80-Bus News

  

January–February 1984, Volume 3, Issue 1

Page 32 of 55
Dis-assembly of NASCOM ROM BASIC Ver 4.7                PAGE    71

F56B 219DF5     OUTBAD: LD      HL,BAD          ; "Bad" message
F56E CD10F2             CALL    PRS             ; Output string
F571 C3E1E3             JP      ERRIN           ; In line message

F574 C5         FILFND: PUSH    BC              ; <- Save
F575 E5                 PUSH    HL              ; <- all
F576 D5                 PUSH    DE              ; <- the
F577 F5                 PUSH    AF              ; <- registers
F578 218EF5             LD      HL,FILE         ; "File" message
F57B CD10F2             CALL    PRS             ; Output string
F57E F1                 POP     AF              ; Get file name
F57F F5                 PUSH    AF              ; And re-save
F580 CDD9FC             CALL    CONMON          ; Output file name to screen
F583 2194F5             LD      HL,FOUND        ; "Found" message
F586 CD10F2             CALL    PRS             ; Output string
F589 F1                 POP     AF              ; <- Restore
F58A D1                 POP     DE              ; <- all
F58B E1                 POP     HL              ; <- the
F58C C1                 POP     BC              ; <- registers
F58D C9                 RET

F58E 46696C65   FILE:   DEFB    "File ",0
F594 20466F75   FOUND:  DEFB    " Found",CR,LF,0
F59D 42616400   BAD:    DEFB    "Bad",0,0,0

F5A3 CD8BE9     PEEK:   CALL    DEINT           ; Get memory address
F5A6 1A                 LD      A,(DE)          ; Get byte in memory
F5A7 C301F1             JP      PASSA           ; Return integer A

F5AA CD41ED     POKE:   CALL    GETNUM          ; Get memory address
F5AD CD8BE9             CALL    DEINT           ; Get integer -32768 to 3276
F5B0 D5                 PUSH    DE              ; Save memory address
F5B1 CD90E6             CALL    CHKSYN          ; Make sure "," follows
F5B4 2C                 DEFB    ","
F5B5 CD84F4             CALL    GETINT          ; Get integer 0-255
F5B8 D1                 POP     DE              ; Restore memory address
F5B9 12                 LD      (DE),A          ; Load it into memory
F5BA C9                 RET

F5BB 2191FA     ROUND:  LD      HL,HALF         ; Add 0.5 to FPREG
F5BE CD62F8     ADDPHL: CALL    LOADFP          ; Load FP at (HL) to BCDE
F5C1 C3CDF5             JP      FPADD           ; Add BCDE to FPREG
Dis-assembly of NASCOM ROM BASIC Ver 4.7                PAGE    72

F5C4 CD62F8     SUBPHL: CALL    LOADFP          ; FPREG = -FPREG + number at HL
F5C7 21                 DEFB    (LD HL,nn)      ; Skip "POP BC" and "POP DE"
F5C8 C1         PSUB:   POP     BC              ; Get FP number from stack
F5C9 D1                 POP     DE
F5CA CD3CF8     SUBCDE: CALL    INVSGN          ; Negate FPREG
F5CD 78         FPADD:  LD      A,B             ; Get FP exponent
F5CE B7                 OR      A               ; Is number zero?
F5CF C8                 RET     Z               ; Yes - Nothing to add
F5D0 3AE710             LD      A,(FPEXP)       ; Get FPREG exponent
F5D3 B7                 OR      A               ; Is this number zero?
F5D4 CA54F8             JP      Z,FPBCDE        ; Yes - Move BCDE to FPREG
F5D7 90                 SUB     B               ; BCDE number larger?
F5D8 D2E7F5             JP      NC,NOSWAP       ; No - Don't swap them
F5DB 2F                 CPL                     ; Two's complement
F5DC 3C                 INC     A               ;  FP exponent
F5DD EB                 EX      DE,HL
F5DE CD44F8             CALL    STAKFP          ; Put FPREG on stack
F5E1 EB                 EX      DE,HL
F5E2 CD54F8             CALL    FPBCDE          ; Move BCDE to FPREG
F5E5 C1                 POP     BC              ; Restore number from stack
F5E6 D1                 POP     DE
F5E7 FE19       NOSWAP: CP      24+1            ; Second number insignificant?
F5E9 D0                 RET     NC              ; Yes - First number is result
F5EA F5                 PUSH    AF              ; Save number of bits to scale
F5EB CD79F8             CALL    SIGNS           ; Set MSBs & sign of result
F5EE 67                 LD      H,A             ; Save sign of result
F5EF F1                 POP     AF              ; Restore scaling factor
F5F0 CD92F6             CALL    SCALE           ; Scale BCDE to same exponent
F5F3 B4                 OR      H               ; Result to be positive?
F5F4 21E410             LD      HL,FPREG        ; Point to FPREG
F5F7 F20DF6             JP      P,MINCDE        ; No - Subtract FPREG from CDE
F5FA CD72F6             CALL    PLUCDE          ; Add FPREG to CDE
F5FD D253F6             JP      NC,RONDUP       ; No overflow - Round it up
F600 23                 INC     HL              ; Point to exponent
F601 34                 INC     (HL)            ; Increment it
F602 CABCE3             JP      Z,OVERR         ; Number overflowed - Error
F605 2E01               LD      L,1             ; 1 bit to shift right
F607 CDA8F6             CALL    SHRT1           ; Shift result right
F60A C353F6             JP      RONDUP          ; Round it up

F60D AF         MINCDE: XOR     A               ; Clear A and carry
F60E 90                 SUB     B               ; Negate exponent
F60F 47                 LD      B,A             ; Re-save exponent
F610 7E                 LD      A,(HL)          ; Get LSB of FPREG
F611 9B                 SBC     A, E            ; Subtract LSB of BCDE
F612 5F                 LD      E,A             ; Save LSB of BCDE
F613 23                 INC     HL
F614 7E                 LD      A,(HL)          ; Get NMSB of FPREG
F615 9A                 SBC     A,D             ; Subtract NMSB of BCDE
F616 57                 LD      D,A             ; Save NMSB of BCDE
F617 23                 INC     HL
F618 7E                 LD      A,(HL)          ; Get MSB of FPREG
F619 99                 SBC     A,C             ; Subtract MSB of BCDE
F61A 4F                 LD      C,A             ; Save MSB of BCDE
F61B DC7EF6     CONPOS: CALL    C,COMPL         ; Overflow - Make it positive

NASCOM ROM BASIC source code is available in ASM and LST file format.

Page 32 of 55