Thanks A.K. Encryptor256! Yeah, we could get 32 bits of data into an 8-bit register... 8 bits at a time...
mov al, cl
; do something with it
mov al, ch
; do something with it
shr ecx, 16
mov al, cl
; do something with it
mov al, ch
; do something with it
That probably isn't something you'd want to do. If the 32 bits of data in the 32-bit register is the address of something interesting, we could do:
mov al, [ecx] ; get a byte of "[contents of memory]" from address in ecx into al
That's something you might want to do in the course of displaying a number... which gets us back on topic!
This "how do I print a number?" has got to be the champion "most frequently asked question" of all time, and I'm getting a bit "burnt out" by it. I apologize for showing you that "aam trick". It was a literal answer to the "two digits" part of your question, but not generally useful (good for "time numbers" maybe).
More generally, we need to multiply by ten or divide by ten. The "mul" and "div" instructions are a bit tricky in that some of the operands are "not shown", and the implicit operands and where the result comes vary with the size of the operand we do show. "div" is especially bad in that it'll crash your program if you screw it up. DOS used to report "divide by zero error" (I didn't divide by zero!) and Linux used to report "floating point error" (I didn't use floating point!). The actual exception is a "divide overflow exception": "div" doesn't do a 32-bit by 32-bit divide as you might expect, but a 64-bit (edx:eax) by 32-bit divide, and if the result doesn't fit in 32 bits it causes a processor exception. We may not care what's in edx, but the CPU does! (other sizes for other sizes of the "shown" operand)
The other "difficulty" is that if we divide 1234 by ten, we get a quotient of 123 and a remainder (in edx for a 32-bit "div") of 4, divide by ten again we get 12 and a remainder of 3, again - 1 remainder 2, and again - 0 remainder 1. At this point we're done (can stop when the quotient is less than ten and save a "div" if you want to). We get these remainders in the opposite order than we want to print them. There are various ways to deal with that - push 'em on the stack and pop 'em off, start at the "end" of the buffer and work toward the start, or put 'em in the buffer in "opposite" order and do a "string reverse" at the end... We will need to "convert" each of these numbers to a "character representing the number" by adding '0' or 48 or 30h to each before printing them, but you know how to do that part.
Going the other way, from "text representing a number" (the only kind of input we can get) to the "number" is just kinda "backwards". Start with a "result so far"of zero, get a character (leftmost first), "convert" it to a number by subtracting '0' or 48 or 30h, and - when we're sure it's a valid digit - multiply the "result so far" by ten and add in our new digit... until done.
There's some discussion of various ways to do this, and example code, here:
http://forum.nasm.us/index.php?topic=1514.msg6233#msg6233We can get into this more if need be. It's an important - and very common - question.
When it comes to floating point numbers, just use "scanf" and "printf". They use the same instructions we would use, of course, but it gets "complex"...
Best,
Frank