Aufruf von printf in x86 zu drucken, eine ganze Zahl

Ich versuche, call printf drucken eine ganze Zahl ist, setzen Sie es nicht drucken Sie die rechts-Wert:

section .data

         an:    db 1
         format: db "num: %d" , 10, 0

section .text
         global main
         extern printf

main:
         push ebp
         mov ebp,esp

         mov eax, [an]
         push eax
         push dword format
         call printf

         add esp, 8
         mov esp,ebp
         pop ebp

         mov eax, 0
         ret

dieser code druckt "num: 1836412417"

setzen, wenn ich versuche, drucken ein char es funktioniert!

section .data

         an:    db 'a'
         format: db "num: %c" , 10, 0

section .text
         global main
         extern printf

main:
         push ebp
         mov ebp,esp

         mov eax, [an]
         push eax
         push dword format
         call printf

         add esp, 8
         mov esp,ebp
         pop ebp

         mov eax, 0
         ret

nun druckt er "num:"

also, was ist falsch mit dem ersten code ?!!

InformationsquelleAutor 3la210 | 2015-03-19

Schreibe einen Kommentar