diff options
Diffstat (limited to '')
-rw-r--r-- | pasmgen-win.asm | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/pasmgen-win.asm b/pasmgen-win.asm index c65c47b..927f9b7 100644 --- a/pasmgen-win.asm +++ b/pasmgen-win.asm @@ -7,6 +7,43 @@ section '.text' code readable executable entry main main: + invoke GetCommandLine + +argparse: +.skipexe: + cmp byte [rax], 0 + je defaultargs + + cmp byte [rax], ' ' + je .pastexe + inc rax + jmp .skipexe +.pastexe: + ;; load arg1 + ;; FIXME: at least on my system, there's 2 more spaces (needs more testing if consistent) + mov r8, [rax+2] + and r8, 0xFF + test r8, r8 + jz fail + sub r8, 48 + + ;; load arg2 + mov r9, [rax+4] + and r9, 0xFF + test r9, r9 + jz fail + sub r9, 48 + + ;; load arg3 + mov r10, [rax+6] + and r10, 0xFF + test r10, r10 + jz fail + sub r10, 48 + + jmp generate + +defaultargs: mov r8, qword 3 mov r9, qword 2 mov r10, qword 3 @@ -18,6 +55,11 @@ ok: invoke WriteConsole, rax, out_buf, rsi, 0, 0 invoke ExitProcess, 0 +fail: + invoke GetStdHandle, STD_OUTPUT_HANDLE + invoke WriteConsole, rax, usage, usage_len, 0, 0 + invoke ExitProcess, 1 + include 'pasmgen.inc' |