NASM - The Netwide Assembler

NASM Forum => Example Code => Topic started by: nobody on December 20, 2007, 06:40:59 PM

Title: print a number
Post by: nobody on December 20, 2007, 06:40:59 PM
hello,
i'm wondering how to simply print a number on the screen !
-first when it's in a register
-second when it's in memory (in .bss i suppose)
Title: Re: print a number
Post by: nobody on December 21, 2007, 01:03:46 AM
> hello

Wrong forum.

> -first when it's in a register

Set up a limit (maybe 999 for start), set up a string buffer, fill it with "000" , start trying to subtract 100's from the register, for every successful subtraction increase the digit in your buffer, when 100's are done, move to 10's, finally just copy the 1's ;-)

> -second when it's in memory (in .bss i suppose)

Load into a register ?
Title: Re: print a number
Post by: nobody on January 02, 2008, 08:36:18 PM
Here is an example of how to do this.  Hope it helps!

http://www.xs4all.nl/~smit/exdec.zip (http://www.xs4all.nl/~smit/exdec.zip)
Title: Re: print a number
Post by: nobody on January 02, 2008, 11:24:04 PM
> Here is an example of how to do this.

YES. Works. It had some MA$M junk inside, however -> fixed:

http://www.file-pasta.com/file/1199315912.6563_NEWEXDEC.ZIP (http://www.file-pasta.com/file/1199315912.6563_NEWEXDEC.ZIP)

Note the 7-times smaller EXE size (COM would be even smaller) - the war on bloat must go on :-D