1
0
mirror of https://github.com/rkujawa/rk65c02.git synced 2026-03-11 03:16:11 +00:00
Files
rk65c02/examples/tinyos_task.s
Radosław Kujawa d3bafd5892 Add Tiny OS example: scheduler with extended physical RAM
- examples/tinyos.c: host with 64K system RAM, 3x32KB task regions above 64K
  (bus_device_add_phys), MMU translate (virtual 32KB per task), console at
  , cooperative yield ( + JMP cd /home/rkujawa/repos/rk65c02 && git commit --trailer "Made-with: Cursor" -m "Add Tiny OS example: scheduler with extended physical RAM

- examples/tinyos.c: host with 64K system RAM, 3x32KB task regions above 64K
  (bus_device_add_phys), MMU translate (virtual 32KB per task), console at
  $DE00, cooperative yield ($FF00 + JMP $1000) and WAI + idle_wait + IRQ
  yield, vectors at $FFFC-$FFFF
- examples/tinyos_kernel.s: entry at $8000, IRQ handler at $8010 (JMP $1000)
- examples/tinyos_task.s: per-task loop printing task id, round-robin yield,
  optional WAI, STP after 3 runs
- Makefile: tinyos target, run-tinyos with timeout
- README.md, doc/MMU.md: document Tiny OS (64K virtual + expanded physical)
- .gitignore: /examples/tinyos"000) and WAI + idle_wait + IRQ
  yield, vectors at -
- examples/tinyos_kernel.s: entry at 000, IRQ handler at 010 (JMP cd /home/rkujawa/repos/rk65c02 && git commit --trailer "Made-with: Cursor" -m "Add Tiny OS example: scheduler with extended physical RAM

- examples/tinyos.c: host with 64K system RAM, 3x32KB task regions above 64K
  (bus_device_add_phys), MMU translate (virtual 32KB per task), console at
  $DE00, cooperative yield ($FF00 + JMP $1000) and WAI + idle_wait + IRQ
  yield, vectors at $FFFC-$FFFF
- examples/tinyos_kernel.s: entry at $8000, IRQ handler at $8010 (JMP $1000)
- examples/tinyos_task.s: per-task loop printing task id, round-robin yield,
  optional WAI, STP after 3 runs
- Makefile: tinyos target, run-tinyos with timeout
- README.md, doc/MMU.md: document Tiny OS (64K virtual + expanded physical)
- .gitignore: /examples/tinyos"000)
- examples/tinyos_task.s: per-task loop printing task id, round-robin yield,
  optional WAI, STP after 3 runs
- Makefile: tinyos target, run-tinyos with timeout
- README.md, doc/MMU.md: document Tiny OS (64K virtual + expanded physical)
- .gitignore: /examples/tinyos

Made-with: Cursor
2026-03-09 22:11:41 +01:00

44 lines
1.1 KiB
ArmAsm

; =============================================================================
; Tiny OS — Per-task code (loaded at physical $11000, $18100, $20100)
; =============================================================================
; Assemble to tinyos_task.rom. Host loads at 0x10000+$1000 for each task.
; Virtual $1000 is mapped to the current task's physical 32KB region.
;
; Guest contract: $FF00 = yield (write next task id 0/1/2), $FF01 = current
; task id (read-only). Console at $DE00. Each task prints its id, yields
; round-robin; every other yield does WAI so host can switch via IRQ.
; =============================================================================
.org 0x1000
task_entry:
lda 0xFF01 ; current task id
clc
adc #48 ; ASCII '0'
sta 0xDE00 ; print to console
inc 0x02 ; yield parity (per-task ZP)
lda 0x02
and #1
bne coop_yield
wai ; every other yield: host switches, asserts IRQ
coop_yield:
inc 0x0200 ; run count (per-task)
lda 0x0200
cmp #3
bcs halt
lda 0xFF01 ; next task = (current + 1) % 3
clc
adc #1
cmp #3
bcc ok
lda #0
ok:
sta 0xFF00 ; yield to next task
jmp task_entry
halt:
stp