Skip to navigation


Tube: NWOSWD

[6502 Second Processor version, I/O processor]

Name: NWOSWD [Show more] Type: Subroutine Category: Tube Summary: The custom OSWORD routine Deep dive: 6502 Second Processor Tube communication
Context: See this subroutine in context in the source code References: This subroutine is called as follows: * STARTUP calls NWOSWD * OSWVECS calls via SAFE

WORDV is set to point to this routine in the STARTUP routine that runs when the I/O processor code first loads.
Arguments: A The OSWORD call to perform: * 240-255: Run the jump command in A (see OSWVECS) * All others: Call the standard OSWORD routine (Y X) The address of the associated OSWORD parameter block
Other entry points: SAFE Contains an RTS
.NWOSWD BIT svn \ If bit 7 of svn is set, jump to notours to process BMI notours \ this call with the standard OSWORD handler CMP #240 \ If A < 240, this is not a special jump command call, BCC notours \ so jump to notours to pass it to the standard OSWORD \ handler STX OSSC \ Store X in OSCC so we can retrieve it later STY OSSC+1 \ Store Y in OSCC+1 so we can retrieve it later PHA \ Store A on the stack so we can retrieve it later SBC #240 \ Set X = (A - 240) * 2 ASL A \ TAX \ so X can be used as an index into a jump table, where \ the table entries correspond to original values of A \ of 240 for entry 0, 241 for entry 1, 242 for entry 2, \ and so on LDA OSWVECS,X \ Fetch the OSWVECS jump table address pointed to by X, STA JSRV+1 \ and store it in JSRV(2 1). This modifies the address LDA OSWVECS+1,X \ of the JSR instruction at JSRV below, so it will call STA JSRV+2 \ the subroutine from the jump table LDX OSSC \ Restore the value of X we stored in OSSC, so now both \ X and Y have the values from the original OSWORD call .JSRV JSR &FFFC \ This address is overwritten by the code above to point \ to the relevant jump command from the OSWVECS jump \ table, so this instruction runs the jump command PLA \ Retrieve A from the stack LDX OSSC \ Retrieve X from OSSC LDY OSSC+1 \ Retrieve Y from OSSC+1 .SAFE RTS \ Return from the subroutine .notours JMP &FFFC \ This address is overwritten by the STARTUP routine to \ contain the original value of WORDV, so this call acts \ just like a standard JMP OSWORD call and is used to \ process OSWORD calls that aren't our custom calls