Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
BRA instruction
#1
Hey,

was just playing with BR and wonder why BRA is limited to jump only $80 bytes in range? Allowing 64k address space for a display list, wouldn't it be wise to make jumps possible more than a half of page? For more sophisticated cases it is a real blocker. It would be perfect if you'd introduce two jumps - relative in 16 bits wide address space and direct JMP which additionally both don't care if the bank changes in the meantime (regardless the bank it jumps to the pointed address, which is not a problem I believe). That would give programmers more freedom. Great work anyway, cheers!
Reply
#2
The reason is quite simple: VASYL instructions are either 8- or 16-bit. There are not enough bit combinations available in this space to encode jump instruction with a wider range.

However, this can be easily worked around using DLIST2 register:

; jump to anywhere in the current bank
MOV VREG_DLIST2L, <MY_DESTINATION_ADDRESS
MOV VREG_DLIST2H, >MY_DESTINATION_ADDRESS
MOV VREG_DL2STROBE, 0
; now executing at MY_DESTINATION_ADDRESS

This will need three cycles to execute, so if timing is tight you may prefer to preload DLIST2[H/L] earlier and only execute the jump (by writing to DL2STROBE) at the right time.
Additionally, you may also switch the bank while jumping:

; jump to anywhere in any bank
MOV VREG_DLIST2L, <MY_DESTINATION_ADDRESS
MOV VREG_DLIST2H, >MY_DESTINATION_ADDRESS
MOV VREG_DL2STROBE, 8 | DESTINATION_BANK   ; bank number from 0 to 7
; now executing at MY_DESTINATION_ADDRESS in DESTINATION_BANK

Just keep in mind that when the new frame starts, the display list execution will be restarted from the address stored in DLIST register (not DLIST2!), but in the current (DESTINATION_BANK) bank. This may lead to unexpected behavior, so plan for that, by either ensuring that there is some sensible code in the current bank at that location, by adjusting DLIST content, or by reverting to the original bank before the frame ends.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)