-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindLab.as
More file actions
59 lines (47 loc) · 941 Bytes
/
indLab.as
File metadata and controls
59 lines (47 loc) · 941 Bytes
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
.include "defs.h"
.section .bss
envp: .quad 0
.section .text
newline:
.byte '\n'
.global _start
_start:
movq (%rsp), %rbx
leaq 16(%rsp,%rbx,8), %rcx
movq %rcx, envp
loop:
movq envp, %rcx
movq (%rcx), %rsi
movq %rsi, %rdi
movq $0, %rdx
strlen:
cmpb $0, (%rdi)
je cont
incq %rdi
incq %rdx
jmp strlen
cont:
movq $SYS_WRITE, %rax
movq $STDOUT, %rdi
syscall
addq $8, envp
movq envp, %r8
cmpq $0x0, (%r8)
je end
cmpq $0,envp
je end
movq $SYS_WRITE, %rax
movq $STDOUT, %rdi
movq $newline, %rsi
movq $1, %rdx
syscall
jmp loop
end:
movq $SYS_WRITE, %rax
movq $STDOUT, %rdi
movq $newline, %rsi
movq $1, %rdx
syscall
movq $SYS_EXIT, %rax
movq $0, %rdi
syscall