-1

I tried creating a very simple example: a conversion program, where one number is an int and the other is a double.

global _main
extern _printf

section .data
    km_h    dd  70
    format  db '%fmph=%dkm/h',10,13,0
    km_mi   dq 1.609

section .code
_main:
    push ebp
    mov ebp, esp
    
    sub esp, 16 ;for the parameters
    
    fld qword [km_mi]
    fimul dword [km_h]
    
    mov dword [esp], format
    mov eax, dword [km_h]
    mov [esp+12], eax
    fstp qword [esp+4]
    push format
    call _printf
    
    mov esp, ebp
    pop ebp
    ret

I tried cc -S on a C source and went as far as writing it with mov [esp+X] instead of pushing, but whatever I try, it outputs garbage.

1 Answers1

0

Okay, I've removed the push and it works now. The conversion is still backwards, but that's easy to fix, and of course, that didn't really matter, it was just a homework to practice the opcodes.