From a8dea7b3dbe58fc16cbd5c197c4921dc325ec4b8 Mon Sep 17 00:00:00 2001 From: Auios Date: Sun, 11 Feb 2024 22:54:32 -0500 Subject: [PATCH 1/8] Create settings.json --- .vscode/settings.json | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..4594df2 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,4 @@ +{ + "editor.tabSize": 4 +} + From 861820aa49840c3879ed4d059f817f4e5760e5cd Mon Sep 17 00:00:00 2001 From: Auios Date: Sun, 11 Feb 2024 22:54:37 -0500 Subject: [PATCH 2/8] Examples --- examples/add1.asm | 7 +++++++ examples/double.asm | 5 +++++ 2 files changed, 12 insertions(+) create mode 100644 examples/add1.asm create mode 100644 examples/double.asm diff --git a/examples/add1.asm b/examples/add1.asm new file mode 100644 index 0000000..512dd70 --- /dev/null +++ b/examples/add1.asm @@ -0,0 +1,7 @@ +; This program adds 1 to register A until it equals 64, then halts. +ldb 1 +loop: +add b +cmp 64 +jnz loop +hlt \ No newline at end of file diff --git a/examples/double.asm b/examples/double.asm new file mode 100644 index 0000000..40782cd --- /dev/null +++ b/examples/double.asm @@ -0,0 +1,5 @@ +; Endlessly doubles A by adding itself to itself. +lda 1 +add b +ldb a +jpr loop \ No newline at end of file From e1540ff2b10140fe6f1d75c3a18dc1e801910998 Mon Sep 17 00:00:00 2001 From: Auios Date: Tue, 13 Feb 2024 18:38:02 -0500 Subject: [PATCH 3/8] Create fibonacci.asm --- .gitignore | 1 + .vscode/settings.json | 4 --- examples/fibonacci.asm | 8 ++++++ examples/helloworld.asm | 16 +++++++++++ examples/{add1.asm => increment_reg.asm} | 5 ++-- memoryMap.md | 36 ++++++++++++++++++++++++ readme.md | 2 ++ 7 files changed, 66 insertions(+), 6 deletions(-) create mode 100644 .gitignore delete mode 100644 .vscode/settings.json create mode 100644 examples/fibonacci.asm create mode 100644 examples/helloworld.asm rename examples/{add1.asm => increment_reg.asm} (88%) create mode 100644 memoryMap.md diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..600d2d3 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.vscode \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index 4594df2..0000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "editor.tabSize": 4 -} - diff --git a/examples/fibonacci.asm b/examples/fibonacci.asm new file mode 100644 index 0000000..63a632e --- /dev/null +++ b/examples/fibonacci.asm @@ -0,0 +1,8 @@ +lda 1 +ldb 0 + +fib_loop: +ldc b +ldb a +add c +jlt fib_loop ; Stop when carry flag is set \ No newline at end of file diff --git a/examples/helloworld.asm b/examples/helloworld.asm new file mode 100644 index 0000000..baf2b0b --- /dev/null +++ b/examples/helloworld.asm @@ -0,0 +1,16 @@ +.org $0100 ; Static data +hello_str: +"Hello world\0" + +.org $0000 ; Program must start at $0000 +ldp $0800 ; Char display +ldq hello_str + +print: +lda *q++ +jpz print_end +sta *p++ +jmp print: + +print_end: +hlt \ No newline at end of file diff --git a/examples/add1.asm b/examples/increment_reg.asm similarity index 88% rename from examples/add1.asm rename to examples/increment_reg.asm index 512dd70..38112ac 100644 --- a/examples/add1.asm +++ b/examples/increment_reg.asm @@ -1,7 +1,8 @@ ; This program adds 1 to register A until it equals 64, then halts. -ldb 1 + loop: -add b +inc a cmp 64 jnz loop + hlt \ No newline at end of file diff --git a/memoryMap.md b/memoryMap.md new file mode 100644 index 0000000..cc1ea6d --- /dev/null +++ b/memoryMap.md @@ -0,0 +1,36 @@ +## Boot ROM +Execution starts here, at address `$0000`. +The OS bootloader is located here. + +## GPIO +Contains hardware multiplication (`$0400`-`$0401`) and division (`$0402`-`$0403`), popcount (`$0404`), and a timer (`$0405`). + +## Keyboard +Read address `$0500` to get the next key event (7-bit Windows VKey code, MSB on indicates press/release). Returns 0 if empty. +Write 1 to `$0500` to enable interrupts. + +## Serial Peripheral Interface +Not yet implemented. + +## Robot Controller +Not directly mentioned in the provided code snippets, but if it follows a similar addressing scheme, it would have a specific range not covered here. + +## Text Display +Write ASCII values to addresses `$0800` to `$0FFF` to display characters at certain positions on the screen. +`$0800` is the top left, `$0FFF` would be the bottom right, considering the character display dimensions and memory layout. + +## Text Display Color +Write 6-bit color IDs to addresses `$0800` to `$0FFF` to set the color of characters on screen. +MSB = whether to invert character mask (i.e., for highlighting). This might need clarification or correction based on the actual implementation, as it seems to overlap with the Text Display's address range. + +## System RAM +The OS may use this memory for the stack, system variables, etc., located at `$1000` to `$1FFF`. + +## User ROM +Your program and data go here, located at `$2000` to `$2FFF`. + +## User RAM +Your code can use this memory for variables, arrays, a heap, etc., located at `$3000` to `$3FFF`. + +## Video Display +Not directly mentioned in the provided snippets for addressing, but based on the peripheral configuration, it would be addressed from `$8000` to `$FFFF` for direct pixel manipulation or other video-related functions. diff --git a/readme.md b/readme.md index f7a0ded..e204f56 100644 --- a/readme.md +++ b/readme.md @@ -27,3 +27,5 @@ For a list of instructions, see [instructionList.txt](instructionList.txt). love . C:/path/filename.asm ``` +## Memory Map +[memory map](memoryMap.md) From cf08a90c7e04b98ef5afeb74a9903531aeb15fa7 Mon Sep 17 00:00:00 2001 From: Auios Date: Wed, 14 Feb 2024 13:36:13 -0500 Subject: [PATCH 4/8] Delete double.asm --- examples/double.asm | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 examples/double.asm diff --git a/examples/double.asm b/examples/double.asm deleted file mode 100644 index 40782cd..0000000 --- a/examples/double.asm +++ /dev/null @@ -1,5 +0,0 @@ -; Endlessly doubles A by adding itself to itself. -lda 1 -add b -ldb a -jpr loop \ No newline at end of file From a87ea1f26101d6bdc48e8ef865b292a87de45fc9 Mon Sep 17 00:00:00 2001 From: Auios Date: Fri, 16 Feb 2024 16:59:56 -0500 Subject: [PATCH 5/8] Update readme.md --- readme.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/readme.md b/readme.md index e204f56..a49afdc 100644 --- a/readme.md +++ b/readme.md @@ -4,20 +4,20 @@ For a list of instructions, see [instructionList.txt](instructionList.txt). ## How to use the assembler: 1. Install `bllua3` from [https://notabug.org/redo/bllua3](https://notabug.org/redo/bllua3) -2. Download this repo somewhere into the Blockland folder. +2. Download this repo into one of Blockland's main directories. (`Add-Ons` or `base` for example) 3. In BL console, execute: ``` - luaexec("your_path/assembler-8608.lua"); + luaexec("Add-Ons/_misc/8608/assembler-8608.lua"); ``` 4. To assemble a program, place a 1x1f ghost brick on the top-left corner of the ROM, face forward, and in BL console do: ``` - AssembleBuildFile("other_path/filename.asm", "RomX RomY RomZ"); + AssembleBuildFile("Add-Ons/_misc/8608/examples/program.asm", "RomX RomY RomZ"); ``` where `RomX` is the width of the ROM, `RomY` is the depth front to back, and `RomZ` is the height in bits, i.e., "16 16 8". - + You can also run the assembler from the command line to get a memory dump and disassembly in stdout, if you have lua installed: ``` - luajit "your_path/assembler-8608.lua" "other_path/filename.asm" + luajit "Add-Ons/_misc/8608/assembler-8608.lua" "Add-Ons/_misc/8608/program/asm.asm" ``` ## How to use the emulator: From 971f8a326c1bad2f1b95533aa2f16eec2d2515d4 Mon Sep 17 00:00:00 2001 From: Auios Date: Fri, 16 Feb 2024 17:00:29 -0500 Subject: [PATCH 6/8] Update memoryMap.md --- memoryMap.md | 41 +++++++++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 16 deletions(-) diff --git a/memoryMap.md b/memoryMap.md index cc1ea6d..d87c386 100644 --- a/memoryMap.md +++ b/memoryMap.md @@ -1,36 +1,45 @@ ## Boot ROM -Execution starts here, at address `$0000`. -The OS bootloader is located here. +Execution starts here, at address `$0000`.
+The main program is located here, or the OS bootloader if an OS is present. ## GPIO -Contains hardware multiplication (`$0400`-`$0401`) and division (`$0402`-`$0403`), popcount (`$0404`), and a timer (`$0405`). +Contains hardware multiplication (`$0400 * $0401 -> $0400`) and division (`$0402 / $0403 -> $0402 r $0403`), popcount (`$0404 -> $0404`), and a timer (`$0405`).
+Value written to timer register = number of game ticks (32 ms) between interrupt triggers.
+Write 0 to disable. ## Keyboard -Read address `$0500` to get the next key event (7-bit Windows VKey code, MSB on indicates press/release). Returns 0 if empty. -Write 1 to `$0500` to enable interrupts. +Read address `$0500` to get the next key event
+7-bit Windows VKey code, MSB 1 = press, 0 = release
+Returns 0 if buffer is empty. +Write 1 to `$0500` to enable keyboard interrupts, 0 to disable. ## Serial Peripheral Interface Not yet implemented. ## Robot Controller -Not directly mentioned in the provided code snippets, but if it follows a similar addressing scheme, it would have a specific range not covered here. +Write to `$0701` to control the robot. Each bit is an action - MSB to LSB: Plant brick, destroy brick, move forward, backward, left, right, up, down.
+Write a 6-bit color ID to `$0700` to set the color of the bricks the robot plants.
+Read `$0700` to get the color of the brick the robot is on. MSB = brick exists. Returns 0 if no brick. + ## Text Display -Write ASCII values to addresses `$0800` to `$0FFF` to display characters at certain positions on the screen. -`$0800` is the top left, `$0FFF` would be the bottom right, considering the character display dimensions and memory layout. +Write ASCII values to `$0800` to `$0BFF` to display characters at certain positions on screen.
+`$0800` is top left, `$0BFF` is bottom right, rows are 64 bytes. ## Text Display Color -Write 6-bit color IDs to addresses `$0800` to `$0FFF` to set the color of characters on screen. -MSB = whether to invert character mask (i.e., for highlighting). This might need clarification or correction based on the actual implementation, as it seems to overlap with the Text Display's address range. +Write 6-bit color IDs to `$0C00` to `$0FFF` to set the color of characters on screen.
+MSB = whether to invert character mask (i.e. for highlighting). ## System RAM -The OS may use this memory for the stack, system variables, etc., located at `$1000` to `$1FFF`. +The OS may use this memory for the stack, system variables, etc.
+If no OS is present, this memory can be used for any purpose, etc.
+Located at `$1000` to `$1FFF`. ## User ROM -Your program and data go here, located at `$2000` to `$2FFF`. +User program and data can go here.
+If no OS is present, the boot ROM will need to jump into this code.
+Located at `$2000` to `$2FFF`. ## User RAM -Your code can use this memory for variables, arrays, a heap, etc., located at `$3000` to `$3FFF`. - -## Video Display -Not directly mentioned in the provided snippets for addressing, but based on the peripheral configuration, it would be addressed from `$8000` to `$FFFF` for direct pixel manipulation or other video-related functions. +Your code can use this memory for variables, arrays, a heap, etc.
+Located at `$3000` to `$3FFF`. From 64a98f6add8613680ed4c2fa55568660979a169c Mon Sep 17 00:00:00 2001 From: Auios Date: Fri, 16 Feb 2024 17:00:38 -0500 Subject: [PATCH 7/8] Examples --- .gitignore | 3 ++- examples/clear_screen.asm | 30 +++++++++++++++++++++++ examples/functions.asm | 50 +++++++++++++++++++++++++++++++++++++++ examples/helloworld.asm | 4 ++-- 4 files changed, 84 insertions(+), 3 deletions(-) create mode 100644 examples/clear_screen.asm create mode 100644 examples/functions.asm diff --git a/.gitignore b/.gitignore index 600d2d3..da66e67 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -.vscode \ No newline at end of file +.vscode +programs \ No newline at end of file diff --git a/examples/clear_screen.asm b/examples/clear_screen.asm new file mode 100644 index 0000000..1d63917 --- /dev/null +++ b/examples/clear_screen.asm @@ -0,0 +1,30 @@ +.include _hwdefs.asm +.include _clrdefs.asm + +;; Variables +.org SYSRAM +stack: byte[128] + +;; Main +.org SYSROM +lds stack +jss cls + +hlt + +;; Clear the screen +FUNC cls: + ldp screen.char + ldc $00 ;; Blank + ldq screen.color + ldb CLR_BLACK ;; Black + .cls_loop: { + stc *p++ + stb *q++ + lda pl + cmp (lo(COLOR)) + jnz .cls_loop + lda ph + cmp (hi(COLOR)) + jnz } +rts diff --git a/examples/functions.asm b/examples/functions.asm new file mode 100644 index 0000000..e52cfc1 --- /dev/null +++ b/examples/functions.asm @@ -0,0 +1,50 @@ +.include _hwdefs.asm +.include _clrdefs.asm + +;; Defines +.define VARS $0100 + +;; Variables +.org SYSRAM +stack: byte[128] + +.org VARS +hello_str: "Hello world!\0" + +;; Main +.org SYSROM +lds stack + +jss cls + +ldp screen.char +ldq hello_str +jss print + +hlt + +;; Clear the screen +FUNC cls: + ldp screen.char + ldc $00 ;; Blank + ldq screen.color + ldb CLR_BLACK ;; Black + .cls_loop: { + stc *p++ + stb *q++ + lda pl + cmp (lo(COLOR)) + jnz .cls_loop + lda ph + cmp (hi(COLOR)) + jnz } +rts + +;; Print string (Q) to the current screen cursor (P) +FUNC print: + lda *q++ + jpz .print_end + sta *p++ + jmp print + .print_end: +rts diff --git a/examples/helloworld.asm b/examples/helloworld.asm index baf2b0b..d33bc46 100644 --- a/examples/helloworld.asm +++ b/examples/helloworld.asm @@ -10,7 +10,7 @@ print: lda *q++ jpz print_end sta *p++ -jmp print: +jmp print print_end: -hlt \ No newline at end of file +hlt From 4af1b92d05e38b7452cdb5bab33bbda1a6a680b3 Mon Sep 17 00:00:00 2001 From: Auios Date: Tue, 20 Feb 2024 19:15:24 -0500 Subject: [PATCH 8/8] Update readme.md --- readme.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/readme.md b/readme.md index a49afdc..4e4b167 100644 --- a/readme.md +++ b/readme.md @@ -4,20 +4,20 @@ For a list of instructions, see [instructionList.txt](instructionList.txt). ## How to use the assembler: 1. Install `bllua3` from [https://notabug.org/redo/bllua3](https://notabug.org/redo/bllua3) -2. Download this repo into one of Blockland's main directories. (`Add-Ons` or `base` for example) +2. Download this repo into `Add-Ons/8608` or anywhere within one of Blockland's main directories. 3. In BL console, execute: ``` - luaexec("Add-Ons/_misc/8608/assembler-8608.lua"); + luaexec("Add-Ons/8608/assembler-8608.lua"); ``` 4. To assemble a program, place a 1x1f ghost brick on the top-left corner of the ROM, face forward, and in BL console do: ``` - AssembleBuildFile("Add-Ons/_misc/8608/examples/program.asm", "RomX RomY RomZ"); + AssembleBuildFile("Add-Ons/8608/examples/program.asm", "RomX RomY RomZ"); ``` where `RomX` is the width of the ROM, `RomY` is the depth front to back, and `RomZ` is the height in bits, i.e., "16 16 8". You can also run the assembler from the command line to get a memory dump and disassembly in stdout, if you have lua installed: ``` - luajit "Add-Ons/_misc/8608/assembler-8608.lua" "Add-Ons/_misc/8608/program/asm.asm" + luajit "Add-Ons/8608/assembler-8608.lua" "Add-Ons/8608/examples/program.asm" ``` ## How to use the emulator: