Question

I posted a question a while back about this but I figured I would start a new thread as the code has changed entirely. I am trying to store a byte string into a memory address created by malloc. When executing the program from terminal I get:

Loaded into eax: 49

I have been following the Intel manual(pdf) exactly as said (or atleast I think). Page 175 for General Purpose Register String Instructions.

    .global main
.text
str: .string "Loaded into eax: %d\n"
one: .string "1"

main:
pushl   $4          #push size of malloc
call    malloc      #call malloc
popl    %ecx        #clear malloc size off of stack
movl    %eax, %edi  #move address to destination
movl    %edi, %ecx  #
movb    one, %al    #move a 1 into %al
stosb               #store the 1 in %al to the address in destination
movl    %ecx, %esi  #move address to source for lodsb
movl    $0, %eax     #clear eax register
lodsb               #load content of (%esi) into %eax
pushl   %eax        #push that content onto stack
pushl   $str        #push string format onto stack
call    printf      #call printf
popl    %ecx        #clear stack
popl    %ecx        #clear stack
end:

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top