-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEchoExecFile.asm
More file actions
40 lines (30 loc) · 1.2 KB
/
EchoExecFile.asm
File metadata and controls
40 lines (30 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
; ********************************************************************************
; This asm program reads the filename of executable
; ********************************************************************************
%include "lib/io.asm"
section .data
argc dd 0
section .text
global _start
_start:
lea eax, [argc] ; load argc address into eax
pop dword [eax] ; save no of args to argc
pop ebx ; first arg address
xor eax, eax ; clear eax
xor edi, edi ; clear edi (edi = counts len of arg0)
loop_count_arg:
mov al, byte [ebx+edi] ; eax: char
inc edi ; index++ (counter)
cmp al, 0 ; check if null
jne loop_count_arg ; jump if null char
dec edi ; excludes null char
; print buffer value
mov ecx, ebx
mov edx, edi
call PrintStr
Newline
exit:
; exit with success status
mov eax, 1 ; system call for exit
xor ebx, ebx ; exit status of 0
int 0x80 ; invoke the system call