Hi, fellow programmers!
I'm writing a function in real mode, (yes you guessed it, it's for an OS bootloader
), that'll print the integer stored in AX.
This is the approach that I have chosen, and it should work (to my understading, even though it might not be the best way to do it)..
1)Divide the integer in AX by 10, if the results of the prior computations isn't 0.
2)Push the remainder onto the stack.
3)Increase CX.
4)Do it again.
5)When the result is 0, and all of the remainders are pushed to the stack, pop CX amount of integers off of the stack, in a loop.
6)In each cycle add 0x30 to the popped value, and print it using INT 0x10, AH=0xE.
I have tried writing this function myself A LOT of times, but I've never succeded.. probably because I'm unsure of how the 'div' instruction works in NASM.
So could someone please try to explain to me, where the instruction expects the value to be divided to be, in which register (or parameter) it'll expect the divisor, and finally where the results and remainders are stored?
Oh and one more thing, how can I increase the literal value of CX?
Best regards,
-Benjamin.