1
section .bss
    valueToPrint : resb 4

section .text
    global _start

_start :

    mov eax ,0x2A
    mov ebx ,0xA
    add eax ,ebx
    mov [valueToPrint] ,eax
    mov eax ,4
    mov ebx ,1
    mov ecx ,valueToPrint
    mov edx ,4
    int 80h

    mov eax ,1
    mov ebx ,0
    int 80h

I expected the above code to print a decimal or hexadecimal number on stdout but it is printing the correspoding ASCII character

Please help me to modify the code such that it should print the result as decimal number

Thanks in advance

rkhb
  • 14,159
  • 7
  • 32
  • 60
  • 1
    Questions about how to convert integers to strings that can be printed have been asked several times before. See e.g. http://stackoverflow.com/questions/19309749/nasm-assembly-convert-input-to-integer/19312503#19312503 – Michael Aug 14 '15 at 16:00
  • And a little more sophisticated: http://stackoverflow.com/a/28524951/3512216 – rkhb Aug 14 '15 at 16:45

0 Answers0