|
| 1 | + org 32768 |
| 2 | +.core.__START_PROGRAM: |
| 3 | + di |
| 4 | + push ix |
| 5 | + push iy |
| 6 | + exx |
| 7 | + push hl |
| 8 | + exx |
| 9 | + ld hl, 0 |
| 10 | + add hl, sp |
| 11 | + ld (.core.__CALL_BACK__), hl |
| 12 | + ei |
| 13 | + jp .core.__MAIN_PROGRAM__ |
| 14 | +.core.__CALL_BACK__: |
| 15 | + DEFW 0 |
| 16 | +.core.ZXBASIC_USER_DATA: |
| 17 | + ; Defines USER DATA Length in bytes |
| 18 | +.core.ZXBASIC_USER_DATA_LEN EQU .core.ZXBASIC_USER_DATA_END - .core.ZXBASIC_USER_DATA |
| 19 | + .core.__LABEL__.ZXBASIC_USER_DATA_LEN EQU .core.ZXBASIC_USER_DATA_LEN |
| 20 | + .core.__LABEL__.ZXBASIC_USER_DATA EQU .core.ZXBASIC_USER_DATA |
| 21 | +_a: |
| 22 | + DEFB 00 |
| 23 | +.core.ZXBASIC_USER_DATA_END: |
| 24 | +.core.__MAIN_PROGRAM__: |
| 25 | + xor a |
| 26 | + ld (_a), a |
| 27 | + push hl |
| 28 | + ld hl, 5 |
| 29 | + call .core.CHECK_BREAK |
| 30 | +.LABEL._test_label: |
| 31 | + ld a, 1 |
| 32 | + ld (_a), a |
| 33 | + push hl |
| 34 | + ld hl, 7 |
| 35 | + call .core.CHECK_BREAK |
| 36 | + ld hl, 0 |
| 37 | + ld b, h |
| 38 | + ld c, l |
| 39 | +.core.__END_PROGRAM: |
| 40 | + di |
| 41 | + ld hl, (.core.__CALL_BACK__) |
| 42 | + ld sp, hl |
| 43 | + exx |
| 44 | + pop hl |
| 45 | + exx |
| 46 | + pop iy |
| 47 | + pop ix |
| 48 | + ei |
| 49 | + ret |
| 50 | + ;; --- end of user code --- |
| 51 | +#line 1 "/zxbasic/src/arch/zx48k/library-asm/break.asm" |
| 52 | +#line 1 "/zxbasic/src/arch/zx48k/library-asm/error.asm" |
| 53 | + ; Simple error control routines |
| 54 | +; vim:ts=4:et: |
| 55 | + push namespace core |
| 56 | + ERR_NR EQU 23610 ; Error code system variable |
| 57 | + ; Error code definitions (as in ZX spectrum manual) |
| 58 | +; Set error code with: |
| 59 | + ; ld a, ERROR_CODE |
| 60 | + ; ld (ERR_NR), a |
| 61 | + ERROR_Ok EQU -1 |
| 62 | + ERROR_SubscriptWrong EQU 2 |
| 63 | + ERROR_OutOfMemory EQU 3 |
| 64 | + ERROR_OutOfScreen EQU 4 |
| 65 | + ERROR_NumberTooBig EQU 5 |
| 66 | + ERROR_InvalidArg EQU 9 |
| 67 | + ERROR_IntOutOfRange EQU 10 |
| 68 | + ERROR_NonsenseInBasic EQU 11 |
| 69 | + ERROR_InvalidFileName EQU 14 |
| 70 | + ERROR_InvalidColour EQU 19 |
| 71 | + ERROR_BreakIntoProgram EQU 20 |
| 72 | + ERROR_TapeLoadingErr EQU 26 |
| 73 | + ; Raises error using RST #8 |
| 74 | +__ERROR: |
| 75 | + ld (__ERROR_CODE), a |
| 76 | + rst 8 |
| 77 | +__ERROR_CODE: |
| 78 | + nop |
| 79 | + ret |
| 80 | + ; Sets the error system variable, but keeps running. |
| 81 | + ; Usually this instruction if followed by the END intermediate instruction. |
| 82 | +__STOP: |
| 83 | + ld (ERR_NR), a |
| 84 | + ret |
| 85 | + pop namespace |
| 86 | +#line 2 "/zxbasic/src/arch/zx48k/library-asm/break.asm" |
| 87 | + ; Check if BREAK is pressed |
| 88 | + ; Return if not. Else Raises |
| 89 | + ; L BREAK Into Program Error |
| 90 | + ; HL contains the line number we want to appear in the error msg. |
| 91 | + push namespace core |
| 92 | +CHECK_BREAK: |
| 93 | + PROC |
| 94 | + LOCAL PPC, TS_BRK, NO_BREAK |
| 95 | + push af |
| 96 | + call TS_BRK |
| 97 | + jr c, NO_BREAK |
| 98 | + ld (PPC), hl ; line num |
| 99 | + ld a, ERROR_BreakIntoProgram |
| 100 | + jp __ERROR ; this stops the program and exits to BASIC |
| 101 | +NO_BREAK: |
| 102 | + pop af |
| 103 | + pop hl ; ret address |
| 104 | + ex (sp), hl ; puts it back into the stack and recovers initial HL |
| 105 | + ret |
| 106 | + PPC EQU 23621 |
| 107 | + TS_BRK EQU 8020 |
| 108 | + ENDP |
| 109 | + pop namespace |
| 110 | +#line 28 "zx48k/break_label0.bas" |
| 111 | + END |
0 commit comments