mmserty wants you to review
3 unresolved threads
- Resolved by Ivan Cherepanov
- Resolved by Ivan Cherepanov
- Resolved by Ivan Cherepanov
- Resolved by Ivan Cherepanov
- Resolved by Ivan Cherepanov
- Resolved by Ivan Cherepanov
- Resolved by Ivan Cherepanov
- Last updated by Vasiliy Kozlov
124 .out: 44 125 ret 45 126 46 ; Читает один символ из stdin и возвращает его. Возвращает 0 если достигнут конец потока 127 47 128 read_char: 48 129 xor rax, rax 130 xor rdi, rdi 131 push word 0 132 mov rsi, rsp 133 mov rdx, 1 134 syscall 135 cmp rax, 1 136 xor rax, rax 137 jne .exit 138 pop ax - Last updated by Andrey Zhdanov
180 cmp rbx, 0 181 je .loop 182 .exit_eol: 183 mov byte[r12], 0 184 .exit_ok: 185 pop rax 186 jmp .exit 187 .exit_err: 188 pop rax 189 xor rax, rax 190 .exit: 191 pop r13 192 pop r12 193 mov rdx, rbx 194 pop rbx 60 195 ret В документации явно говорится о изменении зачения регистров
rcx
,r11
иrax
. В остальном они следуют соглашениям о вызовах.The Linux AMD64 kernel uses internally the same calling conventions as user level applications (see section 3.2.3 for details). User-level applications that like to call system calls should use the functions from the C library. The interface between the C library and the Linux kernel is the same as for the user-level applications with the following differences:
- User-level applications use as integer registers for passing the sequence %rdi, %rsi, %rdx, %rcx, %r8 and %r9. Thekernelinterfaceuses %rdi, %rsi, %rdx, %r10, %r8 and %r9.
- A system-call is done via the syscall instruction. The kernel destroys registers %rcx and %r11.
- The number of the syscall has to be passed in register %rax.
- System-calls are limited to six arguments, no argument is passed directly on the stack.
- Returning from the syscall, register %rax contains the result of the system-call. A value in the range between-4095 and-1 indicates an error, it is-errno.
- Only values of class INTEGER or class MEMORYarepassed to the kernel.
- Resolved by Ivan Cherepanov
- Last updated by Vasiliy Kozlov
282 jg .fail 283 mov rdx, rax 284 xor rax, rax 285 .loop: 286 mov r10b, byte[rdi + rax] 287 mov byte[rsi + rax], r10b 288 inc rax 289 cmp rax, rdx 290 jl .loop 291 .good: 292 mov rax, rsi 293 jmp .end 294 .fail: 87 295 xor rax, rax 296 .end: 88 297 ret