tschak909 Posted September 10, 2016 Share Posted September 10, 2016 Would something like this be useful in VCS code, or would the overhead be too much? ;------------------------------------------------------------------------------------- ;$04 - address low to jump address ;$05 - address high to jump address ;$06 - jump address low ;$07 - jump address high JumpEngine: asl ;shift bit from contents of A tay pla ;pull saved return address from stack sta $04 ;save to indirect pla sta $05 iny lda ($04),y ;load pointer from indirect sta $06 ;note that if an RTS is performed in next routine iny ;it will return to the execution before the sub lda ($04),y ;that called this routine sta $07 jmp ($06) ;jump to the address we loaded It basically allows for the following pattern: LDA OperMode JSR JumpEngine .BYTE #<DoThis, #>DoThis .BYTE #<DoThat,#>DoThat .BYTE #<AndSoOn,#>AndSoOn -Thom Quote Link to comment Share on other sites More sharing options...
Omegamatrix Posted September 10, 2016 Share Posted September 10, 2016 Try: 1) Keep your address tables separate for High and Low, so you don't waste cycles and bytes multiplying by 2. 2) Don't bother with loading indirect pointers just to load an indirect address. Instead just store all the address and index them. Actually I just talked about indirect jumps here and here with some sample code. Quote Link to comment Share on other sites More sharing options...
Nukey Shay Posted September 10, 2016 Share Posted September 10, 2016 I'm assuming that the goal was to be able to set different sets of pointers for each JSR JumpEngine encountered...the code is reading the pointers from the return addy. But in that case, the routine is still inefficient. No need to pull the address off the stack just to do an indirect read...just use the stack ram address that the return address was saved to. i.e. if you are not nesting subs, LDA($FE),Y does the same thing. However...since the data tables are directly below the JSRs, you would not be able to RTS if you wanted. Why not just use separate low and high pointer tables in two complete tables - setting the initial subgroup value for Y before you JSR? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.