new assembler syntax
| 1 | .define Gto |
| 2 | .sect .text |
| 3 | .sect .rom |
| 4 | .sect .data |
| 5 | .sect .bss |
| 6 | .sect .text |
| 7 | |
| 8 | ! This subroutine performs the non_local goto. |
| 9 | ! The address of the descriptor is stored in zeropage locations |
| 10 | ! ADDR, ADDR+1. |
| 11 | ! Since there are two stacks (hardware_stack and the real_stack), |
| 12 | ! the stackpointer of the hard_stack is resetted by searching the |
| 13 | ! new localbase in the real_stack while adjusting the hardware_stack. |
| 14 | |
| 15 | |
| 16 | Gto: |
| 17 | stx ADDR ! address of descripto (lowbyte) |
| 18 | sta ADDR+1 ! address of descriptor (highbyte) |
| 19 | pla ! remove |
| 20 | pla ! __gto return address. |
| 21 | ldy #4 |
| 22 | lda (ADDR),y ! new localbase (lowbyte) |
| 23 | sta ARTH |
| 24 | tax |
| 25 | iny |
| 26 | lda (ADDR),y ! new localbase (highbyte) |
| 27 | sta ARTH+1 |
| 28 | cmp LB+1 |
| 29 | bne 1f |
| 30 | cpx LB |
| 31 | beq 2f ! goto within same procedure |
| 32 | 1: ldy #0 |
| 33 | lda (LB),y ! get localbase (lowbyte) |
| 34 | tax |
| 35 | iny |
| 36 | lda (LB),y ! get localbase (highbyte) |
| 37 | cmp ARTH+1 |
| 38 | bne 3f |
| 39 | cpx ARTH |
| 40 | beq 2f ! found localbase |
| 41 | 3: stx LB ! temporary save of localbase |
| 42 | sta LB+1 |
| 43 | pla ! adjust |
| 44 | pla ! hardware_stack |
| 45 | jmp 1b |
| 46 | 2: sta LB+1 ! store localbase (highbyte) |
| 47 | pha |
| 48 | stx LB ! store localbase (lowbyte) |
| 49 | sec |
| 50 | txa |
| 51 | sbc #BASE |
| 52 | sta LBl ! localbase - 240 (lowbyte) |
| 53 | pla |
| 54 | sbc #0 |
| 55 | sta LBl+1 ! localbase - 240 (highbyte) |
| 56 | ldy #3 |
| 57 | lda (ADDR),y ! new stackpointer (highbyte) |
| 58 | sta SP+1 |
| 59 | dey |
| 60 | lda (ADDR),y ! new stackpointer (lowbyte) |
| 61 | sta SP+2 |
| 62 | dey |
| 63 | lda (ADDR),y ! jump address (highbyte) |
| 64 | sta ADDR+3 |
| 65 | dey |
| 66 | lda (ADDR),y ! jump address (lowbyte) |
| 67 | sta ADDR+2 |
| 68 | jmp (ADDR+2) ! jump to address |
| 69 | |
| 70 |
Copyright © 2010 Geeknet, Inc. All rights reserved. Terms of Use