From fc23a7c4a1d96b8e75e357f955a24065ff2c3783 Mon Sep 17 00:00:00 2001 From: Virgil Dupras Date: Mon, 25 Nov 2019 23:16:15 -0500 Subject: [PATCH] basic: do registers-to-vars transfer after pgm hook call --- apps/basic/README.md | 7 +++++++ apps/basic/fs.asm | 14 ++++++++++---- apps/basic/main.asm | 1 + 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/apps/basic/README.md b/apps/basic/README.md index 417a46f..50144e0 100644 --- a/apps/basic/README.md +++ b/apps/basic/README.md @@ -238,3 +238,10 @@ contents. Any line not starting with a number is ignored (not an error). is iterated to see if it finds a file with the same name. If it does, it loads its contents at `USER_CODE` (from `user.h`) and calls that address, with HL pointing to the the remaining args in the command line. + +The user code called this way follows the *usr* convention for output, that is, +it converts all registers at the end of the call and stores them in appropriate +variables. If `A` is nonzero, an error is considered to have occurred. + +It doesn't do var-to-register transfers on input, however. Only HL is passed +through (with the contents of the command line). diff --git a/apps/basic/fs.asm b/apps/basic/fs.asm index d097582..1f9502c 100644 --- a/apps/basic/fs.asm +++ b/apps/basic/fs.asm @@ -86,7 +86,6 @@ basFNEW: call rdSep ; HL now points to filename push ix \ pop de ld a, e - out (42), a jp fsAlloc ; Deletes filename with specified name @@ -114,11 +113,18 @@ basPgmHook: inc hl ; Z preserved in 16-bit inc de ; Z preserved in 16-bit jr z, .loop - ; Ready to jump. Return USER_CODE in IX and basCallCmd will take care - ; of setting (HL) to the arg string. - ld ix, USER_CODE + ; Ready to jump. Return .call in IX and basCallCmd will take care + ; of setting (HL) to the arg string. .call then takes care of wrapping + ; the USER_CODE call. + ld ix, .call cp a ; ensure Z ret +.call: + ld iy, USER_CODE + call callIY + call basR2Var + or a ; Z set only if A is zero + ret basFSCmds: .dw basFLS diff --git a/apps/basic/main.asm b/apps/basic/main.asm index 09d1771..8014b44 100644 --- a/apps/basic/main.asm +++ b/apps/basic/main.asm @@ -415,6 +415,7 @@ basUSR: ; and finally, A ld a, (VAR_TBL) call callIY +basR2Var: ; Just send reg to vars. Used in basPgmHook ; Same dance, opposite way ld (VAR_TBL), a ld (VAR_TBL+46), ix