Use the Microsoft Visual C Runtime (msvcrt.dll, libmsvcrt in GCC's case) to allow for the printf function (_printf in Windows-speak). For unsigned values, use the "%u" format specifier and for signed values use one of the "%d" or "%i" format specifiers:
; nasm -f win32 -o blah.o blah.asm ; ld -o blah.exe blah.o -lmsvcrt section .data val equ 0xffffffff TAB equ 0x09 LF equ 0x0A s_printf: db "Signed (ASCII):", TAB, TAB, "%i", LF, 0 u_printf: db "Unsigned (ASCII):", TAB, "%u", LF, 0 s_wprintf: dw "S", "i", "g", "n", "e", "d", " ", "(", "w", "i", "d", "e", ")", ":", TAB, TAB, "%", "i", LF, 0 u_wprintf: dw "U", "n", "s", "i", "g", "n", "e", "d", " ", "(", "w", "i", "d", "e", ")", ":", TAB, "%", "u", LF, 0 section .text extern _printf ;for ASCII characters extern _wprintf ;for "wide" characters global _main _main: push ebp mov ebp, esp push dword val push dword s_printf call _printf push dword val push dword u_printf call _printf push dword val push dword s_wprintf call _wprintf push dword val push dword u_wprintf call _wprintf leave xor eax, eax ret ;;;;;;end If it doesn't work, feel free to say so. I tested it using Wine in Linux, not Windows. :P |
| Response Title | Author and Date |
| It works... (5 post scripts) | on Apr 30, 6:49 AM |
| Very nicely done, MC. :) | on May 7, 2:17 PM |
| Again, thank you. | on May 7, 11:20 PM |
| Re: Again, thank you. | on May 8, 2:29 PM |
| *cool. | on May 8, 8:15 PM |