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 "hello world",0
output2 db "again hello world",0
section .bss
section .text
global _start
_start:
mov rcx,output1
call _output
call _exit
_output:
mov rbx,0
_length_loop:
inc rbx
inc rcx
mov dl,[rcx]
cmp dl,0
jne _length_loop
_system_call:
mov rax,1
mov rdi,1
mov rsi,rcx
mov rdx,rbx
syscall
ret
_exit:
mov rax,60
mov rdi,0
syscall
ret
Code: Select all
(gdb) info function
All defined functions:
Non-debugging symbols:
0x0000000000401000 _start
0x0000000000401014 _output
0x0000000000401019 _length_loop
0x0000000000401026 _system_call
0x0000000000401039 _exit
(gdb) break _system_call
Breakpoint 1 at 0x401026
(gdb) run
Starting program: /home/maybe/code/x86/linux/test2
This GDB supports auto-downloading debuginfo from the following URLs:
Enable debuginfod for this session? (y or [n]) y
Debuginfod has been enabled.
To make this setting permanent, add 'set debuginfod enabled on' to .gdbinit.
Breakpoint 1, 0x0000000000401026 in _system_call ()
(gdb) info register rbx
rbx 0xb 11
(gdb) info register rcx
rcx 0x40200b 4202507
Mobile version