diff options
Diffstat (limited to 'src/tasks.asm')
| -rw-r--r-- | src/tasks.asm | 36 |
1 files changed, 12 insertions, 24 deletions
diff --git a/src/tasks.asm b/src/tasks.asm index 459ccb6..0b5276d 100644 --- a/src/tasks.asm +++ b/src/tasks.asm @@ -1,9 +1,10 @@ ; ============================================================================= -; tasks.asm - the init task demonstrates fork(). -; init forks once; the parent loops printing 'P', the child loops printing 'C'. -; Both run the same ROM text, diverging on fork()'s return value (0 in child). -; Exercises: syscall trap, fork (8 KiB bank copy + child frame), scheduler, -; and the HRAM context switch swapping cart-RAM banks per task. +; tasks.asm - the init task demonstrates fork() + exec(). +; +; init forks; the parent exec()s PROG_PING (ROM bank 2), the child exec()s +; PROG_PONG (ROM bank 3). Both program images are ORG'd at $4000, so the output +; "1212..." proves each process runs from its own ROM bank via PROC_ROMB - not +; from shared ROM0. ; ============================================================================= INCLUDE "include/gbos.inc" @@ -16,24 +17,11 @@ TaskInit:: jr z, .child .parent - ld de, .pmsg - ld b, 1 - ld c, SYS_WRITE - rst $30 - ld c, SYS_YIELD - rst $30 - jr .parent + ld b, PROG_PING + ld c, SYS_EXEC + rst $30 ; never returns .child - ld de, .cmsg - ld b, 1 - ld c, SYS_WRITE - rst $30 - ld c, SYS_YIELD - rst $30 - jr .child - -.pmsg - db "P" -.cmsg - db "C" + ld b, PROG_PONG + ld c, SYS_EXEC + rst $30 ; never returns |
