home *** CD-ROM | disk | FTP | other *** search
/ ticalc.org / ticalc_org_rev_b.iso / archives / 86 / asm / source / dis.asm < prev    next >
Encoding:
Assembly Source File  |  2001-07-01  |  39.3 KB  |  1,566 lines

  1. ;; dis.asm -- TI-86 Z80 disassembler by Dan Eble
  2. ;; Last modified 1997-8-7
  3. ;;
  4. ;; Do absolutely anything you want with this.
  5. ;;
  6. ;; May those who rip extensive amounts for
  7. ;; exclusive personal gain be tormented
  8. ;; accordingly by a guilty conscience.
  9. ;;
  10. ;; Have a nice day.             <eble.2@osu.edu>
  11. ;;
  12.  
  13. #INCLUDE "TI86ASM.INC"
  14.  
  15. _busyOn         .equ    $4AAD
  16. _busyOff        .equ    $4AB1
  17.  
  18. FlagBitChar    .equ    0
  19. FlagMaskChar   .equ    00000001b
  20.  
  21. ;-----------------------------------------------------------------
  22. ; Temporary Data Equates
  23. ;-----------------------------------------------------------------
  24. __clrLCD        .equ    ProgramEnd+$00  ; 4-byte call
  25. __clrScrn       .equ    ProgramEnd+$04  ; 4-byte call
  26. __putmap        .equ    ProgramEnd+$08  ; 4-byte call
  27. __putc          .equ    ProgramEnd+$0C  ; 4-byte call
  28. __puts          .equ    ProgramEnd+$10  ; 4-byte call
  29. __vputmap       .equ    ProgramEnd+$14  ; 4-byte call
  30. __vputs         .equ    ProgramEnd+$18  ; 4-byte call
  31. __busyOn        .equ    ProgramEnd+$1C  ; 4-byte call
  32. __busyOff       .equ    ProgramEnd+$20  ; 4-byte call
  33. __getkey        .equ    ProgramEnd+$24  ; 4-byte call
  34. DisAddrBottom   .equ    ProgramEnd+$28  ;W:
  35. Port5Save       .equ    ProgramEnd+$2A  ;B:
  36. Port6Save       .equ    ProgramEnd+$2B  ;B:
  37. DD_FD_flags     .equ    ProgramEnd+$2C  ;B:
  38. pArg1           .equ    ProgramEnd+$2D  ;W:
  39. pArg2           .equ    ProgramEnd+$2F  ;W:
  40. pArg3           .equ    ProgramEnd+$31  ;W:
  41.  
  42. ;-----------------------------------------------------------------
  43.  
  44. .org _asm_exec_ram
  45.  
  46.         in a,(5)
  47.         ld (Port5Save),a
  48.         in a,(6)
  49.         ld (Port6Save),a
  50.  
  51.         ld a,0          ; set up font pointer for menu font
  52.         ld ($D2F0),a
  53.         ld hl,SmallFont
  54.         ld ($D2F1),hl
  55.         set 1,(IY+$23)  ; use user font!
  56.  
  57.         res 3,(iy+5)    ; display black on white
  58.         res 1,(iy+5)    ; print only six rows of each character
  59.  
  60.         call SetUpCalls
  61.  
  62.         call DisScreen
  63.  
  64. KeyLoop:
  65.         call __getkey
  66.  
  67.         cp kRight
  68.         jr nz,not_kRight
  69.         ld hl,(DisAddrTop)
  70.         inc hl
  71.         ld (DisAddrTop),hl
  72.         call DisScreen
  73.         jr KeyLoop
  74. not_kRight:
  75.         cp kLeft
  76.         jr nz,not_kLeft
  77. is_kLeft:
  78.         ld hl,(DisAddrTop)
  79.         dec hl
  80.         ld (DisAddrTop),hl
  81.         call DisScreen
  82.         jr KeyLoop
  83. not_kLeft:
  84.         cp kF2  ; page up
  85.         jr nz,not_kF2
  86.         ld de,$FFF0             ; FFF0h = -10h
  87.         ld hl,(DisAddrTop)
  88.         add hl,de
  89.         ld (DisAddrTop),hl
  90.         call DisScreen
  91.         jr KeyLoop
  92. not_kF2:
  93.         cp kF1  ; page down
  94.         jr nz,not_kF1
  95.         ld hl,(DisAddrBottom)   ; disassemble next page
  96.         ld (DisAddrTop),hl
  97.         call DisScreen
  98.         jr KeyLoop
  99. not_kF1:
  100.         cp kF3  ; toggle hex/char data display
  101.         jr nz,not_kF3
  102.         ld a,(DisFlags)
  103.         xor FlagMaskChar
  104.         ld (DisFlags),a
  105.         call DisScreen
  106.         jr KeyLoop
  107. not_kF3:
  108.         cp kDecPnt      ; goto specific address
  109.         jr nz,not_kDecPnt
  110.         call InputHex
  111.         jr nc,kF5_no_entry
  112.         ld (DisAddrTop),hl
  113. kF5_no_entry:
  114.         call DisScreen
  115.         jr KeyLoop
  116. not_kDecPnt:
  117.         cp kF4
  118.         jr nz,not_kF4
  119.         in a,(5)
  120.         ld b,a
  121.         inc a
  122.         and $0F
  123.         ld c,a
  124.         ld a,b
  125.         and $F0
  126.         or c
  127.         out (5),a
  128.         call DisScreen
  129.         jp KeyLoop
  130. not_kF4:
  131.         cp kF5  ; increment RAM page
  132.         jr nz,not_kF5
  133.         in a,(6)
  134.         ld b,a
  135.         inc a
  136.         and $07
  137.         ld c,a
  138.         ld a,b
  139.         and $F8
  140.         or c
  141.         out (6),a
  142.         call DisScreen
  143.         jp KeyLoop
  144. not_kF5:
  145.         cp kUp
  146.         jr nz,not_kUp
  147.         jp is_kLeft
  148.         jp KeyLoop
  149. not_kUp:     
  150.         cp kDown
  151.         jr nz,not_kDown
  152.         ld hl, $0000            ; put cursor in top left
  153.         ld (_penCol),hl
  154.         ld de,(DisAddrTop)      ; disassemble top line to advance DE
  155.         call DisLine
  156.         ld (DisAddrTop),de      ; store the new top line address
  157.         call ScrollUp           ; scroll screen up
  158.         ld hl, $3000            ; put cursor on bottom line, left
  159.         ld (_penCol),hl
  160.         ld de,(DisAddrBottom)   ; disassemble new bottom line to advance DE
  161.         call DisLine
  162.         ld (DisAddrBottom),de   ; store new bottom
  163.         jp KeyLoop
  164. not_kDown:
  165.         cp kExit
  166.         jp nz,KeyLoop
  167.  
  168.         ld a,(Port6Save)
  169.         out (6),a
  170.         ld a,(Port5Save)
  171.         out (5),a
  172.  
  173.         res 1,(IY+$23)  ; don't use user font anymore!
  174.         call __clrScrn
  175.         ret             ; done with program
  176.  
  177. ;-------------------------------------------------------------------
  178. ; Input a 4-digit hexadecimal value on the bottom line of the screen
  179. ; If Carry Flag is set, HL contains a useful value
  180. ;  A, BC, and DE can be modified
  181. ;-------------------------------------------------------------------
  182.  
  183. InputHex:
  184.         ld a,7
  185.         ld (_curRow),a          ; go to bottom row of screen
  186.         sub a
  187.         ld (IH_InputLen),a      ; so far no keys have been pressed
  188. IH_Loop:
  189.         call __getkey
  190.         cp kLeft                ; Left = backspace
  191.         jr z,IH_kLeft
  192.         cp kEnter               ; Enter = done
  193.         jr z,IH_kEnter
  194.         cp kClear               ; Clear = never mind
  195.         jr z,IH_kClear
  196.         sub $1C                 ; if code < $1C, it's not in table
  197.         jr c,IH_Loop            
  198.         cp $2D-$1C+1            ; if code > $2D, it's not in table
  199.         jr nc,IH_Loop
  200.  
  201.         ld hl,XlateTable
  202.         ld d,0
  203.         ld e,a
  204.         add hl,de
  205.         ld a,(hl)
  206.         or a                    ; if table[code] = 0, not valid
  207.         jr z,IH_Loop
  208.  
  209.     push af    
  210.         ld a,(IH_InputLen)
  211.         ld e,a                  ; (d = 0 from above)
  212.         ld (_curCol),a
  213.     inc a
  214.         cp 5                    ; 4 character maximum
  215.         jr nc,IH_TooLong
  216.         ld (IH_InputLen),a
  217.         ld hl,IH_InputStr
  218.         add hl,de
  219.     pop af
  220.     ld (hl),a
  221.         call __putc              ; print character
  222.         jr IH_Loop
  223. IH_TooLong:
  224.     pop af
  225.         jr IH_Loop
  226.  
  227. IH_kClear:
  228.         or a                    ; this clears CF
  229.         ret
  230.  
  231. IH_kLeft:
  232.         ld a,(IH_InputLen)
  233.         or a
  234.         jr z,IH_Loop            ; only backspace if there are chars
  235.     dec a
  236.         ld (_curCol),a
  237.         ld (IH_InputLen),a
  238.         ld a,' '
  239.         call __putc
  240.         jr IH_Loop
  241.  
  242. IH_kEnter:
  243.         ld a,(IH_InputLen)      ; enter invalid if no chars
  244.         or a
  245.         jr z,IH_Loop
  246.  
  247.         ld b,a                  ; B  = length of input
  248.         ld hl,IH_InputStr       ; HL -> input
  249.         ld de,0                 ; DE will receive value
  250. IH_ValueLoop:
  251.         ex de,hl                ; multiply DE by 16
  252.         add hl,hl
  253.         add hl,hl
  254.         add hl,hl
  255.         add hl,hl
  256.         ex de,hl
  257.         ld a,(hl)
  258.         sub '0'
  259.         cp $0A
  260.         jr c,IH_0to9
  261.         sub 'A'-'9'-1
  262. IH_0to9:
  263.         or e
  264.         ld e,a
  265.         inc hl
  266.         djnz IH_ValueLoop
  267.         ex de,hl                ; put value in hl
  268.         scf                     ; set CF (input is valid)
  269.         ret
  270.  
  271. IH_InputLen:    .db 0
  272. IH_InputStr:    .db 0,0,0,0
  273.  
  274. XlateTable:
  275. ; ASCII         ; scancode : key
  276. .db "0"         ; 1C : k0
  277. .db "1"         ; 1D : k1
  278. .db "2"         ; 1E : k2
  279. .db "3"         ; 1F : k3
  280. .db "4"         ; 20 : k4
  281. .db "5"         ; 21 : k5
  282. .db "6"         ; 22 : k6
  283. .db "7"         ; 23 : k7
  284. .db "8"         ; 24 : k8
  285. .db "9"         ; 25 : k9
  286. .db 0           ; 26 : kEE
  287. .db 0           ; 27 : kSpace
  288. .db "A"         ; 28 : kCapA
  289. .db "B"         ; 29 : kCapB
  290. .db "C"         ; 2A : kCapC
  291. .db "D"         ; 2B : kCapD
  292. .db "E"         ; 2C : kCapE
  293. .db "F"         ; 2D : kCapF
  294.  
  295. ;------------------------------------------------------
  296. ; Clear Screen and Disassemble
  297. ; input: (DisAddrTop) = Disassembly address
  298. ; modifies A, HL, BC, DE, (DisAddrBottom)
  299. ;------------------------------------------------------
  300.  
  301. DisScreen:
  302.         call __clrLCD
  303.  
  304.         call __busyOn
  305.  
  306.         ld hl,$1007             ; print ROM page
  307.         ld (_curRow),hl
  308.         in a,(5)
  309.         ld hl,ByteStr
  310.         call PrintByte
  311.         inc hl
  312.         ld a,(hl)
  313.         call __putmap
  314.  
  315.         ld hl,$1407             ; print RAM page
  316.         ld (_curRow),hl
  317.         in a,(6)
  318.         and $0F
  319.         add a,'0'
  320.         call __putmap
  321.  
  322.         sub a                   ; go to top of screen
  323.         ld (_penRow),a
  324.  
  325.         ld de,(DisAddrTop)      ; de = disassembly address
  326.  
  327.         ld b, 9                 ; dump 9 lines
  328. Line_loop:
  329.         sub a           ; go to BOL
  330.         ld (_penCol), a
  331.     push bc
  332.         call DisLine
  333.     pop bc
  334.         ld a, (_penRow) ; move down a line
  335.     add a, 6
  336.         ld (_penRow), a
  337.     djnz Line_loop
  338.         ld (DisAddrBottom),de
  339.  
  340.         call __busyOff
  341.  
  342.         ret
  343.  
  344. ;------------------------------------------------------
  345. ; Disassemble Line at cursor   DE = address
  346. ; Modifies A,BC,DE,HL
  347. ;------------------------------------------------------
  348.  
  349. DisLine:
  350.         sub a                   ; zero flags
  351.         ld (DD_FD_flags),a
  352.  
  353.         ld hl,$0000             ; zero argument pointers
  354.         ld (pArg1),hl
  355.         ld (pArg2),hl
  356.         ld (pArg3),hl
  357.  
  358.         ld hl,Normal_s8ptrs
  359.         ld (s8ptrs),hl
  360.  
  361.         ld hl,$4C48     ; "LH"
  362.         ld (HLIXStr),hl ; stores as "HL"
  363.         ld (1+_HLIX_Str),hl
  364.  
  365.         ld b,d          
  366.         ld c,e          ; BC = current address
  367.         ld hl,WordStr   
  368.         call PrintWord  ; print BC to (HL)
  369.         call __vputs     ; print (HL) to screen
  370.  
  371.         ld a, 20                ; leave some space
  372.         ld (_penCol), a
  373.  
  374. DL_Fetch:
  375.         call FetchByte          ; fetch and print byte
  376.  
  377.         cp $DD
  378.         jr nz,Not_DD
  379.         ld hl,DD_FD_flags
  380.         set 0,(hl)      ; set DD flag
  381.         ld a,'X'        ; store X's to relevant strings
  382.         ld hl,$5849     ; "XI" stores as "IX"
  383. DL_Store_XY:
  384.         ld (HLIXStr),hl
  385.         ld (1+_HLIX_Str),hl
  386.         ld (IndexStr+2),a
  387.         ld (1+IXStr),a
  388.         ld (XHStr),a
  389.         ld (XLStr),a
  390.         jr DL_Fetch
  391. Not_DD:
  392.         cp $FD
  393.         jr nz,Not_FD
  394.         ld hl,DD_FD_flags
  395.         set 1,(hl)      ; set FD flag
  396.         ld a,'Y'        ; store Y's to relevant strings
  397.         ld hl,$5949     ; "YI" stores as "IY"
  398.         jr DL_Store_XY
  399. Not_FD:
  400.         cp $CB
  401.         jr nz,Not_CB
  402.         call Decode_CB_Inst
  403.         call PrintInst
  404.         ret
  405. Not_CB:
  406.         cp $ED
  407.         jr nz,Not_ED
  408.         call Decode_ED_Inst
  409.         call PrintInst
  410.         ret
  411. Not_ED:
  412.         call Decode_Inst
  413.         call PrintInst
  414.     ret
  415.  
  416. ;------------------------------------------------------
  417. ; Decode Instructions without CB or ED Prefixes
  418. ;------------------------------------------------------
  419. Decode_Inst:
  420.         push af
  421.         ld a,(DD_FD_flags)
  422.         or a
  423.         jr z,No_DD_FD_Flags
  424.         ld hl,Index_s8ptrs
  425.         ld (s8ptrs),hl
  426.  
  427. No_DD_FD_Flags:
  428.         pop af
  429.  
  430.         cp $40          ; if >= 40h
  431.         jp nc,GE_40     ; goto GE_40
  432.  
  433.         bit 2,a
  434.         jp nz,DI_Misc8bit
  435.  
  436.         bit 0,a
  437.         jp nz,DI_Misc16bit
  438.  
  439.         bit 1,a
  440.         jr nz,DI_MiscLD
  441.  
  442.         bit 5,a
  443.         jr nz,DI_JRc
  444.  
  445.         bit 4,a
  446.         jr nz,DI_DJNZ_JR
  447.  
  448.         or a
  449.         jr nz,DI_N_NOP
  450.         ld hl,nopStr    ; mnemonic = NOP
  451.         ret
  452. DI_N_NOP:               ; the only thing left is EX
  453.         ld hl,AFStr
  454.         ld (pArg1),hl
  455.         ld hl,AFpStr
  456.         ld (pArg2),hl
  457.         ld hl,exStr
  458.         ret             ; mnemonic = EX
  459.  
  460. DI_DJNZ_JR:
  461.         ld hl,djnzStr
  462.         bit 3,a
  463.         jr z,DI_is_DJNZ
  464.         ld hl,jrStr
  465. DI_is_DJNZ:
  466.         push hl         ; save mnemonic
  467.         call FetchRelAddr
  468.         ld (pArg1),hl   ; get relative address
  469.         pop hl          ; restore mnemonic
  470.         ret
  471.  
  472. DI_JRc:
  473.         ld h,00011000b  ; bits 4-3 : condition
  474.         ld bc,condptrs
  475.         call LD_HL_From_Table
  476.         ld (pArg1),hl
  477.         call FetchRelAddr       ; get relative address
  478.         ld (pArg2),hl
  479.         ld hl,jrStr     ; mnemonic = JR
  480.         ret
  481.  
  482. DI_MiscLD:
  483.         bit 5,a
  484.         jr nz,DI_LD_A16
  485.  
  486.         ld hl,_BC_Str
  487.         bit 4,a
  488.         jr z,DI_MiscLD_BC
  489.         ld hl,_DE_Str
  490. DI_MiscLD_BC:
  491.         ld (pArg1),hl
  492.         ld hl,AStr
  493.         ld (pArg2),hl
  494. DI_MiscLD_ToSwap:
  495.         bit 3,a
  496.         jr z,DI_MiscLD_NoSwap
  497.         call SwapArg1Arg2
  498. DI_MiscLD_NoSwap:
  499.         ld hl,ldStr     ; mnemonic = LD
  500.         ret
  501.  
  502. DI_LD_A16:
  503.         push af
  504.         call FetchAbsAddr       ; fetch (XXXXh)
  505.         ld (pArg1),hl
  506.         pop af
  507.  
  508.         ld hl,HLIXStr
  509.         bit 4,a
  510.         jr z,DI_LD_A16_HL
  511.         ld hl,AStr
  512. DI_LD_A16_HL:
  513.         ld (pArg2),hl
  514.         jr DI_MiscLD_ToSwap
  515.  
  516. DI_Misc16bit:
  517.         ld h,00110000b  ; bits 5-4 : dest register
  518.         ld bc,s16ptrs   ; bc -> string pointer table
  519.         call LD_HL_From_Table
  520.         ld (pArg1),hl
  521.  
  522.         bit 1,a
  523.         jr nz,DI_INCDEC16
  524.  
  525.         bit 3,a
  526.         jr z,DI_LDimm16
  527.  
  528.         ld a,$02        ; force this to recall either HL,IX,or IY
  529.         ld h,$03
  530.         ld bc,s16ptrs
  531.         call LD_HL_From_Table
  532.         ld (pArg2),hl
  533.         call SwapArg1Arg2
  534.         ld hl,addStr    ; mnemonic = ADD
  535.         ret
  536.  
  537. DI_LDimm16:
  538.         call FetchImm16
  539.         ld (pArg2),hl
  540.         ld hl,ldStr     ; mnemonic = LD
  541.         ret
  542.  
  543. DI_INCDEC16:
  544.         ld hl,incStr
  545.         bit 3,a
  546.         ret z
  547.         ld hl,decStr
  548.         ret
  549.  
  550. DI_Misc8bit:    ; INC,DEC,LD,RxCA,RxA,DAA,CPL
  551.         ld h,00111000b  ; bits 5-3 = register
  552.         ld bc,(s8ptrs)
  553.         call LD_HL_From_Table
  554.         ld (pArg1),hl
  555.  
  556.         bit 1,a
  557.         jr z,DI_INCDEC8
  558.  
  559.         bit 0,a
  560.         jr z,DI_LDimm8
  561.  
  562.         ld hl,$0000     ; don't need arg1 anymore
  563.         ld (pArg1),hl
  564.  
  565.         bit 5,a
  566.         jr z,DI_Rotate
  567.  
  568.         ld h,00011000b          ; bits 4-3 : mnemonic index
  569.         ld bc,op001xx111ptrs    ; -> mnemonic pointer table
  570.         call LD_HL_From_Table
  571.         ret
  572.  
  573. DI_LDimm8:
  574.         call FIA_If_Needed      ; fetch index byte, if needed
  575.         call FetchByte  ; get and print byte
  576.         ld hl,imm8Str
  577.         call PrintByte  ; stuff byte in buffer
  578.         ld (pArg2),hl
  579.         ld hl,ldStr     ; mnemonic = LD
  580.         ret
  581.         
  582. DI_Rotate:
  583.         ld h,00011000b  ; mask index to mnemonic table
  584.         ld bc,rotptrs
  585.         call LD_HL_From_Table
  586.         ret
  587. DI_INCDEC8:
  588.         call FIA_If_Needed      ; fetch index byte, if needed
  589.         ld hl,incStr
  590.         bit 0,a
  591.         ret z
  592.         ld hl,decStr
  593.         ret
  594. GE_40:
  595.         cp $80          ; if >= 80h
  596.         jr nc,GE_80     ; goto GE_80
  597.  
  598.         cp $76          ; exception to the rule is HALT
  599.         jr nz,Not_76
  600.         ld hl,haltStr   ; mnemonic = "HALT"
  601.         ret
  602.  
  603. Not_76: ; load instruction
  604.  
  605.         ld bc,(s8ptrs)          ; string pointer table for LD operands
  606.         ld h,00111000b          ; bits 5-3 of A specify table offset
  607.         call LD_HL_From_Table   ; HL = table value
  608.         ld (pArg1),hl
  609.         call FIA_If_Needed      ; fetch index byte, if needed
  610.         
  611.  
  612.         ld bc,(s8ptrs)          ; string pointer table for LD operands
  613.         ld h,00000111b          ; bits 2-0 of A specify table offset
  614.         call LD_HL_From_Table   ; HL = table value
  615.         ld (pArg2),hl
  616.         call FIA_If_Needed      ; fetch index byte, if needed
  617.  
  618.         ld hl,ldStr     ; mnemonic = "LD"
  619.         ret
  620. GE_80:
  621.         cp $C0          ; if >= C0h
  622.         jr nc,GE_C0     ; goto GE_C0
  623.  
  624.         ld hl,AStr      ; arg1 is "A"
  625.         ld (pArg1),hl
  626.  
  627.         ld bc,(s8ptrs)          ; string pointer table for operands
  628.         ld h,00000111b          ; bits 2-0 of A specify table offset
  629.         call LD_HL_From_Table   ; HL = table value
  630.         ld (pArg2),hl
  631.         call FIA_If_Needed      ; fetch index byte, if needed
  632.  
  633.         ld bc,op80_BFptrs       ; string pointer table for mnemonics
  634.         ld h,00111000b          ; bits 5-3 of A specify table offset
  635.         call LD_HL_From_Table   ; HL = table value
  636.  
  637.         ret
  638. GE_C0:
  639.         bit 0,a
  640.         jr nz,GE_C0_ODD
  641.  
  642.         push af
  643.         and $06
  644.         cp 6
  645.         jr z,GE_C0_IMM8
  646.         pop af
  647.  
  648.         ld h,00111000b  ; bits 5-3 = condition
  649.         ld bc,condptrs  ; table of string pointers
  650.         call LD_HL_From_Table
  651.         ld (pArg1),hl
  652.  
  653.         ld h,00000110b  ; bits 2-1 = mnemonic
  654.         ld bc,opC0_evenptrs     ; table of mnemonic pointers
  655.         call LD_HL_From_Table   ; HL = pointer to mnemonic string
  656.  
  657.         push hl
  658.         and $06
  659.         jr z,GE_C0_RETc ; RETc doesn't use imm16, JPc and CALLc do
  660.         call FetchImm16
  661.         ld (pArg2),hl   ; pArg2->buffer
  662. GE_C0_RETc:
  663.         pop hl
  664.         ret
  665.  
  666. GE_C0_IMM8:
  667.         pop af
  668.         ld hl,AStr      ; arg1 = "A"
  669.         ld (pArg1),hl
  670.  
  671.         ld h,00111000b          ; bits 5-3 = mnemonic
  672.         ld bc,op80_BFptrs       ; BC -> mnemonic pointer table
  673.         call LD_HL_From_Table
  674.         
  675.         push hl
  676.         call FetchByte  ; fetch a byte and print it
  677.         ld hl,imm8Str
  678.         call PrintByte ; stuff it in buffer
  679.         ld (pArg2),hl   ; pArg2 -> buffer
  680.         pop hl
  681.         ret
  682.  
  683. GE_C0_ODD:
  684.         push af
  685.         and $0A
  686.         jr nz,GE_C0_N_Stack
  687.         pop af
  688.  
  689.         ld h,00110000b          ; bits 5-4 = register
  690.         ld bc,stack_s16ptrs     ; bc -> string pointer table
  691.         call LD_HL_From_Table
  692.         ld (pArg1),hl
  693.  
  694.         ld hl,popStr
  695.         and $04
  696.         jr z,GE_C0_NotPush
  697.         ld hl,pushStr
  698. GE_C0_NotPush:
  699.         ret
  700.  
  701. GE_C0_N_Stack:
  702.         pop af
  703.         push af
  704.         and $07
  705.         cp $07
  706.         jr nz, GE_C0_N_RST
  707.  
  708.         pop af
  709.         and $38         ; prepare argument
  710.         ld hl,imm8Str
  711.         ld (pArg1),hl
  712.         call PrintByte
  713.         ld hl,rstStr    ; mnemonic = RST
  714.         ret
  715.  
  716. GE_C0_N_RST:
  717.         pop af
  718.  
  719.         cp $C3          ; JP i16
  720.         jr nz,GE_C0_N_JP_i16
  721.         call FetchImm16
  722.         ld (pArg1),hl   ; pArg1->buffer
  723.         ld hl,jpStr        
  724.         ret
  725.  
  726. GE_C0_N_JP_i16:
  727.         cp $C9
  728.         jr nz,GE_C0_N_RET
  729.         ld hl,retStr
  730.         ret
  731. GE_C0_N_RET:
  732.         cp $D9
  733.         jr nz,GE_C0_N_EXX
  734.         ld hl,exxStr
  735.         ret
  736. GE_C0_N_EXX:
  737.         cp $E9
  738.         jr nz,GE_C0_N_JPHL
  739.         ld hl,_HLIX_Str
  740.         ld (pArg1),hl
  741.         ld hl,jpStr
  742.         ret
  743. GE_C0_N_JPHL:
  744.         cp $F9
  745.         jr nz,GE_C0_N_LDSPHL
  746.         ld hl,SPStr
  747.         ld (pArg1),hl
  748.         ld hl,HLIXStr
  749.         ld (pArg2),hl
  750.         ld hl,ldStr
  751.         ret
  752. GE_C0_N_LDSPHL:
  753.         cp $CD
  754.         jr nz,GE_C0_N_CALL_i16
  755.         call FetchImm16
  756.         ld (pArg1),hl   ; pArg1->buffer
  757.         ld hl,callStr
  758.         ret
  759.  
  760. GE_C0_N_CALL_i16:
  761.         cp $F3
  762.         jr nz,GE_C0_N_DI
  763.         ld hl,diStr
  764.         ret
  765. GE_C0_N_DI:
  766.         cp $FB
  767.         jr nz,GE_C0_N_EI
  768.         ld hl,eiStr
  769.         ret
  770. GE_C0_N_EI:
  771.         cp $E3
  772.         jr nz,GE_C0_N_EXSPHL
  773.         ld hl,_SP_Str
  774.         ld (pArg1),hl
  775.         ld hl,HLIXStr
  776.         ld (pArg2),hl
  777.         ld hl,exStr
  778.         ret
  779. GE_C0_N_EXSPHL:
  780.         cp $EB
  781.         jr nz,GE_C0_N_EXDEHL
  782.         ld hl,DEStr
  783.         ld (pArg1),hl
  784.         ld hl,HLStr
  785.         ld (pArg2),hl
  786.         ld hl,exStr
  787.         ret
  788. GE_C0_N_EXDEHL:
  789.         cp $D3
  790.         jr nz,GE_C0_N_OUTnA
  791.         call FetchPort
  792.         ld (pArg1),hl
  793.         ld hl,AStr
  794.         ld (pArg2),hl
  795.         ld hl,outStr
  796.         ret
  797. GE_C0_N_OUTnA:
  798.         ld hl,AStr
  799.         ld (pArg1),hl
  800.         call FetchPort
  801.         ld (pArg2),hl
  802.         ld hl,inStr
  803.         ret
  804.  
  805. ;------------------------------------------------------
  806. ; Decode Instructions with CB Prefixes
  807. ;------------------------------------------------------
  808. Decode_CB_Inst:
  809.         ld a,(DD_FD_flags)
  810.         and $FF
  811.         jr z,DCB_NoIndex1
  812.         call FetchIndAddr
  813.  
  814. DCB_NoIndex1:
  815.  
  816.         call FetchByte  ; fetch and print a byte
  817.  
  818.         cp $40          ; if >= 40h
  819.         jr nc,DCB_GE_40 ; goto DCB_GE_40
  820.  
  821.         ld bc,Normal_s8ptrs     ; string pointer table for operands
  822.         ld h,00000111b          ; bits 2-0 of A specify table offset
  823.         call LD_HL_From_Table   ; HL = table value
  824.         ld (pArg1),hl
  825.  
  826.         push af                 ; arg2 is (IX+nn), if required
  827.         ld a,(DD_FD_flags)
  828.         and $FF
  829.         jr z,DCB_NoIndex2
  830.         ld hl,IndexStr
  831.         ld (pArg2),hl
  832.         pop af
  833.         push af                 ; restore a
  834.         and $07
  835.         cp $06                  ; if arg2 is (hl), replace it with
  836.         jr nz,DCB_NotHL         ; (IX+nn) and make arg2 null
  837.         ld hl,$0000
  838.         ld (pArg1),hl
  839.         call SwapArg1Arg2
  840. DCB_NotHL:
  841. DCB_NoIndex2:
  842.         pop af
  843.  
  844.         ld bc,opCB00_3Fptrs     ; string pointer table RLC, etc
  845.         ld h,00111000b          ; bits 5-3 of A specify table offset
  846.         call LD_HL_From_Table   ; HL = table value
  847.  
  848.         ret
  849.  
  850. DCB_GE_40:
  851.         push af                 ; set up arg1
  852.         rrca
  853.         rrca
  854.         rrca
  855.         and $07
  856.         add a,'0'
  857.         ld hl,ByteStr
  858.         ld (pArg1),hl
  859.         ld (hl),a
  860.         inc hl
  861.         sub a
  862.         ld (hl),a
  863.         pop af
  864.  
  865.         ld bc,Normal_s8ptrs     ; string pointer table for operands
  866.         ld h,00000111b          ; bits 2-0 of A specify table offset
  867.         call LD_HL_From_Table   ; HL = table value
  868.         ld (pArg2),hl
  869.  
  870.         push af                 ; arg3 is (IX+nn), if required
  871.         ld a,(DD_FD_flags)
  872.         and $FF
  873.         jr z,DCB_NoIndex3
  874.         ld hl,IndexStr
  875.         ld (pArg3),hl
  876.         pop af
  877.         push af                 ; restore a
  878.         cp $80
  879.         jr c,DCB_ReplaceArg2    ; if A < $80, mnemonic is BIT
  880.         and $07
  881.         cp $06                  ; if arg2 is (hl), replace it with
  882.         jr nz,DCB_NotHL2        ; (IX+nn) and make arg3 null
  883. DCB_ReplaceArg2:
  884.         ld hl,(pArg3)
  885.         ld (pArg2),hl
  886.         ld hl,$0000
  887.         ld (pArg3),hl
  888. DCB_NotHL2:
  889. DCB_NoIndex3:
  890.         pop af
  891.  
  892.         ld bc,opCB40_FFptrs     ; address of mnemonic table
  893.         ld h,11000000b          ; bits 7-6 are index into mnemonic table
  894.         call LD_HL_From_Table
  895.  
  896.         ret
  897.  
  898. ;------------------------------------------------------
  899. ; Decode Instructions with ED Prefixes
  900. ;------------------------------------------------------
  901. Decode_ED_Inst:
  902.         ld a,(DD_FD_flags)
  903.         and $FF
  904.         jr z,DED_NoIndex        ; DD and FD not allowed w/ED
  905.  
  906.         ld hl,QuestionStr
  907.         ret
  908.  
  909. DED_NoIndex:
  910.  
  911.         call FetchByte  ; fetch and print a byte
  912.  
  913.         cp $40          ; if >= 40h
  914.         jr nc,DED_GE_40 ; goto DED_GE_40
  915.  
  916. DED_NOP:
  917.         ld hl,nopStr
  918.         ret
  919.  
  920. DED_GE_40:
  921.         cp $80          ; if >= 80h, 
  922.         jr nc,DED_GE_80 ; goto DED_GE_80
  923.  
  924.         ld bc,DED_JumpPtrs      ; bc -> jump table
  925.         ld h,00000111b          ; bits 2-0 hold index into table
  926.         call LD_HL_From_Table
  927.         jp (hl)
  928.  
  929. ;; Embedded Data: Jump pointers
  930. DED_JumpPtrs:   .dw DED_JP_0,DED_JP_1,DED_JP_2,DED_JP_3
  931.                 .dw DED_JP_4,DED_JP_5,DED_JP_6,DED_JP_7
  932.  
  933. DED_GE_80:
  934.  
  935.         cp $A0          ; if < A0h,
  936.         jr c,DED_NOP    ; goto DED_NOP
  937.         cp $C0          ; if >= C0h, 
  938.         jr nc,DED_NOP   ; goto DED_NOP
  939.         bit 2,a
  940.         jr nz,DED_NOP
  941.  
  942.         ld h,00011011b          ; significant bits
  943.         ld bc,opEDA0_BFptrs     ; -> opcode table
  944.         call LD_HL_From_Table   ; load string pointer
  945.  
  946.         ret
  947.  
  948. DED_JP_0:
  949.         ld bc,inCptrs           ; string pointer table for operand
  950.         ld h,00111000b          ; bits 5-3 of A specify table offset
  951.         call LD_HL_From_Table   ; HL = table value
  952.         ld (pArg1),hl
  953.  
  954.         ld hl,PortCStr
  955.         ld (pArg2),hl
  956.  
  957.         ld hl,inStr
  958.         ret
  959.  
  960. DED_JP_1:
  961.         ld hl,PortCStr
  962.         ld (pArg1),hl
  963.  
  964.         ld bc,outCptrs          ; string pointer table for operand
  965.         ld h,00111000b          ; bits 5-3 of A specify table offset
  966.         call LD_HL_From_Table   ; HL = table value
  967.         ld (pArg2),hl
  968.  
  969.         ld hl,outStr
  970.         ret
  971.  
  972. DED_JP_2:
  973.         ld hl,HLStr
  974.         ld (pArg1),hl
  975.  
  976.         ld bc,s16ptrs           ; string pointer table for operand
  977.         ld h,00110000b          ; bits 5-4 of A specify table offset
  978.         call LD_HL_From_Table   ; HL = table value
  979.         ld (pArg2),hl
  980.  
  981.         ld hl,sbcStr
  982.         bit 3,a
  983.         ret z
  984.         ld hl,adcStr
  985.         ret
  986.  
  987. DED_JP_3:
  988.         push af
  989.         call FetchAbsAddr       ; fetch (XXXXh)
  990.         ld (pArg1),hl
  991.         pop af
  992.  
  993.         ld bc,s16ptrs           ; string pointer table for operand
  994.         ld h,00110000b          ; bits 5-4 of A specify table offset
  995.         call LD_HL_From_Table   ; HL = table value
  996.         ld (pArg2),hl
  997.  
  998.         bit 3,a
  999.         jr z,DED_JP_3_NoSwap
  1000.         call SwapArg1Arg2
  1001. DED_JP_3_NoSwap:
  1002.         ld hl,ldStr
  1003.         ret
  1004.  
  1005. DED_JP_4:
  1006.         ld hl,negStr
  1007.         ret
  1008.  
  1009. DED_JP_5:
  1010.         ld hl,retnStr
  1011.         bit 3,a
  1012.         ret z
  1013.         ld hl,retiStr
  1014.         ret
  1015.  
  1016. DED_JP_6:
  1017.         ld bc,imptrs            ; string pointer table for operand
  1018.         ld h,00011000b          ; bits 4-3 of A specify table offset
  1019.         call LD_HL_From_Table   ; HL = table value
  1020.         ld (pArg1),hl
  1021.         ld hl,imStr
  1022.         ret
  1023.  
  1024. DED_JP_7:
  1025.         bit 5,a
  1026.         jr z,DED_JP_7_LD
  1027.  
  1028.         bit 4,a
  1029.         jr nz,DED_JP_7_NOP
  1030.  
  1031.         ld hl,rrdStr
  1032.         bit 3,a
  1033.         jr z,DED_JP_7_RRD
  1034.         ld hl,rldStr
  1035. DED_JP_7_RRD:
  1036.         ret
  1037.  
  1038. DED_JP_7_NOP:
  1039.         ld hl,nopStr
  1040.         ret
  1041.  
  1042. DED_JP_7_LD:    ; LD I,A ; LD A,I ; LD R,A ; LD A,R
  1043.         ld hl,IStr
  1044.         bit 3,a
  1045.         jr z,DED_JP_7_LD_I
  1046.         ld hl,RStr
  1047. DED_JP_7_LD_I:
  1048.         ld (pArg1),hl
  1049.         ld hl,AStr
  1050.         ld (pArg2),hl
  1051.         bit 4,a
  1052.         jr z,DED_JP_7_LD_N
  1053.         call SwapArg1Arg2
  1054. DED_JP_7_LD_N:  ; No Swap
  1055.         ld hl,ldStr     ; mnemonic = LD
  1056.         ret
  1057.  
  1058. ;------------------------------------------------------
  1059. ; Print Instruction and operands on current line
  1060. ;  input: HL->mnemonic string
  1061. ;         pArg1->argument 1 string (null if <1 arg)
  1062. ;         pArg2->argument 2 string (null if <2 args)
  1063. ;         pArg3->argument 3 string (null if <3 args)
  1064. ;------------------------------------------------------
  1065. PrintInst:
  1066.         push af
  1067.         push de
  1068.  
  1069.         ld a, 56        ; leave a large gap
  1070.         ld (_penCol), a
  1071.         call __vputs     ; print mnemonic
  1072.         ld hl,(pArg1)   ; see if there is one argument
  1073.         sub a
  1074.         or h
  1075.         or l
  1076.         jr z,PI_Done
  1077.         ld a, 75        ; leave a small gap
  1078.         ld (_penCol), a
  1079.         call __vputs     ; print arg1
  1080.         ld hl,(pArg2)   ; see if there are two arguments
  1081.         sub a
  1082.         or h
  1083.         or l
  1084.         jr z,PI_Done
  1085.         ld a,','        ; print a comma
  1086.         call __vputmap
  1087.         call __vputs     ; print arg2
  1088.         ld hl,(pArg3)   ; see if there are three arguments
  1089.         sub a
  1090.         or h
  1091.         or l
  1092.         jr z,PI_Done
  1093.         ld a,','        ; print a comma
  1094.         call __vputmap
  1095.         call __vputs     ; print arg3
  1096. PI_Done:
  1097.         pop de
  1098.         pop af
  1099.         ret
  1100.  
  1101. ;------------------------------------------------------
  1102. ; Fetch Byte and print it at current cursor location
  1103. ;------------------------------------------------------
  1104. FetchByte:
  1105.         ld a,(de)               ; fetch a byte
  1106.         inc de
  1107.  
  1108.         push af
  1109.         ld hl,DisFlags
  1110.         bit FlagBitChar,(hl)    ; hex/char
  1111.         jr nz,FB_Char
  1112.         ld hl,ByteStr           ; print the byte
  1113.         call PrintByte
  1114.         call __vputs
  1115.         pop af
  1116.         ret
  1117. FB_Char:
  1118.     dec a        ; 0 -> FF
  1119.         cp $D5          ; if char < D5, print character
  1120.     inc a        ; "inc" does not affect the carry flag
  1121.         jr c, FB_Char_GoAhead
  1122.     ld a, $D0    ; else print a square instead
  1123. FB_Char_GoAhead:
  1124.         push de
  1125.         call __vputmap
  1126.         pop de
  1127.         pop af
  1128.         ret
  1129.  
  1130. ;------------------------------------------------------
  1131. ; Fetch Word into BC, print bytes at cursor
  1132. ;------------------------------------------------------
  1133. FetchWord:
  1134.         call FetchByte
  1135.         ld c,a
  1136.         call FetchByte
  1137.         ld b,a
  1138.         ret
  1139.  
  1140. ;------------------------------------------------------
  1141. ; Fetch port (nn) print byte at cursor
  1142. ;   A becomes port number, HL->PortStrSm or PortStrLg
  1143. ;------------------------------------------------------
  1144. FetchPort:
  1145.         call FetchByte  ; fetch a byte and print it
  1146.         cp 10           ; if port >= 10, use large string
  1147.         jr nc, FP_LargeString
  1148.         ld hl,PortStrSm+1       ; else use small string
  1149.         add a,'0'
  1150.         ld (hl),a
  1151.         dec hl
  1152.         ret
  1153. FP_LargeString:
  1154.         ld hl,PortStrLg+1
  1155.         call PrintByte
  1156.         dec hl
  1157.         ret
  1158.  
  1159. ;------------------------------------------------------
  1160. ; Call FetchIndAddr if HL -> IndexStr
  1161. ;  BC and HL are changed
  1162. ;------------------------------------------------------
  1163. FIA_If_Needed:
  1164.         push af
  1165.         ld bc,IndexStr
  1166.         or a                    ; clear carry flag
  1167.         sbc hl,bc               ; compare hl to IndexStr
  1168.         call z,FetchIndAddr     ; if necessary, get index byte
  1169.         pop af
  1170.         ret
  1171.  
  1172. ;------------------------------------------------------
  1173. ; Fetch (IX+nn) index, print it to important places
  1174. ;------------------------------------------------------
  1175. FetchIndAddr:
  1176.         call FetchByte  ; fetch and print to screen
  1177.         ld hl,IndexStr+4
  1178.         call PrintByte ; print to IndexStr
  1179.         ret
  1180.  
  1181. ;------------------------------------------------------
  1182. ; Fetch (XXXXh) address for loads, stores, etc
  1183. ;   A is destroyed. HL->AddrStr, which holds "(XXXXh)"
  1184. ;------------------------------------------------------
  1185. FetchAbsAddr:
  1186.         call FetchWord  ; fetch word into BC
  1187.         ld hl,AddrStr+1
  1188.         call PrintWord  ; print BC into (HL)
  1189.         dec hl
  1190.         ret
  1191.  
  1192. ;------------------------------------------------------
  1193. ; Fetch XXXXh address for relative jumps
  1194. ;   A is destroyed. HL->imm16Str, which holds "XXXXh"
  1195. ;------------------------------------------------------
  1196. FetchRelAddr:
  1197.         call FetchByte  ; get and display byte
  1198.         ld l,a
  1199.         rlca            ; if sign bit of A is set
  1200.         sbc a,a         ; set all bits in A
  1201.         ld h,a          ; now HL = sign-extended A
  1202.         add hl,de       ; add current memory location
  1203.         ld b,h          
  1204.         ld c,l          ; BC = address
  1205.         jr FI16_PrintI16        ; see FetchImm16
  1206.  
  1207. ;------------------------------------------------------
  1208. ; Fetch XXXXh address for absolute jumps, loads, etc.
  1209. ;   A is destroyed. HL->imm16Str, which holds "XXXXh"
  1210. ;------------------------------------------------------
  1211. FetchImm16:
  1212.         call FetchWord  ; fetch word into BC
  1213. FI16_PrintI16:
  1214.         ld hl,imm16Str
  1215.         call PrintWord  ; print BC into (HL)
  1216.         ret
  1217.  
  1218. ;------------------------------------------------------
  1219. ; Swap pArg1 and pArg2 ; HL is destroyed
  1220. ;------------------------------------------------------
  1221. SwapArg1Arg2:
  1222.         ld hl,(pArg1)
  1223.         push hl
  1224.         ld hl,(pArg2)
  1225.         ld (pArg1),hl
  1226.         pop hl
  1227.         ld (pArg2),hl
  1228.         ret
  1229.  
  1230. ;------------------------------------------------------
  1231. ; Scroll Screen Down
  1232. ;------------------------------------------------------
  1233. ScrollDown:
  1234.         ld hl, 8*16*6+$FBFF     ; move from second-to-bottom line
  1235.         ld de, 9*16*6+$FBFF     ; move to bottom line
  1236.         ld bc, 8*16*6           ; move 8 lines
  1237.         lddr                    ; move!
  1238.         ld hl, 0*16*6+$FC00     ; clear top line
  1239.         jr ScrollCommon
  1240.  
  1241. ;------------------------------------------------------
  1242. ; Scroll Screen Up
  1243. ;------------------------------------------------------
  1244. ScrollUp:
  1245.         ld hl, 1*16*6+$FC00     ; move from one line down
  1246.         ld de, 0*16*6+$FC00     ; move to top line
  1247.         ld bc, 8*16*6           ; move 8 lines
  1248.         ldir                    ; move!
  1249.         ld hl, 8*16*6+$FC00     ; clear bottom line
  1250. ScrollCommon:
  1251.         ld d,h
  1252.         ld e,l
  1253.         inc de
  1254.         ld bc, 16*6
  1255.         ld (hl), 0
  1256.         ldir
  1257.         ret
  1258.  
  1259. ;-------------------------------------------------------
  1260. ; Print the word in BC into four consecutive bytes at HL
  1261. ;-------------------------------------------------------
  1262. PrintWord:
  1263.         ld a,b
  1264.         call PrintByte
  1265.         inc hl
  1266.         inc hl
  1267.         ld a,c
  1268.         call PrintByte
  1269.         dec hl
  1270.         dec hl
  1271.         ret
  1272.  
  1273. ;------------------------------------------------------
  1274. ; Print the byte in A into two consecutive bytes at HL
  1275. ;------------------------------------------------------
  1276. PrintByte:
  1277.         push hl
  1278.         call PrintNybble
  1279.         call PrintNybble
  1280.         pop hl
  1281.     ret
  1282.  
  1283. ; Print the high nybble of A into (HL++), swap nybbles
  1284.  
  1285. PrintNybble:
  1286.         rrca
  1287.         rrca
  1288.         rrca
  1289.         rrca
  1290.     push af
  1291.         and $0F
  1292.     add a, '0'
  1293.     cp $3A
  1294.     jr c, Less_0A
  1295.     add a, 7
  1296. Less_0A:
  1297.         ld (hl),a
  1298.         inc hl
  1299.         pop af
  1300.     ret
  1301.  
  1302. ;------------------------------------------------------
  1303. ; Load HL from Word Table.
  1304. ; Input:  A = some bits hold an index into the table
  1305. ;         H = AND bitmask to apply to A
  1306. ;         BC= table start address
  1307. ; Output: HL= [BC+2*A(index bits)]
  1308. ;         A and BC are preserved
  1309. ;------------------------------------------------------
  1310. LD_HL_From_Table:
  1311.         push bc
  1312.         ld L,0  ; make sure L has no bits set
  1313.         ld b,8  ; do this 8 times, once for each bit
  1314. LHBA_Loop:
  1315.         rlca            ; rotate A
  1316.         rl L            ; put that bit from A into L
  1317.         sla h
  1318.         jr c,LHBA_Bit1  ; if bit shifted out of H is 0
  1319.         srl L           ; discard that bit from L
  1320. LHBA_Bit1:              
  1321.         djnz LHBA_Loop
  1322.         pop bc
  1323.         add hl,hl       ; table is word-sized
  1324.         add hl,bc       ; add table start address
  1325.         call LD_HL_pHL
  1326.         ret
  1327.  
  1328. ;------------------------------------------------------
  1329. ; Load HL from (HL)
  1330. ;------------------------------------------------------
  1331. LD_HL_pHL:
  1332.         push de
  1333.         ld e,(hl)
  1334.         inc hl
  1335.         ld d,(hl)
  1336.         ex de,hl
  1337.         pop de
  1338.         ret
  1339.  
  1340. ;------------------------------------------------------
  1341. ; Set up call table
  1342. ;------------------------------------------------------
  1343. ;__getkey        .db $CD,0,0,$C9
  1344.  
  1345. SetUpCalls:
  1346.         ld b,(EndOfCallTable-CallTable)/2
  1347.         ld hl, CallTable
  1348.         ld de, __clrLCD
  1349. SUC_Loop:
  1350.         push bc
  1351.  
  1352.         push hl
  1353.         call LD_HL_pHL
  1354.         ldi             ; copy call
  1355.         ldi
  1356.         ldi
  1357.         ldi
  1358.         pop hl
  1359.         inc hl
  1360.         inc hl
  1361.         pop bc
  1362.         djnz SUC_Loop
  1363.         ret
  1364.  
  1365. CallTable:      ; these need to be in the same order as the list at
  1366.                 ; the top of this file
  1367.                 .dw _clrLCD
  1368.                 .dw _clrScrn
  1369.                 .dw _putmap
  1370.                 .dw _putc
  1371.                 .dw _puts
  1372.                 .dw _vputmap
  1373.                 .dw _vputs
  1374.                 .dw _busyOn
  1375.                 .dw _busyOff
  1376.                 .dw _getkey
  1377. EndOfCallTable    
  1378.  
  1379. ;------------------------------------------------------
  1380. ; Variables
  1381. ;------------------------------------------------------
  1382. DisAddrTop      .dw $00
  1383. DisFlags        .db $00
  1384.  
  1385. ByteStr         .db "00",0
  1386. WordStr         .db "0000",0
  1387. imm8Str         .db "00h",0
  1388. imm16Str        .db "0000h",0
  1389. PortStrSm       .db "(0)",0
  1390. PortStrLg       .db "(00h)",0
  1391. AddrStr         .db "(0000h)",0
  1392. IndexStr        .db "(IX+00h)",0
  1393. HLIXStr         .db "HL",0
  1394. _HLIX_Str       .db "(HL)",0
  1395.  
  1396. ;------------------------------------------------------
  1397. ; Tables
  1398. ;------------------------------------------------------
  1399.  
  1400. s8ptrs          .dw Normal_s8ptrs
  1401. Normal_s8ptrs   .dw BStr,CStr,DStr,EStr,HStr,LStr,_HL_Str,AStr
  1402. Index_s8ptrs    .dw BStr,CStr,DStr,EStr,XHStr,XLStr,IndexStr,AStr
  1403.  
  1404. s16ptrs         .dw BCStr,DEStr,HLIXStr,SPStr
  1405. stack_s16ptrs   .dw BCStr,DEStr,HLIXStr,AFStr
  1406.  
  1407. inCptrs         .dw BStr,CStr,DStr,EStr,HStr,LStr,DashStr,AStr
  1408. outCptrs        .dw BStr,CStr,DStr,EStr,HStr,LStr,ZeroStr,AStr
  1409.  
  1410. condptrs        .dw nzStr,zStr,ncStr,cStr,poStr,peStr,pStr,mStr
  1411.  
  1412. rotptrs         .dw rlcaStr,rrcaStr,rlaStr,rraStr
  1413.  
  1414. imptrs          .dw ZeroStr,QuestionStr,OneStr,TwoStr
  1415.  
  1416. op001xx111ptrs  .dw daaStr,cplStr,scfStr,ccfStr
  1417.  
  1418. op80_BFptrs     .dw addStr,adcStr,subStr,sbcStr
  1419.                 .dw andStr,xorStr,orStr,cpStr
  1420.  
  1421. opC0_evenptrs   .dw retStr,jpStr,callStr
  1422.  
  1423. opCB00_3Fptrs   .dw rlcStr,rrcStr,rlStr,rrStr
  1424.                 .dw slaStr,sraStr,sllStr,srlStr
  1425.  
  1426. opCB40_FFptrs   .dw QuestionStr,bitStr,resStr,setStr
  1427.  
  1428. opEDA0_BFptrs   .dw ldiStr,cpiStr,iniStr,outiStr
  1429.                 .dw lddStr,cpdStr,indStr,outdStr
  1430.                 .dw ldirStr,cpirStr,inirStr,otirStr
  1431.                 .dw lddrStr,cpdrStr,indrStr,otdrStr
  1432.  
  1433. ;------------------------------------------------------
  1434. ; Strings
  1435. ;------------------------------------------------------
  1436. NullStr         .db 0
  1437. QuestionStr     .db "?",0
  1438. DashStr         .db "-",0
  1439. ZeroStr         .db "0",0
  1440. OneStr          .db "1",0
  1441. TwoStr          .db "2",0
  1442.  
  1443. AStr    .db "A",0
  1444. AFStr   .db "AF",0
  1445. AFpStr  .db "AF",$27,0   ; AF'
  1446. BStr    .db "B",0
  1447. BCStr   .db "BC",0
  1448. CStr    .db "C",0
  1449. DStr    .db "D",0
  1450. DEStr   .db "DE",0
  1451. EStr    .db "E",0
  1452. HStr    .db "H",0
  1453. HLStr   .db "HL",0
  1454. IStr    .db "I",0
  1455. IXStr   .db "IX",0
  1456. XHStr   .db "XH",0
  1457. XLStr   .db "XL",0
  1458. LStr    .db "L",0
  1459. RStr    .db "R",0
  1460. SPStr   .db "SP",0
  1461. _BC_Str .db "(BC)",0
  1462. _DE_Str .db "(DE)",0
  1463. _HL_Str .db "(HL)",0
  1464. _SP_Str .db "(SP)",0
  1465.  
  1466. PortCStr        .db "(C)",0
  1467.  
  1468. nzStr   .db "nz",0
  1469. zStr    .db "z",0
  1470. ncStr   .db "nc",0
  1471. cStr    .db "c",0
  1472. poStr   .db "po",0
  1473. peStr   .db "pe",0
  1474. pStr    .db "p",0
  1475. mStr    .db "m",0
  1476.  
  1477. StartOfStrings
  1478.  
  1479. adcStr  .db "ADC",0
  1480. addStr  .db "ADD",0
  1481. andStr  .db "AND",0
  1482. bitStr  .db "BIT",0
  1483. callStr .db "CALL",0
  1484. ccfStr  .db "CCF",0
  1485. cpStr   .db "CP",0
  1486. cpdStr  .db "CPD",0
  1487. cpdrStr .db "CPDR",0
  1488. cpiStr  .db "CPI",0
  1489. cpirStr .db "CPIR",0
  1490. cplStr  .db "CPL",0
  1491. daaStr  .db "DAA",0
  1492. decStr  .db "DEC",0
  1493. diStr   .db "DI",0
  1494. djnzStr .db "DJNZ",0
  1495. eiStr   .db "EI",0
  1496. exStr   .db "EX",0
  1497. exxStr  .db "EXX",0
  1498. haltStr .db "HALT",0
  1499. imStr   .db "IM",0
  1500. inStr   .db "IN",0
  1501. incStr  .db "INC",0
  1502. indStr  .db "IND",0
  1503. indrStr .db "INDR",0
  1504. iniStr  .db "INI",0
  1505. inirStr .db "INIR",0
  1506. jpStr   .db "JP",0
  1507. jrStr   .db "JR",0
  1508. ldStr   .db "LD",0
  1509. lddStr  .db "LDD",0
  1510. lddrStr .db "LDDR",0
  1511. ldiStr  .db "LDI",0
  1512. ldirStr .db "LDIR",0
  1513. negStr  .db "NEG",0
  1514. nopStr  .db "NOP",0
  1515. orStr   .db "OR",0
  1516. otdrStr .db "OTDR",0
  1517. otirStr .db "OTIR",0
  1518. outStr  .db "OUT",0
  1519. outdStr .db "OUTD",0
  1520. outiStr .db "OUTI",0
  1521. popStr  .db "POP",0
  1522. pushStr .db "PUSH",0
  1523. resStr  .db "RES",0
  1524. retStr  .db "RET",0
  1525. retiStr .db "RETI",0
  1526. retnStr .db "RETN",0
  1527. rlStr   .db "RL",0
  1528. rlaStr  .db "RLA",0
  1529. rlcStr  .db "RLC",0
  1530. rlcaStr .db "RLCA",0
  1531. rldStr  .db "RLD",0
  1532. rrStr   .db "RR",0
  1533. rraStr  .db "RRA",0
  1534. rrcStr  .db "RRC",0
  1535. rrcaStr .db "RRCA",0
  1536. rrdStr  .db "RRD",0
  1537. rstStr  .db "RST",0
  1538. sbcStr  .db "SBC",0
  1539. scfStr  .db "SCF",0
  1540. setStr  .db "SET",0
  1541. slaStr  .db "SLA",0
  1542. sllStr  .db "SLL",0
  1543. sraStr  .db "SRA",0
  1544. srlStr  .db "SRL",0
  1545. subStr  .db "SUB",0
  1546. xorStr  .db "XOR",0
  1547.  
  1548. EndOfStrings
  1549.  
  1550. SmallFont:
  1551. .db $64 ; magic number
  1552. .db $01 ; # of characters in font
  1553.  
  1554. .db 'N'
  1555. .db 5   ; width of character
  1556. .db 00000b
  1557. .db 10010b
  1558. .db 11010b
  1559. .db 10110b
  1560. .db 10010b
  1561. .db 10010b
  1562.  
  1563. ProgramEnd:
  1564. .end
  1565.  
  1566.