|
| 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, 00, 00, 00, 00 |
| 23 | +.core.ZXBASIC_USER_DATA_END: |
| 24 | +.core.__MAIN_PROGRAM__: |
| 25 | + ld hl, _a + 4 |
| 26 | + call .core.__FP_PUSH_REV |
| 27 | + ld a, 081h |
| 28 | + ld de, 00000h |
| 29 | + ld bc, 00000h |
| 30 | + call .core.__MODF |
| 31 | + ld hl, _a |
| 32 | + call .core.__STOREF |
| 33 | + ld hl, 0 |
| 34 | + ld b, h |
| 35 | + ld c, l |
| 36 | +.core.__END_PROGRAM: |
| 37 | + di |
| 38 | + ld hl, (.core.__CALL_BACK__) |
| 39 | + ld sp, hl |
| 40 | + exx |
| 41 | + pop hl |
| 42 | + exx |
| 43 | + pop iy |
| 44 | + pop ix |
| 45 | + ei |
| 46 | + ret |
| 47 | + ;; --- end of user code --- |
| 48 | +#line 1 "/zxbasic/src/arch/zx48k/library-asm/modf.asm" |
| 49 | +#line 1 "/zxbasic/src/arch/zx48k/library-asm/stackf.asm" |
| 50 | + ; ------------------------------------------------------------- |
| 51 | + ; Functions to manage FP-Stack of the ZX Spectrum ROM CALC |
| 52 | + ; ------------------------------------------------------------- |
| 53 | + push namespace core |
| 54 | + __FPSTACK_PUSH EQU 2AB6h ; Stores an FP number into the ROM FP stack (A, ED CB) |
| 55 | + __FPSTACK_POP EQU 2BF1h ; Pops an FP number out of the ROM FP stack (A, ED CB) |
| 56 | +__FPSTACK_PUSH2: ; Pushes Current A ED CB registers and top of the stack on (SP + 4) |
| 57 | + ; Second argument to push into the stack calculator is popped out of the stack |
| 58 | + ; Since the caller routine also receives the parameters into the top of the stack |
| 59 | + ; four bytes must be removed from SP before pop them out |
| 60 | + call __FPSTACK_PUSH ; Pushes A ED CB into the FP-STACK |
| 61 | + exx |
| 62 | + pop hl ; Caller-Caller return addr |
| 63 | + exx |
| 64 | + pop hl ; Caller return addr |
| 65 | + pop af |
| 66 | + pop de |
| 67 | + pop bc |
| 68 | + push hl ; Caller return addr |
| 69 | + exx |
| 70 | + push hl ; Caller-Caller return addr |
| 71 | + exx |
| 72 | + jp __FPSTACK_PUSH |
| 73 | +__FPSTACK_I16: ; Pushes 16 bits integer in HL into the FP ROM STACK |
| 74 | + ; This format is specified in the ZX 48K Manual |
| 75 | + ; You can push a 16 bit signed integer as |
| 76 | + ; 0 SS LL HH 0, being SS the sign and LL HH the low |
| 77 | + ; and High byte respectively |
| 78 | + ld a, h |
| 79 | + rla ; sign to Carry |
| 80 | + sbc a, a ; 0 if positive, FF if negative |
| 81 | + ld e, a |
| 82 | + ld d, l |
| 83 | + ld c, h |
| 84 | + xor a |
| 85 | + ld b, a |
| 86 | + jp __FPSTACK_PUSH |
| 87 | + pop namespace |
| 88 | +#line 2 "/zxbasic/src/arch/zx48k/library-asm/modf.asm" |
| 89 | + ; ------------------------------------------------------------- |
| 90 | + ; Floating point library using the FP ROM Calculator (ZX 48K) |
| 91 | + ; All of them uses A EDCB registers as 1st paramter. |
| 92 | + ; For binary operators, the 2n operator must be pushed into the |
| 93 | + ; stack, in the order A DE BC. |
| 94 | + ; |
| 95 | + ; Uses CALLEE convention |
| 96 | + ; ------------------------------------------------------------- |
| 97 | + push namespace core |
| 98 | +__MODF: ; MODULO |
| 99 | + call __FPSTACK_PUSH2 ; Enters B, A |
| 100 | + ; ------------- ROM DIV |
| 101 | + rst 28h |
| 102 | + defb 01h ; EXCHANGE |
| 103 | + defb 32h ; MOD |
| 104 | + defb 02h ; Discard (POP) |
| 105 | + defb 38h; ; END CALC |
| 106 | + jp __FPSTACK_POP |
| 107 | + pop namespace |
| 108 | +#line 25 "zx48k/modf.bas" |
| 109 | +#line 1 "/zxbasic/src/arch/zx48k/library-asm/pushf.asm" |
| 110 | + ; Routine to push Float pointed by HL |
| 111 | + ; Into the stack. Notice that the hl points to the last |
| 112 | + ; byte of the FP number. |
| 113 | + ; Uses H'L' B'C' and D'E' to preserve ABCDEHL registers |
| 114 | + push namespace core |
| 115 | +__FP_PUSH_REV: |
| 116 | + push hl |
| 117 | + exx |
| 118 | + pop hl |
| 119 | + pop bc ; Return Address |
| 120 | + ld d, (hl) |
| 121 | + dec hl |
| 122 | + ld e, (hl) |
| 123 | + dec hl |
| 124 | + push de |
| 125 | + ld d, (hl) |
| 126 | + dec hl |
| 127 | + ld e, (hl) |
| 128 | + dec hl |
| 129 | + push de |
| 130 | + ld d, (hl) |
| 131 | + push de |
| 132 | + push bc ; Return Address |
| 133 | + exx |
| 134 | + ret |
| 135 | + pop namespace |
| 136 | +#line 26 "zx48k/modf.bas" |
| 137 | +#line 1 "/zxbasic/src/arch/zx48k/library-asm/storef.asm" |
| 138 | + push namespace core |
| 139 | +__PISTOREF: ; Indect Stores a float (A, E, D, C, B) at location stored in memory, pointed by (IX + HL) |
| 140 | + push de |
| 141 | + ex de, hl ; DE <- HL |
| 142 | + push ix |
| 143 | + pop hl ; HL <- IX |
| 144 | + add hl, de ; HL <- IX + HL |
| 145 | + pop de |
| 146 | +__ISTOREF: ; Load address at hl, and stores A,E,D,C,B registers at that address. Modifies A' register |
| 147 | + ex af, af' |
| 148 | + ld a, (hl) |
| 149 | + inc hl |
| 150 | + ld h, (hl) |
| 151 | + ld l, a ; HL = (HL) |
| 152 | + ex af, af' |
| 153 | +__STOREF: ; Stores the given FP number in A EDCB at address HL |
| 154 | + ld (hl), a |
| 155 | + inc hl |
| 156 | + ld (hl), e |
| 157 | + inc hl |
| 158 | + ld (hl), d |
| 159 | + inc hl |
| 160 | + ld (hl), c |
| 161 | + inc hl |
| 162 | + ld (hl), b |
| 163 | + ret |
| 164 | + pop namespace |
| 165 | +#line 27 "zx48k/modf.bas" |
| 166 | + END |
0 commit comments