Code: Select all
section .data
output1 db "hello world",10,0
output2 db "hello world again",10,0
section .bss
section .text
global _start
_start:
mov rax,output1
call _output
mov rax,output2
call _output
call _exit
_output:
_output_setup:
push rax
mov rbx, 0
_output_length_loop:
inc rax
inc rbx
mov cl,[rax]
cmp cl, 0
jne _output_length_loop
_output_output:
mov rax, 1
mov rdi, 1
pop rsi
mov rdx, rbx
syscall
ret
_exit:
mov rax, 60
mov rdi, 0
syscall
ret
Code: Select all
section .data
output1 db "print this string",10,0
output2 db "print this string again",10,0
section .text
global _start
_start:
mov rcx,output1
call _output
mov rcx,output2
call _output
call _exit
_output:
_output_setup:
mov rbx,0
_output_length_loop:
inc rbx
inc rcx
mov dl,[rcx]
cmp dl,0
jne _output_length_loop
_output_output:
mov rax,0
mov rdi,0
mov rsi,rcx
mov rdx,rbx
syscall
ret
_exit:
mov rax,60
mov rdi,0
syscall
ret
meine zeilenweise Analyse ermitteln:-
Code: Select all
rcx rbx dl_
_start
b1 - mov rcx, output1
- call _output
_output
0 - mov rbx,0
_output_loop_length -0
1 - inc rbx
ib1 - inc rcx
p - mov dl,[rcx]
- cmp dl,0 (p != 0)
- jne _output_length_loop
_output_loop_length -1
2 - inc rbx
ib1 - inc rcx
r - mov dl,[rcx]
- cmp dl,0 (p != 0)
- jne _output_length_loop
...
_output_loop_length -2
3 - inc rbx
ib1 - inc rcx
0 - mov dl,[rcx]
- cmp dl,0 (p == 0)
- jne _output_length_loop
...
i vor b1 steht für erhöhte Position des Init-Bytes
Ich vermute, dass „inc rcx“ irgendwie eine Endlosschleife erzeugt, bin mir aber nicht sicher, wieso ich außerdem Unklarheiten in Bezug auf die entsprechende Zeile habe.
Mobile version