Reputation: 96
Here is the assembly, I am using Windows 11.
Assembling: as .\test.S -o test.out
Linking: ld -o test.exe -subsys=console test.out -L "C:\TDM-GCC-64\x86_64-w64-mingw32\lib" -lmsvcrt
When i run the program a garbage exit code is thrown...
I think the foo function is the culprit.
Even when i remove call foo
, it gives random exit code.
;#; This file was generated by the MZ compiler.
.section .data
b: .space 8
a: .space 8
.section .text
foo:
push %rbp
mov %rsp, %rbp
sub $32, %rsp
add $32, %rsp
pop %rbp
ret
.global _start
_start:
push %rbp
mov %rsp, %rbp
sub $32, %rsp
lea a(%rip), %rax
movq $420, (%rax)
lea b(%rip), %rax
movq $42, (%rax)
mov $10, %rcx
mov $3, %rdx
call foo
add $32, %rsp
pop %rbp
movq $0, %rax
ret
Upvotes: 1
Views: 66