diff options
-rw-r--r-- | cat.asm | 8 |
1 files changed, 5 insertions, 3 deletions
@@ -17,6 +17,7 @@ pop rsi ;Pop number of args from the stack cmp esi,1 je stdin ;go to stdin mode if there are no arguments + pop rsi ;discard argv[0] nextarg: @@ -40,7 +41,7 @@ open: copy: mov edi, eax ;move the fd to rdi for read - mov r15, rax ;copy the fd to an AMD64 addittional register for safekeeping + mov r15, rax ;copy the fd to an AMD64 additional register for safekeeping call read output: @@ -68,8 +69,8 @@ stdin: xor edi, edi ;stdin == 0 call read - test eax,eax ; Check if the return value was 0 - je exit ; Jump to exit on EOF recieved + test eax,eax ;Check if the return value was 0 + je exit ;Jump to exit on EOF recieved mov edi, 1 ;file descriptor = stdout mov edx, eax ;move num bytes read to number of bytes to write @@ -79,6 +80,7 @@ stdin: + ; read function, takes rdi as an argument (a fd) read: mov edx, bufflen ;read up to bufflen bytes at once |