diff options
author | JozanLeClerc <bousset.rudy@gmail.com> | 2020-04-27 01:02:18 +0200 |
---|---|---|
committer | JozanLeClerc <bousset.rudy@gmail.com> | 2020-04-27 01:02:18 +0200 |
commit | ea0eca4f717d7f4408273613a566f3550d27085b (patch) | |
tree | b1c1fa062823bb36bbd8bb9dab6437c83c229eec /asm/c_args.asm | |
parent | Makefile change (diff) | |
download | lowbat-bsd-ea0eca4f717d7f4408273613a566f3550d27085b.tar.gz lowbat-bsd-ea0eca4f717d7f4408273613a566f3550d27085b.tar.bz2 lowbat-bsd-ea0eca4f717d7f4408273613a566f3550d27085b.tar.xz lowbat-bsd-ea0eca4f717d7f4408273613a566f3550d27085b.tar.zst lowbat-bsd-ea0eca4f717d7f4408273613a566f3550d27085b.zip |
Rewrite started
Diffstat (limited to 'asm/c_args.asm')
-rw-r--r-- | asm/c_args.asm | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/asm/c_args.asm b/asm/c_args.asm new file mode 100644 index 0000000..dcca5d3 --- /dev/null +++ b/asm/c_args.asm @@ -0,0 +1,47 @@ +/* ************************************************************************************ */ +/* */ +/* File : c_args.asm /_________/ */ +/* Author : Joe | */ +/* Date : 04/2020 | */ +/* Info : Check args | */ +/* / | */ +/* \ / */ +/* \_____/ */ +/* */ +/* ************************************************************************************ */ + +;; jo_c_args(argc: rdi, *argv[]: rsi) +;; ---------------------------------- +;; returns 0 if args are invalid +;; returns 1 if args are valid + +section .text + extern strncmp + global jo_c_args + +jo_c_args: + cmp rdi, 0x2 + jle no_args + mov rax, [rsi + 0x8 * 0x2] + cmp byte [rax + 0x0], 0x0 + je no_args + push rdi + mov rdi, [rsi + 0x8 * 0x1] + push rsi + mov rsi, reference + mov rdx, reflen + call strncmp + pop rsi + pop rdi + cmp rax, 0x0 + jne no_args + mov rax, 0x1 + retq + +no_args: + xor rax, rax + retq + +section .data + reference: db "--say", 0x0 + reflen: equ $ - reference |