Code: Select all
PRINT USR nnnnn;"parameter data in here"
Is there a way to pass data into M/C and still use the return value? I.E.
Code: Select all
LET X = USR nnnnn + (something that's ignored)
Code: Select all
PRINT USR nnnnn;"parameter data in here"
Code: Select all
LET X = USR nnnnn + (something that's ignored)
No, the usr-call does not allow parameters
From the point of view of the syntax checker, those "parameter data" were parameters of the PRINT command, which allows an unlimited number of arguments, while USR dos not allow any. The usr-program then takes the PRINT-parameters for its own usage ....was one way. The machine-code routine would somehow fool the interpreter into ignoring the following string, so no actual print output occurred.Code: Select all
PRINT USR nnnnn;"parameter data in here"
No, that is not possible. The syntax checker will not allow entry of that line.Is there a way to pass data into M/C and still use the return value? I.E.
Code: Select all
LET X = USR nnnnn + (something that's ignored)
Code: Select all
format zx81 as 'rom'
;LISTON
// driver code for using vdrive software with ZXmaster
// usually loaded at 8192 ($2000) but relocatable code for any address
vdrive:
XOR A // entry point for command line usage (default entry point 8192)
JR .basic
XOR A // entry point for BASIC program usage (default entry point 8195)
JR .basicp
NOP // version coding of vdrive driver code (version 0)
LD A,$FE // entry point for assembly program usage (default entry point 8198)
.basicp:
INC A // coded entry point in A, 0=command line, 1=basic program, -1=assembly program
.basic:
PUSH AF // save entry point
RST $20 // read parameters
CALL $0F55 // calculate expression of parameters
LD A,($4001)
ADD A,A // check bit 6, result type, 0=string, 1=numeric
JP M,$0D9A // stop with error
JR $FE // endless loop till command is processed from ZXmaster
POP AF
RLCA // copy bit 7 into carry
LD A,($4000) // get already error code but keep flag register :-)
JR NZ,.basip // jump if basic/assembly program entry for quite output
INC A // check if error occured and get correct error code
JR NZ,.baserr
RST $08 // success message and back to BASIC
db $FF
.basip:
JR C,.mcode // jump if assembly program option
INC A // retrieve error code
LD ($4032),A // and store in SEED variable (16434)
RST $08 // return to BASIC with no error (hidden in variable)
db $FF
.mcode:
INC A // retrieve error code
LD ($4032),A // and store in SEED variable (16434)
LD A,$FF // clear system error code for continue assembly program (hidden error)
LD ($4000),A
RET // return to calling program
.baserr:
LD B,0 // just cleared as BC is used for string length while not more than 255 bytes
CALL $0AC8 // get runtime address through calling official ZX81 BASIC routine
.bascalc:
LD DE,errnodisk-.bascalc // get offset to error message
CP $07
JR Z,@f // no disk error
LD DE,errnofile-.bascalc
CP $03
JR Z,@f // no file error
LD DE,errsyntax-.bascalc // offset to syntax error (default)
@@: ADD HL,DE // calculate real address from runtime address and offset
LD C,(HL) // read length of string
INC HL
EX DE,HL // start address of string in DE, length in BC
CALL $0B6B // official print string routine from ZX81 BASIC rom
EX DE,HL // get back address to return to BASIC with error code
JP (HL) // finish
errsyntax:
.cnt: db .end-.beg // size of message
.beg:
dbzx 'SYNTAX ERROR' // message
.end:
RST $08 // return to BASIC
db $00 // BASIC error code 1
errnofile:
.cnt: db .end-.beg
.beg:
dbzx 'FILE NOT FOUND'
.end:
RST $08
db $02 // BASIC error code 3
errnodisk:
.cnt: db .end-.beg
.beg:
dbzx 'DISK NOT FOUND'
.end:
RST $08
db $06 // BASIC error code 7