diff options
author | JozanLeClerc <bousset.rudy@gmail.com> | 2020-04-17 19:35:12 +0200 |
---|---|---|
committer | JozanLeClerc <bousset.rudy@gmail.com> | 2020-04-17 19:35:12 +0200 |
commit | 96caf953fb9d851b2f949fcd52dd7194ee6b1bb2 (patch) | |
tree | 79e491bab9e767be9fb738da0df1abc0ee0372d1 /asm/jo_c_args.asm | |
parent | in progress (diff) | |
download | lowbat-bsd-96caf953fb9d851b2f949fcd52dd7194ee6b1bb2.tar.gz lowbat-bsd-96caf953fb9d851b2f949fcd52dd7194ee6b1bb2.tar.bz2 lowbat-bsd-96caf953fb9d851b2f949fcd52dd7194ee6b1bb2.tar.xz lowbat-bsd-96caf953fb9d851b2f949fcd52dd7194ee6b1bb2.tar.zst lowbat-bsd-96caf953fb9d851b2f949fcd52dd7194ee6b1bb2.zip |
On the way, solved segv
Diffstat (limited to 'asm/jo_c_args.asm')
-rw-r--r-- | asm/jo_c_args.asm | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/asm/jo_c_args.asm b/asm/jo_c_args.asm index c18fbf7..8c91e57 100644 --- a/asm/jo_c_args.asm +++ b/asm/jo_c_args.asm @@ -10,24 +10,30 @@ ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; returns 0 if args are invalid +;; returns 1 if args are valid + section .text extern strncmp global jo_c_args -jo_c_args: ; jo_c_args(argc: rdi, *argv[]: rdi) +jo_c_args: ; jo_c_args(argc: rdi, *argv[]: rsi) cmp rdi, 0x2 jle no_args + mov rax, [rsi + 0x8 * 0x2] + cmp byte [rax + 0x0], 0x0 + je no_args push rdi - mov rdi, [rsi + 8 * 1] + mov rdi, [rsi + 0x8 * 0x1] push rsi mov rsi, reference - mov rdx, len + mov rdx, reflen call strncmp pop rsi pop rdi cmp rax, 0x0 jne no_args - mov rax, [rsi + 8 * 2] + mov rax, 0x1 retq no_args: @@ -36,4 +42,4 @@ no_args: section .data reference: db "--say", 0x0 - len: equ $ - reference ; reference len + reflen: equ $ - reference ; reference len |