i trying learn x86_64 assembly , trying standard input output today , stumbled upon post learning assembly - echo program name how same reading input stdin (using syscall instruction)? if know input integer , want read register? edit: @daniel kozar's answer below helped me understand how stdin , stdout stuff work syscall instruction on linux. attempted write small program, reads number console input , prints ascii character corresponding number. if type 65 input, should output. , new line character. if @ all, helps 1 else :-) section .text global _start _start: mov rdi, 0x0 ; file descriptor = stdin = 0 lea rsi, [rsp+8] ; buffer = address store bytes read mov rdx, 0x2 ; number of bytes read mov rax, 0x0 ; syscall number reading stdin syscall ; make syscall xor rax, rax ; clear off rax mov rbx, [rsp+8] ; read first byte read rsp+8 stdin call rbp sub rbx, 0x30 ; since read character, obtained ascii va...
Comments
Post a Comment