;;; -*- TI-Asm -*- ;;; TI-81 ROM dumper .org $DCC7 + 6 ;; Padding rla rla rla rla rla rla rla rla rla rla rla rla rla rla rla ;; addr = DCDC .ifdef UNKNOWN_EXEC ;; Setup for unknown execution address: determine current PC ld hl,$E1E1 set 3,h ld ($E315),hl call $E315 dumpcodeoff: ;; Patch own code xor a ld d,a ld b,a ld e,patch1 - dumpcodeoff add hl,de ld a,$76 scf rla ; A = EDh ld (hl),a add a,$10 ; A = FDh inc hl inc hl ld (hl),a inc hl inc hl xor a inc a ; A = 1 ld (hl),a ld e,static_code - patch3 add hl,de ld de,$E315 ld a,static_code_size ld c,a patch1: db $11,$b0 ; Patch #1: LDIR = ED B0 ;; Set shift2nd flag patch2: db $11,$cb ; Patch #2: SET 3,(IY+1) = FD CB 01 DE patch3: ; db $11,$de ld h,c ld l,c ; HL = 0 .else ; !UNKNOWN_EXEC ;; Setup for known execution address ;; Set shift2nd flag ld hl,patch1 scf rl (hl) inc hl inc (hl) patch1: db $7E, $E4 ; Patch #1: PUSH IY = FD E5 pop hl inc hl set 3,(hl) xor a ld h,a ld l,a ; HL = 0 .endif ;; Reserved space for hacking rla rla rla rla nextline: ;; Main ROM dumping loop ;; HL = current addr ld a,h call disphex ld a,l call disphex ld a,$83 add a,a ld d,a ; D = 6 puthexloop: ld a,(hl) inc hl call disphex dec d jr nz,puthexloop1 ;; Pause for 50 interrupt cycles ld d,50 waitloop: halt dec d jr nz,waitloop1 jr nextline ;; Reserved space for hacking rla rla rla rla .ifdef UNKNOWN_EXEC static_code: rorg $E315 .endif disphex: ld b,a rra rra rra rra call disphexl ld a,b disphexl: push de ld e,$10 dec e and e add a,low(chartbl) ld e,a ld d,high(chartbl) ld a,(de) pop de jp $8020 chartbl: db $4D,$4E,$4F,$50,$51,$52,$54,$55 db $58,$5F,$60,$61,$69,$6B,$6F,$73 .ifdef UNKNOWN_EXEC rorg $$ static_code_size equ $ - static_code .endif ;; Indirect jumps (needed because otherwise these jumps would ;; be too short to be expressible as TI-81 tokens) puthexloop1: jr puthexloop waitloop1: jr waitloop