home *** CD-ROM | disk | FTP | other *** search
/ Oakland CPM Archive / oakcpm.iso / sigm / vol115 / pseudo.asm < prev    next >
Encoding:
Assembly Source File  |  1984-04-29  |  14.4 KB  |  854 lines

  1. ;THE FIRST(?) PUBLIC DOMAIN HARDWARE-SOFTWARE
  2. ;COMBINATION!
  3. ;    
  4. ;name of file PSEUDO.ZSM
  5. ;
  6. ;this program expects the circuit as described
  7. ;in the file PSEUDO.DOC
  8. ;
  9. ;this is Z80 code, but could be easily adapted
  10. ;to run on an 8080, 8085.
  11. ;
  12. ;the pseudo-ops are for my particular assembler
  13. ;(ie EJECT = PAGE or SKIP etc.,
  14. ;    DEFB = DB, DEFS = DS)
  15. ;
  16. ;This firmware is released into the public domain
  17. ;as of 3/17/83, for personal use only. Hardware
  18. ;&/or software changes are at the discretion of
  19. ;the user.
  20. ;
  21. ;any relation to firmware living or dead is 
  22. ;purely accidental.
  23. ;
  24. ;author:
  25. ;    Ron Winter
  26. ;    PO Box 3061
  27. ;    North Brunswick, NJ 08902
  28. ;    (201) 249 4228
  29. ;
  30. ;
  31. ;credits:
  32. ;
  33. ;I wish to thank all the authors of previous SIG/M
  34. ;releases for many of the ideas used in creating
  35. ;this monster, especially those of BYE for the
  36. ;static byte relocation trickery.
  37. ;
  38. ;
  39. ;note: 
  40. ;no real mention of OS is given in this code
  41. ;and I have run it under (over, thru?) North Star
  42. ;HDOS & CP/M equally. It should run on TRS model?,
  43. ;Softcards, etc. with very little work(?).
  44. ;
  45. ;
  46.  EJECT
  47.     TITLE emulator code 
  48.  PSECT ABS
  49.  
  50. ;I initialize VI6 vector for main monitor,
  51. ;VI5 for breakpoints, leave Z80 in powered on
  52. ;IM0. one could run IM2 without too much sweat.
  53.  
  54. Jump    EQU 0C3H    ;opcode     
  55. RST40    EQU 0C7H+5*8    ;opcode
  56.  
  57. RST_5    EQU 8*5        ;trap $
  58. RST_6   EQU 8*6        ;  "
  59.  
  60. ;assumes 24x80 display, but could be used in
  61. ;other formats, again a little recoding around
  62. ;the display section only.
  63.  
  64. ;I use the following commands in the emulator
  65. ;(to start with, can be extended)
  66. ;
  67. ;<esc> means step from address to be entered
  68. ;<sp>  means single step- initial setup
  69. ;<b> enter breakpoint- and go
  70. ;<r or c or s> means run until RET family
  71. ;<ret> means full speed- pseudo run
  72.  
  73. Base    EQU 0    ;adjust for your roms in cpm land
  74.  
  75. Bell    EQU 07
  76. Space    EQU ' '
  77. Esc    EQU 1BH
  78. Ret    EQU 0DH
  79.  
  80. False    EQU 0
  81. True    EQU .NOT.False
  82.  
  83. Primes    EQU True    ;save AF',HL',DE',BC'
  84.  
  85. Arming_port    EQU 08    ;starts divide/2 on M1
  86.  
  87. Software_enable EQU True
  88.  IF Software_enable
  89. Enable_port     EQU 0AH    ;set to your values
  90. On_value    EQU 0EH
  91. Off_value    EQU 0EH+01
  92.  ENDIF
  93.  
  94. Nstar        EQU True
  95. Nstar_parallel    EQU True    ;my keyboard input
  96. Other_keyboards EQU False
  97.  
  98. Dpcrt        EQU True    ;my `terminal'
  99. Split_screen    EQU True
  100.  
  101. Destination: EQU 0BD00H    ;where I hide it
  102.             ;in my system, change to
  103.             ;suit
  104.  EJECT
  105.     ORG    Base+0100H    ;normal transient
  106.  
  107.     JP    Initialize
  108. ;
  109. ;for debugging, <esc> to really frigid start up!
  110. ;    DI
  111. ;IF Software_enable
  112. ;    LD A,Off_value    ;disables circuit
  113. ;    OUT (Enable_port),A
  114. ;ENDIF
  115. ;IF Nstar
  116. ;    JP 0E800H
  117. ;ENDIF
  118. ;IF .NOT.Nstar
  119. ;    JP 0    ;? or wherever is proper
  120. ;ENDIF
  121.  EJECT
  122. Initialize: DI
  123.  IF Software_enable
  124.     LD    A,On_value
  125.     OUT    (Enable_port),A
  126.  ENDIF
  127.     LD    (SP_save),SP
  128.     LD    SP,SP_save
  129.  
  130.     LD    A,Jump
  131.     LD    HL,Breakpoint
  132.     LD    DE,Monitor
  133.     LD    (RST_5),A
  134.     LD    (RST_6),A
  135.     LD    (RST_5+1),HL
  136.     LD    (RST_6+1),DE
  137.  EJECT
  138. ;byte relocate our assembly to anywhere
  139.     LD    HL,Source
  140.     LD    DE,Destination
  141.     LD    BC,Size_of_code
  142.      LDIR
  143. ;vectors are set, code is in place
  144. ;so now we signal ourself that we are ready
  145.  IF Split_screen
  146.      CALL    Get_cursor    ;split screen use
  147.      CALL    Change_to_29_lines
  148.     LD    DE,' '+24.SHL.8+' '+0
  149. ;D=row, E=column on my screen where I will set
  150. ;the cursor (25th row, 1st col)
  151.      CALL    Set_cursor
  152.  ENDIF
  153.  IF .NOT.Split_screen
  154. ;
  155.  ENDIF
  156.     LD    HL,Pretty_display
  157.     LD    DE,80*5-1    ;# of char's to
  158. Refresh: LD    C,(HL)        ;put on display
  159.      CALL    Out_locally    ;avoiding last
  160.     INC    HL        ;screen position
  161.     DEC    DE        ;so as to keep
  162.     LD    A,E        ;from scrolling
  163.     OR    D
  164.      JR    NZ,Refresh    ;ie, a mini
  165.                 ;screen editor
  166.  IF Split_screen
  167.      CALL    Restore_cursor
  168.      CALL    Back_to_24_lines
  169.  ENDIF
  170.  IF .NOT.Split_screen
  171. ;
  172.  ENDIF
  173.     JP    Exit_initialization
  174. Pretty_display:
  175. ;layout template
  176. ;      1234567890123456789012345678901234567890
  177. ;                  1      2        3          4
  178. ;
  179.  DEFM '<sp> single step, <ret> pseudo run, <esc'
  180.  DEFM '> quit, <s> subs                        '
  181.  DEFM '(pc)           AF sz.h.vnc   HL    DE   '
  182.  DEFM ' BC    IX    IY                         '
  183.  DEFM '........       .. ........  ....  ....  '
  184.  DEFM '....  ....  ....                        '
  185.  DEFM ' pc      SP    AF''sz.h.pnc   HL''   DE''  '
  186.  DEFM ' BC''   I     R                          '
  187.  DEFM '....    ....   .. ........  ....  ....  '
  188.  DEFM '....   ..    ..                         '
  189.  EJECT
  190. Offset    EQU Destination-$    ;sets lc
  191. ;            
  192. Breakpoint: EQU $+Offset
  193. ;will hit here on any rst 40 code executed by
  194. ;processor, hope it was ours!
  195.  
  196. Source:    ;for relaocator
  197.     DI
  198.     LD    (Save_HL),HL ;save hl 1st
  199.     LD    (SP_save),SP ;save stackpointer
  200.  
  201.     PUSH    AF    ;tease AF into view
  202.     POP    HL
  203.     LD    (Save_AF),HL ;save AF
  204.  
  205.     POP    HL    ;the $ after the break
  206.     DEC    HL    ;restored to $ at the
  207.     PUSH    HL    ;breakpoint
  208.     LD    (The_next_pc),HL
  209.  
  210.     LD    SP,SP_save    ;private stack
  211.     LD    (Save_DE),DE    ;de done
  212. ;pointers used here so can be extended to any #
  213. ;of bkpts. One must then keep count of them &
  214. ;their addresses.
  215.     LD    DE,Bpt_storage
  216.     LD    A,(DE)    ;original opcode
  217.     LD    (HL),A    ;restored
  218. ;
  219. ;enable now since it was off for 
  220. ;`run until breakpoint'
  221.  IF Software_enable
  222.     LD    A,On_value
  223.     OUT    (Enable_port),A
  224.  ENDIF
  225. ;preset single step to pause display
  226.     LD    A,Space
  227.     LD    (Last_key),A
  228.      JR    Common_code
  229.  EJECT
  230. Monitor: EQU $+Offset
  231. ;hit here on vi6, and again it better be ours
  232. ;maybe we should
  233.     DI
  234. ;just in case it wasn't!
  235.     LD    (Save_HL),HL
  236.     LD    (SP_save),SP
  237.     POP    HL
  238.     LD    (The_next_pc),HL
  239.     PUSH    HL
  240.  
  241.     LD    SP,SP_save
  242.  
  243.     PUSH    AF
  244.     POP    HL
  245.     LD    (Save_AF),HL
  246.  
  247.     LD    (Save_DE),DE
  248. ;
  249. Common_code:     
  250.     LD    (Save_BC),BC    
  251.                 ;if you want to
  252.     LD    A,I        ;pick up the iff2
  253.     LD    (Save_I),A    ;flip flop, here
  254.                 ;it is in the p/v
  255.                 ;flag now
  256.  
  257.     LD    A,R        ;for those who 
  258.     LD    (Save_R),A    ;like to see action
  259.  
  260.     LD    (SaveIX),IX
  261.     LD    (SaveIY),IY
  262.  IF Primes    
  263. ; if you want to see all the 'ed registers
  264.     EXX
  265.     LD    (HL_prime),HL
  266.     LD    (DE_prime),DE
  267.     LD    (BC_prime),BC
  268.     EX    AF,AF'
  269.     PUSH    AF
  270.     POP    HL
  271.     LD    (AF_prime),HL
  272.     EX    AF,AF'
  273.     EXX
  274.  ENDIF
  275.  EJECT
  276.  IF Split_screen
  277.      CALL    Change_to_29_lines
  278.      CALL    Get_cursor
  279.  ENDIF
  280.  IF .NOT.Split_screen
  281. ;send output to your other terminal
  282.  ENDIF
  283. ;main monitor flavor given by this code
  284.      CALL    Display
  285. Stop:     CALL Poller
  286.      JR    NZ,Key_was_struck    ;else use
  287.                     ;last key
  288.     LD    A,(Last_key)
  289.     CP    Ret
  290.      JR    Z,Pseudo_run
  291.     CP    Space
  292.      JR    Z,Single_step
  293.     CP    'R'
  294.      JR    Z,Run_til_rets
  295. ;more options here
  296.      JR    Error
  297. ;
  298. Single_step:
  299.     LD    DE,' '+24.SHL.8+' '+57
  300.      CALL    Set_cursor
  301.      JR    Stop
  302. ;
  303. Run_til_rets: 
  304.     LD    HL,(The_next_pc)
  305.     LD    A,(HL)
  306.     CP    0C9H        ;is RET
  307.      JR    Z,Stop
  308.     CP    0C0H
  309.      JR    C,Pseudo_run     ;not a RET
  310.     AND    00000111B
  311.      JR    Z,Stop        ;else it aint
  312.  
  313. Pseudo_run:
  314.      CALL Recover_all
  315. Exit_initialization: EQU $+Offset
  316.     LD    SP,(SP_save)
  317.     EI
  318.     OUT    (Arming_port),A
  319.      RET
  320.  EJECT
  321. Key_was_struck:    
  322.     LD (Last_key),A
  323.     CP    Space
  324.      JR    Z,Pseudo_run
  325.  
  326.     AND    01011111B     ;case filter
  327.     LD    (Last_key),A
  328.  
  329.     CP    Ret
  330.      JR    Z,Pseudo_run
  331.  
  332.     PUSH     AF
  333. ;set cursor to prompt point of display
  334.     LD    DE,' '+24.SHL.8+' '+57
  335.      CALL    Set_cursor
  336.     POP    AF
  337.  
  338.     CP    'S'        ;s - subroutine
  339.      JR    Z,Run_until
  340.     CP    'R'        ;r - return
  341.      JR    Z,Run_until
  342.     CP    'C'        ;c - calls
  343.      JR    Z,Run_until
  344.  
  345.     CP    Esc
  346.      JR    Z,Enter_go$
  347.  
  348.     CP    'B'
  349.      JR    Z,Set_breakpoint
  350. ;more options, then fall thru to
  351. Error:    
  352.     LD    C,Bell
  353.      CALL    Out_locally
  354.  
  355.     LD    A,' '        ;force a pause
  356.     LD    (Last_key),A
  357.      JR    Stop
  358. ;
  359. Run_until:
  360.     LD    C,A
  361.  
  362.     LD    A,'R'
  363.     LD    (Last_key),A
  364.  
  365.      CALL    Out_locally
  366.      JR    Pseudo_run
  367.  EJECT
  368. Enter_go$:
  369.      CALL    Get_address
  370.  
  371.  IF Split_screen
  372.      CALL    Restore_cursor
  373.      CALL    Back_to_24_lines
  374.  ENDIF
  375.  IF .NOT.Split_screen
  376. ;
  377.  ENDIF
  378.     LD    A,Space        ;force pause
  379.     LD    (Last_key),A    ;at breakpoint
  380.  
  381.     LD    HL,(Go_or_bkpt) ;from chosen
  382.     LD    SP,(SP_save)    ;address
  383.  
  384.  IF Software_enable
  385.     LD    A,On_value
  386.     OUT    (Enable_port),A
  387.  ENDIF
  388.     EI
  389. ;this arms it (for any value of A)
  390.     OUT    (Arming_port),A
  391.      JP    (HL)
  392. ;
  393. Set_breakpoint:    
  394.     LD    C,'B'
  395.      CALL    Out_locally
  396.  
  397.      CALL    Get_address
  398.  
  399.     LD    DE,Bpt_storage
  400.     LD    HL,(Go_or_bkpt)
  401.     LD    A,(HL)        ;save byte @ $
  402.     LD    (DE),A
  403.     LD    A,RST40        ;set trap
  404.     LD    (HL),A
  405. ;for normal run must disable hardware
  406.  IF Software_enable
  407.     LD    A,Off_value    ;just in case it
  408.     OUT    (Enable_port),A    ;was on
  409.  ENDIF
  410.      CALL    Recover_all
  411.     LD    SP,(SP_save)
  412.      RET
  413. ;
  414.  EJECT
  415. Recover_all: EQU $+Offset
  416.  IF Split_screen
  417.      CALL    Restore_cursor
  418.      CALL    Back_to_24_lines
  419.  ENDIF
  420.  IF .NOT.Split_screen
  421. ;if other terminal, then really nothing to do
  422.  ENDIF
  423.     LD    A,(Save_I)
  424.     LD    I,A
  425.  
  426.     LD    BC,(Save_BC)
  427.     LD    DE,(Save_DE)
  428.     LD    IX,(SaveIX)
  429.     LD    IY,(SaveIY)
  430.  
  431.     LD    HL,(Save_AF)
  432.     PUSH    HL
  433.     POP    AF
  434.  
  435.     LD    HL,(Save_HL)
  436.  IF Primes
  437.     EXX
  438.     EX    AF,AF'
  439.     LD    HL,(AF_prime)
  440.     PUSH    HL
  441.     POP    AF
  442.     EX    AF,AF'
  443.     LD    HL,(HL_prime)
  444.     LD    DE,(DE_prime)
  445.     LD    BC,(BC_prime)
  446.     EXX
  447.  ENDIF
  448.      RET
  449. ;
  450. Restore_cursor:    EQU $+Offset
  451.     LD    DE,(Col_of_cursor)
  452.  
  453. Set_cursor: EQU $+Offset
  454.  IF Dpcrt            ;& televideo,etc.
  455.     LD    C,Esc
  456.      CALL    Out_locally
  457.     LD    C,'='
  458.      CALL    Out_locally
  459.     LD    C,D
  460.      CALL    Out_locally
  461.     LD    C,E
  462.  ENDIF
  463.  IF .NOT.Dpcrt
  464. ;
  465.  ENDIF
  466. Out_locally: EQU $+Offset
  467.  IF Dpcrt
  468. Out_wait: IN    A,(40H)
  469.     BIT    7,A
  470.      JR    NZ,Out_wait
  471.     LD    A,C
  472.     OUT    (41H),A
  473.  ENDIF
  474.  IF .NOT.Dpcrt
  475. ;alternate code to do console out
  476. ;char in C, preserve all but AF
  477.  ENDIF    
  478.      RET
  479. ;
  480. In_locally: EQU $+Offset
  481.  IF Dpcrt
  482. In_wait: IN    A,(40H)
  483.     BIT    0,A
  484.      JR    NZ,In_wait
  485.     IN    A,(41H)
  486.  ENDIF
  487.  IF .NOT.Dpcrt
  488. ;code for getting bytes (cursor position) f/ your
  489. ;terminal, return char in A
  490.  ENDIF
  491.      RET
  492. ;
  493. Get_cursor: EQU $+Offset
  494.  IF Dpcrt            ;& televideo,etc.
  495.     LD    C,Esc
  496.      CALL    Out_locally
  497.     LD    C,'?'
  498.      CALL    Out_locally
  499.      CALL    In_locally
  500.     LD    (Row_of_cursor),A
  501.      CALL    In_locally
  502.     LD    (Col_of_cursor),A
  503.  ENDIF
  504.  IF .NOT.Dpcrt
  505. ;
  506.  ENDIF
  507.      RET
  508. ;
  509. Change_to_29_lines: EQU $+Offset
  510.  IF Dpcrt
  511.     LD    D,29    ;lines
  512.  ENDIF
  513.  IF .NOT.Dpcrt
  514. ;if other terminal, these routines are
  515. ;not needed
  516.  ENDIF
  517.      JR    S_screen
  518. ;
  519. Back_to_24_lines: EQU $+Offset
  520.  IF Dpcrt
  521.     LD    D,24
  522.  ENDIF
  523.  IF .NOT.Dpcrt
  524. ;
  525.  ENDIF 
  526. S_screen: LD    HL,Terminal_split_screen_command
  527.     LD    B,C_length
  528.      CALL    String_it
  529.  IF Dpcrt
  530.     LD    C,D
  531.      JP    Out_locally
  532.  ENDIF
  533.  IF .NOT.Dpcrt
  534. ;
  535.      RET
  536.  ENDIF
  537. ;
  538. String_it: EQU $+Offset
  539. S_print: LD    C,(HL)
  540.     INC    HL
  541.      CALL    Out_locally
  542.     DJNZ    S_print
  543.      RET
  544.  EJECT
  545. Poller:    EQU $+Offset
  546. ;for get address routine, poller should preserve
  547. ;HL at least
  548. ;this is the char input routine
  549.  
  550.  IF Nstar_parallel
  551. ;local console input code
  552.     IN    A,(06)
  553.     BIT    1,A
  554.  ENDIF
  555.  IF .NOT.Nstar_parallel
  556. ;
  557. ;
  558.  ENDIF
  559.      RET    Z
  560. ;return if no key struck, else return with char
  561. ;in A, & z flag false.
  562.  IF Nstar_parallel     ;and no repeat, no case!
  563.     BIT    6,A    ;on my adm-? keyboard!
  564.     LD    (Repeat?),A
  565.  
  566.     LD    A,(Toggle)
  567.      JR    Z,No_case_switch
  568.     XOR    01
  569.     LD    (Toggle),A
  570. No_case_switch: OR A
  571.  
  572.     IN    A,(00H)    ;finally the key
  573.      JR    Z,Keep_extra_punctuation
  574.     CP    '@'
  575.      JR    C,Keep_extra_punctuation
  576.     CP    '`'
  577.      JR    NC,Keep_extra_punctuation
  578.     ADD    A,'a'-'A'
  579. Keep_extra_punctuation:    LD (Key_stroke),A
  580.     LD    A,(Repeat?)
  581.     BIT    7,A
  582.      JR    NZ,Force_repeat    ;note false zf
  583.     LD    A,30H    ;resets parallel
  584.             ;input flag on m'board
  585.     OR    A    ;note also false zf
  586.     OUT    (06H),A
  587. Force_repeat: LD A,(Key_stroke)
  588.  ENDIF
  589.  IF .NOT.Nstar_parallel
  590. ;probably a lot less code!
  591.  ENDIF
  592.      RET
  593.  EJECT
  594. Reget:
  595.     POP    HL
  596. Get_address: EQU $+Offset
  597. ;must enter 4 hex characters, <esc> to re-enter
  598. ;only return to use displayed value
  599.     LD    DE,' '+24.SHL.8+' '+59
  600.      CALL    Set_cursor
  601.  
  602.     LD    HL,Address_prompt
  603.     LD    B,P_length
  604.      CALL    String_it
  605.  
  606.     LD    HL,Go_or_bkpt+1 ;human entry
  607.      CALL    Hex_loop    ;is left to right    
  608.      CALL    Hex_loop    ;so we do high
  609.     LD    HL,Go_or_bkpt    ;first, then low
  610.      CALL    Hex_loop    ;byte of address
  611.      CALL    Hex_loop    ;need for exit
  612.      RET            ;method
  613. ;
  614. Hex_nfg:
  615.     LD    A,C
  616.     CP    Esc
  617.      JR    Z,Reget
  618.     LD    C,Bell
  619.      CALL    Out_locally
  620. ;
  621. Hex_loop: EQU $+Offset
  622. Hex_wait: CALL    Poller
  623.      JR    Z,Hex_wait
  624.     LD    C,A        ;save for echo
  625.     CP    '0'
  626.      JR    C,Hex_nfg
  627.     SUB    '0'
  628.     CP    '9'-'0'+1
  629.      JR    C,Hex_ok
  630.     AND    01011111B    ;upper-lower
  631.                 ;case filter
  632.     SUB    'A'-('9'+1)
  633.     CP    16
  634.      JR    NC,Hex_nfg
  635. Hex_ok:    RLD            ;since we have it
  636.                  ;might as well
  637.                 ;stuff it in
  638.      JP    Out_locally
  639.  EJECT
  640. ;main monitor display update
  641. Display: EQU $+Offset
  642.  
  643.     LD    DE,' '+26.SHL.8+' '
  644.      CALL    Set_cursor
  645. ;
  646.     LD    HL,(The_next_pc)
  647.     LD    B,04        ;contents of next
  648. Show_code: LD    A,(HL)        ;address
  649.      CALL    Hex_to_2_ascii    ;disassembler
  650.     INC    HL        ;anyone?
  651.      DJNZ    Show_code
  652. ;
  653.     LD    HL,Save_AF
  654.     LD    DE,' '+26.SHL.8+' '+15
  655.      CALL    Do_a_line
  656.  
  657.     LD    HL,(SaveIX)
  658.      CALL    Word_to_4_ascii
  659.  
  660.      CALL    Two_blanks
  661.  
  662.     LD    HL,(SaveIY)
  663.      CALL    Word_to_4_ascii
  664.  
  665. ;next display line
  666.     LD    DE,' '+28.SHL.8+' '+0
  667.      CALL    Set_cursor
  668.  
  669.     LD    HL,(The_next_pc)
  670.  
  671.      CALL    Word_to_4_ascii
  672.      CALL    Four_blanks
  673.     LD    HL,(SP_save)    ;with our trap on
  674.     INC    HL        ;it, so we show 
  675.     INC    HL        ;it as the back-
  676.      CALL    Word_to_4_ascii ;ground sees it
  677. ;
  678.  IF Primes
  679.     LD    HL,AF_prime
  680.     LD    DE,' '+28.SHL.8+' '+15
  681.  
  682.      CALL    Do_a_line
  683.      CALL    One_blank
  684.  ENDIF
  685.  IF .NOT.Primes
  686.     LD    DE,' '+28.SHL.8+' '+47
  687.                     ;that aught to line
  688.                 ;up under I & R
  689.      CALL    Set_cursor
  690.  ENDIF
  691.     LD    A,(Save_I)
  692.      CALL    Hex_to_2_ascii
  693.      CALL    Four_blanks
  694.     LD    A,(Save_R)
  695.      JP    Hex_to_2_ascii
  696.  EJECT
  697. Do_a_line: EQU $+Offset
  698.  
  699.      CALL    Set_cursor
  700.     INC    HL
  701.     LD    A,(HL)        ;saved A (or A')
  702.      CALL    Hex_to_2_ascii
  703.      CALL    One_blank
  704.  
  705.     DEC    HL
  706.     LD    A,(HL)        ;flag register
  707.     INC    HL
  708.     INC    HL
  709.     LD    B,08        ;# bits
  710. More_bits: LD    C,'1'
  711.     SLA    A
  712.     PUSH    AF
  713.      JR    C,A_bit
  714.     DEC    C        ;'1' -> '0'
  715. A_bit:     CALL    Out_locally
  716.     POP    AF
  717.     DJNZ    More_bits
  718.  
  719.      CALL    Two_blanks
  720.  
  721.     EX    DE,HL
  722.     LD    B,03        ;for HL DE & BC
  723. HLDEBC:    LD    A,(DE)        ;or  primed
  724.     LD    L,A
  725.     INC    DE
  726.     LD    A,(DE)
  727.     LD    H,A
  728.     INC    DE
  729.      CALL    Word_to_4_ascii
  730.      CALL    Two_blanks
  731.     DJNZ    HLDEBC
  732.      RET
  733.  EJECT
  734. ;garden variety utilities
  735. ;
  736. ;print HL as 4 ascii bytes
  737. Word_to_4_ascii: EQU $+Offset
  738.  
  739.     LD    A,H
  740.      CALL    Hex_to_2_ascii
  741.     LD    A,L
  742.  
  743. ;print A as 2 ascii bytes 
  744. Hex_to_2_ascii:    EQU $+Offset
  745.  
  746.     PUSH    AF
  747.     SRL    A
  748.     SRL    A
  749.     SRL    A
  750.     SRL    A
  751.      CALL    Byte_to_ascii
  752.     POP    AF
  753.     AND    0FH
  754.  
  755. ;nybble to ascii & print
  756. Byte_to_ascii: EQU $+Offset
  757.     ADD    A,90H
  758.     DAA
  759.     ADC    A,40H
  760.     DAA
  761.     LD    C,A
  762.      JP    Out_locally
  763. ;
  764. Four_blanks: EQU $+Offset
  765.  
  766.     LD    C,' '
  767.      CALL    Out_locally
  768.     LD    C,' '
  769.      CALL    Out_locally
  770.  
  771. Two_blanks: EQU $+Offset
  772.  
  773.     LD    C,' '
  774.      CALL    Out_locally
  775.  
  776. One_blank: EQU $+Offset
  777.  
  778.     LD    C,' '
  779.      JP    Out_locally
  780.  EJECT
  781. Terminal_split_screen_command: EQU $+Offset
  782.  
  783.  IF Dpcrt
  784.     DEFB    Esc,'L',0,1,8AH,0E7H
  785.  ENDIF
  786.  IF .NOT.Dpcrt
  787. ;if other terminal then this probably aint here
  788.   ENDIF
  789. C_length: EQU $+Offset-Terminal_split_screen_command
  790. ;
  791. The_next_pc: EQU $+Offset
  792.     DEFS 2
  793. Go_or_bkpt: EQU $+Offset
  794.     DEFS 2
  795.  
  796. Save_AF: EQU $+Offset
  797.     DEFS 2
  798. Save_HL: EQU $+Offset
  799.     DEFS 2
  800. Save_DE: EQU $+Offset
  801.     DEFS 2
  802. Save_BC: EQU $+Offset
  803.     DEFS 2
  804.  
  805. SaveIX:    EQU $+Offset
  806.     DEFS 2
  807. SaveIY:    EQU $+Offset
  808.     DEFS 2
  809.  
  810. AF_prime: EQU $+Offset
  811.     DEFS 2
  812. HL_prime: EQU $+Offset
  813.     DEFS 2
  814. DE_prime: EQU $+Offset
  815.     DEFS 2
  816. BC_prime: EQU $+Offset
  817.     DEFS 2
  818.  
  819. Save_I:    EQU $+Offset
  820.     DEFS 1
  821. Save_R:    EQU $+Offset
  822.     DEFS 1
  823.  
  824. Bpt_storage: EQU $+Offset
  825.     DEFS 2
  826.  
  827. Col_of_cursor: EQU $+Offset
  828.     DEFS 1
  829. Row_of_cursor: EQU $+Offset    
  830.     DEFS 1
  831.  IF Nstar_parallel
  832. Toggle:    EQU $+Offset
  833.     DEFS 1
  834. Key_stroke: EQU $+Offset
  835.     DEFS 1
  836. Repeat?: EQU $+Offset
  837.     DEFS 1
  838.  ENDIF
  839. Last_key: EQU $+Offset
  840.     DEFS 1
  841. ;
  842. Address_prompt: EQU $+Offset
  843.     DEFM 'addr ='
  844. P_length: EQU $+Offset-Address_prompt
  845. ;leave some stack space
  846.     DEFS ($.AND.0FF00H)+100H-$-2
  847.     DEFB 0        ;to see if enuf sp space
  848. SP_save    EQU $+Offset
  849.  LIST
  850. Size_of_code: EQU $+Offset-Breakpoint 
  851. ;see if total size will fit where you plan to 
  852. ;move it (reassemble with alternate origin til
  853. ;it just fits)!
  854.     END