![]() |
nasm assembler; output numbers?
Probably a very simple question - I am just starting assembler. If I have something like:
Code:
...Code:
...Thanks |
My assembly knowledge is limited to microcontrollers and at this stage very rusty.
AFAIK you have to do the conversion yourself. Below some pseudo-code that might help you on the way: Code:
// first digitConversion is done by simply adding 30hex. After the conversion, we divide the pid by 10 so we can use the modulo-10 on the next digit. Please note that the above example places the digits in reverse order in the buffer. Hope this helps you on the way. |
Nice to have someone new to assembler programing
O.K. the code above you got posted is a little difficult to convert to NASM and would than be code of
(I guess) 600 lines. And yes, you have to convert the value to ascii-numbers you can read. In assembler you have all to do on your own in assembler there are no were lying headers and libraries around like with c++. Now here a procedure to convert the value of eax from my homepage: beckware.de - INFO - software - NASM - examples or direct: http://people.freenet.de/beckware/na...xtostdout.html there are also other useful things. Have also a look to the NASM forum: http://sourceforge.net/forum/?group_id=6208 Code:
;With div edi, eax is divided by 10 and edx holds the rest. Ascii ´0´ is decimal 48 and that is added to edx and stored into .buf back-wards. Now .buf is written to STDOUT that´s all. |
Ah thank you. That works great, thanks for the explaination to, I understand how it is done now! I did try to convert Wim Sturkenboom's code to NASM, but I couldn't quite do it. The DIV operator confused me somewhat, but after reading the manual carefully and looking at your code/explaination i think i understand it now.
Thanks a lot. |
Bumping there for telling you this solution still working perfectly.
Is clean and easy to understand. Thank you. |
| All times are GMT -5. The time now is 05:02 PM. |