diff options
author | Nicholas Tay <nick@windblume.net> | 2023-10-23 23:21:10 +1100 |
---|---|---|
committer | Nicholas Tay <nick@windblume.net> | 2023-10-23 23:27:20 +1100 |
commit | 6df757098380fd9450e6e74cbac2bdb69db843bb (patch) | |
tree | 2d5edbd5e2b3ad51a4c2252b2be3395ec1d95521 | |
parent | d850410532fc4cb58756a05f9b5919eefa854975 (diff) | |
download | pasmgen-6df757098380fd9450e6e74cbac2bdb69db843bb.tar.gz pasmgen-6df757098380fd9450e6e74cbac2bdb69db843bb.tar.bz2 pasmgen-6df757098380fd9450e6e74cbac2bdb69db843bb.zip |
Add 3-arg parsing into windows build
Pretty scuffed, but it works... the loading is especially bad but it's
not that much better than linux, except linux we can easily check argc
and at least give usage then. Testing each arg seems to work ok for now
though lol
-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' |