aboutsummaryrefslogtreecommitdiffstats
path: root/cat.s
diff options
context:
space:
mode:
authorturret <turret@duck.com>2023-09-08 10:11:38 -0500
committerturret <turret@duck.com>2023-09-08 10:11:38 -0500
commit64b2832475a676b4126e4a7807c2ad4b3fdad0dd (patch)
tree8cab3acb4c41b14a21a3a08b50ba671be5e5a95b /cat.s
parent7fe2c32d10543e5d06b745f92bea86d7483c4b5d (diff)
downloadcat-64b2832475a676b4126e4a7807c2ad4b3fdad0dd.tar.gz
cat-64b2832475a676b4126e4a7807c2ad4b3fdad0dd.tar.bz2
cat-64b2832475a676b4126e4a7807c2ad4b3fdad0dd.zip
cat: actual groundwork for flags
Diffstat (limited to 'cat.s')
-rw-r--r--cat.s34
1 files changed, 28 insertions, 6 deletions
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
+