printf does not print negative numbers. See example:

.model flat includelib msvcrt.lib printf proto c, :vararg .data resp db 'k = %d',10,13,0 k db ? .code public main main proc mov k, -1 invoke printf, addr resp, k xor eax, eax ret main endp end 

It turns out k = 255, but not k = -1 How to print a negative number?


So far I have done this:

 movsx ebx, k invoke printf, addr resp, ebx 
  • one
    Try k dd ? instead of db . printf assumes that 32-bit integers are passed to it. - insolor

1 answer 1

If you want to print a byte, use "%hd" ,
h says that the parameter size is byte.