2018-04-07 11:55:02 +00:00
|
|
|
extern puts
|
|
|
|
global foo
|
|
|
|
|
2018-09-07 12:53:56 +00:00
|
|
|
section .rodata
|
2018-09-01 10:16:17 +00:00
|
|
|
|
|
|
|
message:
|
|
|
|
db 'foo() called', 0
|
|
|
|
|
2018-04-07 11:55:02 +00:00
|
|
|
section .text
|
|
|
|
|
2018-04-07 14:57:56 +00:00
|
|
|
;; Long nop macros for nasm/yasm borrowed from nasm-utils:
|
|
|
|
;; https://github.com/travisdowns/nasm-utils
|
|
|
|
%define nop1 nop ; just a nop, included for completeness
|
|
|
|
%define nop2 db 0x66, 0x90 ; 66 NOP
|
|
|
|
%define nop3 db 0x0F, 0x1F, 0x00 ; NOP DWORD ptr [EAX]
|
|
|
|
%define nop4 db 0x0F, 0x1F, 0x40, 0x00 ; NOP DWORD ptr [EAX + 00H]
|
|
|
|
%define nop5 db 0x0F, 0x1F, 0x44, 0x00, 0x00 ; NOP DWORD ptr [EAX + EAX*1 + 00H]
|
|
|
|
%define nop6 db 0x66, 0x0F, 0x1F, 0x44, 0x00, 0x00 ; 66 NOP DWORD ptr [EAX + EAX*1 + 00H]
|
|
|
|
%define nop7 db 0x0F, 0x1F, 0x80, 0x00, 0x00, 0x00, 0x00 ; NOP DWORD ptr [EAX + 00000000H]
|
|
|
|
%define nop8 db 0x0F, 0x1F, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00 ; NOP DWORD ptr [EAX + EAX*1 + 00000000H]
|
|
|
|
%define nop9 db 0x66, 0x0F, 0x1F, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00 ; 66 NOP DWORD ptr [EAX + EAX*1 + 00000000H]
|
|
|
|
|
2018-04-07 11:55:02 +00:00
|
|
|
foo:
|
2018-09-01 10:16:17 +00:00
|
|
|
push ebp
|
2018-09-07 12:53:56 +00:00
|
|
|
mov ebp, esp
|
|
|
|
sub esp, 4 ; align the stack to a 16-byte boundary
|
2018-04-07 11:55:02 +00:00
|
|
|
push message
|
|
|
|
call puts
|
2018-09-07 12:53:56 +00:00
|
|
|
mov esp, ebp
|
2018-09-01 10:16:17 +00:00
|
|
|
pop ebp
|
2018-04-07 11:55:02 +00:00
|
|
|
ret
|