RB2INI Source Code

Diese Seite ist nicht mehr aktuell. Das HP-41CY Re-initialization Module findet man jetzt auf GitHub.

This page is not up-to-date anymore. The HP-41CY re-initialization module is now available on GitHub.

;**********************************************************************
; A ROM to re-initialize a corrupted HP-41CY.
; Written in 2019 by Jurgen Keller <jkeller@gmx.ch>
;**********************************************************************


            .TITLE  "HP-41CY Initialization"
            .JDA

;*** FAT for this example ROM *****************************************

            XROM        1           ; XROM number
            FCNS        1           ; Header + N functions
            DEFR4K      (Header)
            NOP                     ; FAT terminator
            NOP

;**** Header **********************************************************

            .NAME       "-RB2INI 1A"
(Header)    RTN

;*** RAMBOX2 Initialization *******************************************

            .FILLTO     0DFF
(RB2INI)    ?NCXQ       [CLLCDE]
            LDIS&X      02A         ; show progress (*)
            WRIT        15(e)

            ?NCXQREL    (COPYME2A)  ; copy RB2INI to page A

            LDIS&X      02F         ; show progress (/)
            WRIT        15(e)

            ?NCGO       AE30        ; transfer control to RB2INI
                                    ; in page A

            .FILLTO     0E2F
            C=0         ALL         ; activate bank #1
            ENROM1

            ?NCXQREL    (COPYOSA)   ; copy OS/A from page E to 8

            LDIS&X      101         ; show progress (a)
            WRIT        15(e)

            ?NCXQREL    (CLPG9)     ; clear page 9
            LDIS&X      039
            WRIT        15(e)

            ?NCXQREL    (CLPGB2F)   ; clear pages B to F

            ENROM1                  ; enable even pages of bank #1
            ENROM2                  ; and odd pages of bank #2

            ?NCXQREL    (COPYME29)  ; copy RB2INI to page A
            LDIS&X      02F         ; show progress (/)
            WRIT        15(e)

            ?NCGO       9E60        ; transfer control to RB2INI
                                    ; in page 9

            .FILLTO     0E5F
            ENROM2                  ; enable bank #2
            ENROM3

            ?NCXQREL    (COPYOSB)   ; copy OS/B from page F to 8

            LDIS&X      102         ; show progress (b)
            WRIT        15(e)

            ?NCXQREL    (CLPGA)     ; clear page A
            LDIS&X      001         ; show progress (A)
            WRIT        15(e)

            ?NCXQREL    (CLPGB2F)   ; clear pages B to F

            DSPOFF                  ; done
            POWOFF
            NOP

;*** Helper Routines **************************************************

            .FILLTO     0EFF

            ; copy RB2INI from page 8 to 9
(COPYME29)  C=0         ALL
(COPYL1)    RCR         11
            R=          6
            LD@R        8
            FETCHS&X
            R=          6
            LD@R        9
            WROM
            RCR         3
            C=C+1       S&X
            JNC         (COPYL1)

            C=0         ALL         ; clear I/O irq in page 9
            R=          6
            LD@R        9
(WRIOSVCV)  LD@R        F
            LD@R        F
            LD@R        8
            WROM
            RTN

            ; copy RB2INI from page 8 to A
(COPYME2A)  C=0         ALL
(COPYL2)    RCR         11
            R=          6
            LD@R        8
            FETCHS&X
            R=          6
            LD@R        A
            WROM
            RCR         3
            C=C+1       S&X
            JNC         (COPYL2)

            C=0         ALL         ; clear I/O irq in page A
            R=          6
            LD@R        A
            JNC         (WRIOSVCV)

            ; copy OS/A from page E to 8
(COPYOSA)   C=0         ALL
(COPYLA)    RCR         11
            R=          6
            LD@R        E
            FETCHS&X
            R=          6
            LD@R        8
            WROM
            RCR         3
            C=C+1       S&X
            JNC         (COPYLA)
            RTN

            ; copy OS/B from page F to 8
(COPYOSB)   C=0         ALL
(COPYLB)    RCR         11
            R=          6
            LD@R        F
            FETCHS&X
            R=          6
            LD@R        8
            WROM
            RCR         3
            C=C+1       S&X
            JNC         (COPYLB)
            RTN

            ; clear pages B to F
(CLPGB2F)   ?NCXQREL    (CLPGB)
            LDIS&X      002         ; show progress (B)
            WRIT        15(e)

            ?NCXQREL    (CLPGC)
            LDIS&X      003         ; show progress (C)
            WRIT        15(e)

            ?NCXQREL    (CLPGD)
            LDIS&X      004         ; show progress (D)
            WRIT        15(e)

            ?NCXQREL    (CLPGE)
            LDIS&X      005         ; show progress (E)
            WRIT        15(e)

            ?NCXQREL    (CLPGF)     ; show progress (F)
            LDIS&X      006
            WRIT        15(e)
            RTN

            ; routines to clear pages

(CLPG9)     C=0         ALL
            R=          3
            LD@R        9
            JNC         (CLPGX)

(CLPGA)     C=0         ALL
            R=          3
            LD@R        A
            JNC         (CLPGX)

(CLPGB)     C=0         ALL
            R=          3
            LD@R        B
            JNC         (CLPGX)

(CLPGC)     C=0         ALL
            R=          3
            LD@R        C
            JNC         (CLPGX)

(CLPGD)     C=0         ALL
            R=          3
            LD@R        D
            JNC         (CLPGX)

(CLPGE)     C=0         ALL
            R=          3
            LD@R        E
            JNC         (CLPGX)

(CLPGF)     C=0         ALL
            R=          3
            LD@R        F

(CLPGX)     RCR         11
            WROM
            RCR         3
            C=C+1       S&X
            JNC         (CLPGX)
            RTN

;*** Interrupt Handling ***********************************************

            .FILLTO     0FBF
(IOSVC)     ?NCGOREL    (RB2INI)    ; do it the easy way because
                                    ; we will never return

            .FILLTO     0FF7
(IOSVCV)    JNC         (IOSVC)