From 64b2832475a676b4126e4a7807c2ad4b3fdad0dd Mon Sep 17 00:00:00 2001 From: turret Date: Fri, 8 Sep 2023 10:11:38 -0500 Subject: cat: actual groundwork for flags --- cat.s | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) (limited to 'cat.s') diff --git a/cat.s b/cat.s index b02be26..279164f 100644 --- a/cat.s +++ b/cat.s @@ -32,15 +32,31 @@ process_fd: ret _start: - ; TODO: cmd flag consumer - ; r12 = argc mov rbp, rsp - mov r13, [rbp] mov r12, [rbp] cmp r12, 2 - jl .stdin + jl final.stdin + +.loop: + cmp r12, 2 + jl final + + mov r11, [rbp] + mov r11, [r11] + and r11, 0xff + cmp r11, 0x2d ;'-' + jne .cont +.cont: + add rbp, 8 + sub r12, 1 + jmp .loop + +final: + ; fix rbp and r12 + mov rbp, rsp + mov r12, [rbp] add rbp, 8 * 2 ; jump past 1st arg .loop: @@ -104,8 +120,14 @@ exit: mov rdi, 0 syscall - section .data - section .bss bufSize: equ 65536 buf: resb bufSize + +numbernonblankonly: equ 0b000001 +showends: equ 0b000010 +numberlines: equ 0b000100 +squeezeblanks: equ 0b001000 +showtabs: equ 0b010000 +shownonprinting: equ 0b100000 + -- cgit v1.2.3