From 78dd619293539de798678bea576024a4b3f227bc Mon Sep 17 00:00:00 2001 From: Alvin Date: Thu, 8 Oct 2026 01:03:31 +0200 Subject: [PATCH] s --- .gitignore | 2 + C_IMPLEMENTATION.md | 2 + C_OS.md | 8 +- bob.exe | Bin 79583 -> 79583 bytes bob32.exe | Bin 79583 -> 79583 bytes kernel.basm | 305 ++++++++++++++++++++------------------------ kernel/API.md | 4 + kernel/shell.c | 4 +- tests/test_os.c | 2 +- 9 files changed, 159 insertions(+), 168 deletions(-) diff --git a/.gitignore b/.gitignore index f0f2a57..2796ba1 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,5 @@ __pycache__/ bob-files.b16 bob-files.b16.tmp + +*.exe diff --git a/C_IMPLEMENTATION.md b/C_IMPLEMENTATION.md index 080e485..fe640c9 100644 --- a/C_IMPLEMENTATION.md +++ b/C_IMPLEMENTATION.md @@ -581,3 +581,5 @@ The bob32 resident compiler now emits into the native app staging region and sav The bob32 resident compiler now accepts one-dimensional array parameters, adjusting them to pointer-valued stack arguments. It derives addresses for local array arguments, loads and indexes parameter pointers in the callee, and preserves mutation visibility through the caller's array. Prototype/definition signatures retain array-versus-scalar parameter shape, and calls reject known mismatches. Tests cover `sum(values,length)`, indexed iteration, mutation, a nested forwarding call, repeated helper calls, conflicting/multidimensional declarations, and existing local-array behavior. Full suites: CPU 203, OS/compiler 1,825, console 28. Started the app-side standard library with `kernel/bob_string.h`: basic string operations, whitespace detection, overflow-checked signed decimal/hex parsing, bounded integer formatting and quote-aware in-place tokenization. Runtime tests exercise edge cases in bob32, and a compiled app using the header is imported, launched, snapshotted, restored and run again from the bob32 filesystem. Full suites: CPU 203, OS/compiler 1,840, console 28. + +Native bob32 apps can now use `int main(int argc, char **argv)`. The OS shell accepts quoted arguments after an imported app name, preserves empty strings and backslash escapes, and supplies the guest filename as `argv[0]`. A compiled app checks its argument count and values—including a word with spaces and an empty argument—through the real import/run path. Full suites: CPU 203, OS/compiler 1,844, console 28. diff --git a/C_OS.md b/C_OS.md index ebea7e5..13469f0 100644 --- a/C_OS.md +++ b/C_OS.md @@ -41,6 +41,12 @@ image in the guest filesystem, use `import32 build/app.b32 myapp`, then launch it with `run myapp`. `save` includes imported applications in the B32S snapshot; after `restore yes`, run them again without re-importing. `run32` remains available for direct host-path launches. +Native applications may define either `int main(void)` or the conventional +`int main(int argc, char **argv)`. For the latter, `argv[0]` is the guest app +name and `argc` includes it. Pass arguments with `run myapp first "two words"`; +quotes group spaces and backslash escapes the next character. Empty quoted +arguments are preserved. This applies to imported guest files; direct host-path +`run32` launches currently start without command-line arguments. Set `BOB16_TRACE_FAULT=1` before launching the emulator to log the address and instruction when a supervised application faults. The updated emulator also accepts `bob.exe --os` from that directory to boot @@ -87,7 +93,7 @@ token, 0 at end, or -1 for an unclosed quote. | `save` | Save all files to a host snapshot | | `restore yes` | Validate/load that snapshot, replacing the RAM files | | `load name 0x4001 ...` | Store raw bob16 machine words as a program file | -| `run name` | Load a binary program into reserved RAM, execute, return | +| `run name` | Load a program into reserved RAM and run it; native apps accept arguments | | `run32 path` | Load and run a native B32K v2 image from a host path or guest filename | | `import32 path name` | Import a host B32K v2 image into bob32 RAM files | | `halt` | Stop the emulator | diff --git a/bob.exe b/bob.exe index e773967bb5dc1c208446ddc6764ffd484dca51a6..2f0bca7c8c911500626d2fc8938bd33090c3da6d 100644 GIT binary patch delta 23 fcmccrmgW9imI)n4;neI0<-r9PLk<| build/compiler.log 2>&1")==0,"bob32 argv app preprocessing"); check(system(COMPILER " build/argv-app.i build/argv-app.basm build/argv-app.b32 --wide-app > build/compiler.log 2>&1")==0,"bob32 argv app compilation");