home *** CD-ROM | disk | FTP | other *** search
/ Oakland CPM Archive / oakcpm.iso / sigm / vol172 / 8086.a86 < prev    next >
Encoding:
Text File  |  1984-05-30  |  15.5 KB  |  874 lines

  1. ;This is a simple monitor for an 8086 board
  2. ;It is based on the simple monitor in Byte on Nov 1980 but has been enlarged
  3. ;to have a few extra fetures.  In my system it is in ROM at 0ff800h so that a
  4. ;reset will go to the end of this monitor 0ffff0h and decide if a jump to
  5. ;low ram is req or monitor commands.  The references to a z80 are the z80 
  6. ;board (MASTER/s100) which transferrs control to the 8086 (SLAVE/z80). 
  7. ;Look at the end of this program for the menue and more details
  8. ;
  9. ;        John Monahan        (201) 779- 0635
  10. ;
  11. ff    equ    0ch
  12. lf    equ    0ah
  13. cr    equ    0dh
  14. bs    equ    0bh
  15. esc    equ    1bh        ;ESC character to abort a command
  16. bell    equ    07h
  17. tab    equ    09h
  18.  
  19. IOBYTE    EQU    0FFH        ;IOBYTE (SEE BELOW)
  20. SDSTAT    EQU    0H        ;crt out status port
  21. SDDATA    EQU    1H        ;crt out data port
  22. KEYSTAT    EQU    0H        ;keyboard in status port
  23. KEYIN    EQU    1H        ;keyboard in
  24. CENTSTAT EQU    5H        ;printer status
  25. CENTOUT    EQU    5H        ;printer data
  26. CENTSTROBE EQU    4H        ;strobe for printer
  27. ;
  28. ;    THE FOLLOWING IS FOR RAM STORAGE (YOU CAN PUT IT ANYWHERE)
  29. flag    equ    0Df9fh        ;--- a byte for flag storage in ram
  30. stackp    equ    0Df9eh        ;--- NOTE this is where the stack will start
  31.                 ;    the SS will be set to 0h. so 0000:df9eh
  32. ;----------------------------------------------------------------------------
  33.  
  34.  
  35.     cseg    0F000H        ;USE 0000 FOR TESTING PURPOSES WITH PDD.COM
  36.     org    0F800H        
  37.  
  38.     pagesize    72
  39.     pagewidth    132
  40. ;
  41. begin:    jmp    init            ;reset all registrars
  42.     jmp    ci            ;console input
  43.     jmp    ri            ;reader outputr
  44. conout:    jmp    co            ;console output
  45.     jmp    poo            ;punch output
  46.     jmp    lo            ;printer output
  47. keystaa:jmp    csts            ;consol status
  48. conin:    jmp    cico            ;console in with echo
  49.     jmp    lstat            ;printer status
  50.     jmp    start            ;warm start
  51. ;
  52. ;
  53. init:    cld                ;set direction up
  54.     cli                ;disabel interrupts
  55.     mov    ax,cs            ;note cs will be 0f000h
  56.     mov    ds,ax
  57.     mov    es,ax
  58.     mov    ax,0            ;must put stack in RAM
  59.     mov    ss,ax
  60.     mov    sp,stackp        ;<----MUST point to a RAM area
  61.     mov    bx,(offset SIGNON)
  62.     call    print
  63. ;
  64. start:    mov    ax,0
  65.     mov    ss:.flag,al        ;flag used by some routines
  66.     mov    ax,cs
  67.     mov    ds,ax            ;set ds & es for messages
  68.     mov    es,ax            ;NOTE DS: WILL BE USED FOR ALL MSGS
  69.     call    crlf            ;WITH THIS MONITOR
  70.     mov    cl,'>'
  71.     call    conout
  72.     mov    cl,07h
  73.     call    conout
  74. ;
  75. mainloop: call    conin            ;get a command
  76.     mov    ah,0
  77.     cmp    al,'A'
  78.     jb    start            ;must be A to Z
  79.     cmp    al,'Z'
  80.     jg    start
  81.     sub    al,'A'            ;calculate offset
  82.     shl    al,1            ;X 2
  83.     add    ax,Offset ctable
  84.     mov    bx,ax
  85.     mov    ax, [bx]        ;get location of routine
  86.     call    ax
  87.     jmp    start            ;finished 
  88. ;
  89. ;
  90. fill:    call    setup            ;if > 64k segment will be in ds:
  91.     call    clength
  92.     push    ds            ;because ds is destroyed by getparmal
  93.     call    getparmal
  94.     pop    ds
  95. floop:    mov    [bx],al            ;note this is ds:[bx]
  96.     inc    bx
  97.     loop    floop
  98.     ret
  99. ;
  100. ;
  101. verify:    call    setup
  102.     push    ds            ;save it for below
  103.     call    clength
  104.     inc    cx
  105.     mov    si,bx
  106.     push    cx
  107.     mov    cx,0ffffh
  108.     call    getparmb        ;ds has segment info
  109.     pop    cx
  110.     mov    ax,ds
  111.     mov    es,ax
  112.     pop    ds            ;now ds and es are set correctly
  113.     mov    di,bx
  114.     call    crlf
  115. vloop:    
  116.    repe    cmps    Byte Ptr [di],Byte Ptr [si]
  117.     cmp    cx,0
  118.     jne    verr
  119.     ret
  120. ;
  121. verr:    push    ds            ;must relocate ds
  122.     mov    ax,cs
  123.     mov    ds,ax
  124.     cmp    ss:byte ptr .flag, 0ffh        ;flag for heading done
  125.     jz    verr1
  126.     mov    ss:byte ptr .flag, 0ffh        ;so next time indicates done
  127.     mov    bx, Offset vhead
  128.     call    print
  129. verr1:    pop    ds            ;get back ds
  130.     mov    bx,si
  131.     dec    bx
  132.     call    outadd
  133.     mov    al,[bx]
  134.     mov    dh,al            ;store ah in dh
  135.     call    hexout
  136.     call    blank
  137.     call    blank
  138.     mov    bx,di
  139.     dec    bx
  140.     call    outadd1
  141.     mov    al,es:[bx]
  142.     push    ax
  143.     call    hexout
  144.     call    blank
  145.     pop    ax
  146.     xor    al,dh            ;store from above
  147.     call    binout
  148.     call    ctlchek
  149.     jmp    vloop
  150. ;
  151. ;
  152. move:    call    setup
  153.     push    ds            ;save ds
  154.     cmp    al,cr
  155.     jnz    m1
  156.     jmp    err
  157. m1:    call    clength
  158.     push    bx            ;save bx
  159.     call    setup
  160.     mov    ax,ds
  161.     mov    es,ax            
  162.     mov    di,bx
  163.     pop    bx            ;now get back bx
  164.     pop    ds            ;now get back ds
  165.     mov    si,bx
  166.   rep    movs    Byte Ptr [di], byte Ptr [si]
  167.     ret
  168. ;
  169. ;
  170. dump:    call    setup
  171.     and    bl,0f0h            ;even up printout
  172.     or    dl,0fh            ;also nice ending for Ray G.
  173.     call    clength
  174.     call    outadd            ;send start address
  175. dloop1:    mov    al,ds:[bx]
  176.     call    hexout
  177.     call    blank
  178.     mov    al,bl            ;test 16 byte boundry
  179.     and    al,0fh
  180.     cmp    al,0fh
  181.     jnz    dnext
  182. notfst:    push    cx            ;now print ascii
  183.     push    bx
  184.     push    dx
  185.     mov    cx,8            ;first send 8 spaces
  186.     call    tabs
  187.     sub    bx,000fh        ;drop back 16 places
  188.     mov    dl,16
  189. dloop2:    mov    al,ds:[bx]
  190.     and    al,7fh
  191.     cmp    al,' '            ;filter out control characters
  192.     jnc    dloop3
  193. dloop4:    mov    al,'.'
  194. dloop3:    cmp    al,'~'
  195.     jnc    dloop4
  196.     mov    cl,al
  197.     call    conout
  198.     inc    bx
  199.     dec    dl
  200.     jnz    dloop2
  201.     pop    dx
  202.     pop    bx
  203.     pop    cx
  204.     inc    bx
  205.     call    outadd
  206.     jmp    dump1
  207. ;
  208. dnext:    inc    bx            
  209. dump1:    loop    dloop1
  210.     ret
  211. ;
  212. ;
  213. query:    call    conin            ;is it input or output
  214.     cmp    al,'I'
  215.     jz    input
  216.     cmp    al,'O'
  217.     jz    output
  218.     jmp    err            ;if not QI or QO then error
  219. input:    push    ds            ;ds is altered by setup
  220.     call    setup
  221.     pop    ds
  222.     call    crlf
  223.     mov    dx,bx
  224.     in    al,dx
  225.     push    ax
  226.     call    hexout
  227.     call    blank
  228.     pop    ax
  229.     call    binout
  230.     ret
  231. ;
  232. ;
  233. output:    push    ds        ;play safe 
  234.     call    setup
  235.     pop    ds
  236.     mov    al,dl
  237.     mov    dx,bx
  238.     out    dx,al
  239.     ret
  240. ;
  241. ;
  242. goto:    push    ds
  243.     call    setup
  244.     pop    ds
  245.     jmp    bx
  246. ;
  247. ;
  248. hexmath:push    ds
  249.     call    setup
  250.     pop    ds
  251.     push    bx        ;save data for the moment
  252.     push    dx
  253.     call    crlf
  254.     mov    bx, offset mhead
  255.     call    print
  256.     call    crlf
  257.     pop    dx        ;get back data
  258.     pop    bx
  259.     push    bx        ;save them again for below
  260.     push    dx
  261.     add    bx,dx
  262.     call    outbx    
  263.     mov    cx,2        ;skip over 2 spaces
  264.     call    tabs
  265.     pop    dx        ;get back data one more time
  266.     pop    bx
  267.     sub    bx,dx
  268.     call    outbx
  269.     ret
  270. ;
  271. ;
  272. ntest:    call    setup
  273.     call    clength
  274.     call    crlf
  275. mtest1:    push    bx
  276.     push    cx
  277. mtloop:    mov    al,ds:[bx]
  278.     mov    ah,al
  279.     not    al
  280.     mov    ds:[bx],al
  281.     mov    al,ds:[bx]
  282.     not    al
  283.     cmp    al,ah
  284.     jne    terr
  285.     mov    ds:[bx],ah
  286. tnext:    inc    bx
  287.     call    ctlchek
  288.     loop    mtloop
  289.     pop    cx
  290.     pop    bx
  291.     jmp    mtest1            ;test for ever
  292. ;
  293. terr:    mov    dx,ax            ;save data in dx
  294.     call    outadd
  295.     mov    ax,dx            ;get back data
  296.     xor    al,ah            ;identify bits
  297.     mov    dx,ax
  298.     call    hexout
  299.     call    blank
  300.     mov    ax,dx
  301.     call    binout
  302.     jmp    tnext
  303. ;
  304. ;
  305. esubst:    call    setup
  306. nusloop: call    outadd
  307.     mov    cx,8
  308. sloop:    call    blank
  309.     mov    al,ds:[bx]
  310.     push    cx
  311.     push    bx
  312.     push    ax
  313.     call    hexout
  314.     mov    cl,'-'
  315.     call    conout
  316.     pop    ax
  317.     pop    bx
  318.     pop    cx
  319.     push    ds            ;is messed up by getparmal
  320.     call    getparmal
  321.     pop    ds
  322.     cmp    ah,cr
  323.     je    qtest
  324.     cmp    ah,' '            ;is a skip reqs
  325.     jne    snext1
  326. snext:    mov    ds:[bx],al
  327. snext1:    inc    bx
  328.     loop    sloop
  329.     jmp    nusloop
  330. qtest:    ret
  331. ;
  332. ;
  333. dispas:    call    setup
  334.     and    bl,0f0h            ;even up printout
  335.     or    dl,0fh            ;also nice ending for Ray G.
  336.     call    clength            ;length in cx
  337.     call    outadd            ;send start address
  338. aloop1:    mov    dl,64            ;dx no longer needed
  339.     push    cx            ;put length on stack
  340. aloop2:    mov    al,ds:[bx]
  341.     and    al,7fh
  342.     cmp    al,' '            ;filter out control characters
  343.     jnc    aloop3
  344. aloop4:    mov    al,'.'
  345. aloop3:    cmp    al,'~'
  346.     jnc    aloop4
  347.     mov    cl,al
  348.     call    conout
  349.     inc    bx
  350.     dec    dl
  351.     jnz    aloop2
  352.     call    outadd
  353.     pop    cx            ;get back length (was on stack)
  354.     sub    cx,64
  355.     jnc    aloop1
  356.     ret
  357. ;
  358. ;
  359. map:    call    crlf
  360.     mov    ax,0
  361.     mov    ds,ax            ;must start in first segment
  362.     mov    dl,64            ;character count
  363.     mov    dh,4            ;segment counter(4 lines per segment)
  364.     mov    bx,ax            ;need to reset bx (ds = 0 already)
  365.     call    outadd            ;start with address
  366. map1:    mov    ax,[bx]            ;remember ds is assumed 
  367.     not    ax            ;complement data
  368.     mov    [bx],ax
  369.     cmp    ax,[bx]            ;did it change
  370.     jne    not_ram
  371.     not    ax            ;correct data
  372.     mov    [bx],ax
  373.     mov    cl,'R'
  374.     jmp    nextbk            ;get next block
  375. ;
  376. not_ram:cmp    ax,0            ;ffff->0  must be rom if not 0
  377.     jne    prom
  378.     mov    cl,'.'            ;no need to correct data for here
  379.     jmp    nextbk            ;get next block
  380. ;
  381. prom:    mov    cl,'p'
  382. ;
  383. nextbk:    call    conout            ;send the R,P or "."
  384.     inc    bh            ;move 1000h at a time
  385.     dec    dl
  386.     jnz    noline
  387.     mov    dl,64            ;reset counter for next line
  388.     dec    dh            ;segment counter
  389.     jnz    noseg
  390.     mov    ax,ds
  391.     add    ax,1000h
  392.     jc    mapdone
  393.     mov    ds,ax
  394.     mov    dh,4
  395. noseg:    call    outadd
  396. noline:    jmp    map1
  397. mapdone: ret
  398. ;
  399. ;    Note this is dependent on my system you can ignore
  400. ;
  401. Z80:    in    al,0fdh            ;this switches control over to Z80
  402.     nop
  403.     nop
  404.     nop
  405.     nop
  406.     nop
  407.     DB    0EAH,0F0H,0FFH,00H,0F0H    ;next time will start here
  408. ;
  409. ;
  410. ;------------------------ SUPPORT ROUTINES ---------------------------
  411. ;
  412. ;   ROUTINE TO PRINT A STRING   BX = START OF STRING  $ = FINISH
  413. ;
  414. print:    push    cx
  415. print1:    mov    al, [bx]    
  416.     inc    bx
  417.     cmp    al,'$'
  418.     jnz    print2
  419.     pop    cx
  420.     ret
  421. print2:    mov    cl,al
  422.     call    conout
  423.     jmp    print1
  424. ;
  425. ;    CHECK FOR ^S or ESC  AT CONSOL
  426. ctlchek: call    keystaa
  427.     cmp    al,0
  428.     jz    ctlexit
  429.     call    conin
  430.     cmp    al,'S'-40h
  431.     jnz    ctlcchek        ;possibly ^C
  432. wait:    call    csts
  433.     cmp    al,0
  434.     jz    wait
  435.     ret
  436. ctlcchek: cmp    al,esc
  437.     jz    err
  438. ctlexit: ret
  439. ;
  440. ;    SEND CRLF
  441. crlf:    push    cx
  442.     call    ctlchek
  443.     mov    cl,cr
  444.     call    conout
  445.     mov    cl,lf
  446.     call    conout
  447.     pop    cx
  448.     ret
  449. ;
  450. ;    PRINT A BLANK SPACE
  451. blank:    push    cx
  452.     mov    cx,1
  453.     call    tabs
  454.     pop    cx
  455.     ret
  456. ;
  457. ;    TABS            ;[cx] = no of spaces
  458. tabs:    push    cx
  459.     mov    cl,' '
  460.     call    conout
  461.     pop    cx
  462.     loop    tabs
  463.     ret
  464. ;
  465. ;    ERROR ABORT ROUTINE
  466. err:    mov    cl,'*'
  467.     call    conout
  468.     mov    sp,stackp
  469.     jmp    start
  470. ;
  471. ;    BINARY OUTPUT        ;send what is in [al]
  472. binout:    push    cx
  473.     mov    cx,8
  474. binout1: push    cx
  475.     shl    al,1
  476.     jb    bout1
  477.     mov    cl,'0'
  478.     push    ax
  479.     call    conout
  480.     pop    ax
  481.     jmp    binend
  482. bout1:    mov    cl,'1'
  483.     push    ax
  484.     call    conout
  485.     pop    ax
  486. binend:    pop    cx
  487.     loop    binout1
  488.     pop    cx
  489.     ret
  490. ;
  491. ;    HEXOUT            ;output the 2 hex digits in [al]
  492. hexout:    push    cx
  493.     push    ax
  494.     mov    cl,4        ;first isolate low nibble
  495.     shr    al,cl
  496.     call    hexdigout
  497.     pop    ax
  498.     call    hexdigout    ;get upper nibble
  499.     pop    cx
  500.     ret
  501. ;
  502. hexdigout: and    al,0fh        ;convert nibble to ascii
  503.     add    al,90h
  504.     daa
  505.     adc    al,40h
  506.     daa
  507.     mov    cl,al
  508.     call    conout
  509.     ret
  510. ;
  511. ;    HEXCHK            ;check for a valid HEX DIGIT
  512. hexchk:    sub    al,'0'        ;convert to binary if ok set carry if problem
  513.     jb    hret
  514.     cmp    al,0ah
  515.     cmc    
  516.     jnb    hret
  517.     sub    al,7
  518.     cmp    al,10
  519.     jb    hret
  520.     cmp    al,16
  521.     cmc
  522. hret:    ret
  523. ;
  524. ;    GETPARMB        ;get 20 bit parameter 16 bit value to bx. 
  525. getparmb: mov    bx,0        ;if 5 digits first to ds upper nibble
  526. loopb:    call    conin
  527.     cmp    al,'0'        ;alphanumeric?
  528.     jb    bexit
  529.     push    cx
  530.     push    bx        ;force the highest nibble to ds:
  531.     and    bx,0f000h
  532.     mov    ds,bx
  533.     pop    bx
  534.     mov    cl,4
  535.     shl    bx,cl        ;shift in last addition
  536.     pop    cx
  537.     call    hexchk        ;convert to binary and check it
  538.     jb    err
  539.     add    bl,al
  540.     loop    loopb
  541.     ret
  542. ;
  543. bexit:    cmp    al,' '        ;terminate with a sp or cr only
  544.     je    bgood
  545.     cmp    al,','
  546.     je    bgood
  547.     cmp    al,cr
  548.     je    bgood
  549.     jmp    err
  550. bgood:    mov    ah,al        ;save terminator
  551.     ret
  552. ;
  553. ;
  554. ;    SETUP            ;get parameters in bx & dx (cx not altered)
  555. setup:    push    cx        ;bx = dx if only one parameter
  556.     mov    cx,0ffffh
  557.     call    getparmb
  558.     cmp    ah,cr
  559.     je    set1
  560.     push    ds        ;save first ds
  561.     mov    dx,bx        ;store bx in dx for the moment
  562.     call    getparmb
  563.     xchg    bx,dx        ;set them in the right order
  564.     mov    ax,ds        ;save second ds
  565.     pop    cx        ;get back first ds put it in cx
  566.     cmp    ax,cx
  567.     jz    set2
  568.     jmp    err
  569. set1:    mov    dx,bx
  570. set2:    pop    cx
  571.     ret
  572. ;
  573. ;    CLENGTH            ;cx = (dx-bx)+1    if bx>dx err
  574. clength: push    dx
  575.     cmp    dx,bx
  576.     jnb    cl1
  577.     jmp    err
  578. cl1:    sub    dx,bx
  579.     mov    cx,dx
  580.     inc    cx        ;count = difference +1
  581.     pop    dx
  582.     ret
  583. ;
  584. ;    GETPARMAL        ;al <--- ascii hex from consol
  585. getparmal: push    bx        ;terminator in ah
  586.     push    cx
  587.     push    dx
  588.     mov    dl,al        ;store old value
  589.     mov    cx,0ffffh
  590.     call    getparmb
  591.     cmp    cx,0ffffh
  592.     jne    gquit        ;no change req if 0ffff
  593.     mov    bl,dl
  594. gquit:    mov    al,bl
  595.     pop    dx
  596.     pop    cx
  597.     pop    bx
  598.     ret
  599. ;
  600. ;    OUTBX            ;bx output as 4 hex digits
  601. outbx:    push    ax
  602.     mov    al,bh
  603.     call    hexout
  604.     mov    al,bl
  605.     call    hexout
  606.     pop    ax
  607.     ret
  608. ;    
  609. ;    OUTADD            ;send to console a crlf then address ds+bx
  610. outadd:    call    crlf
  611.     push    cx
  612.     mov    ax,ds
  613. outadd2:mov    cl,12
  614.     shr    ax,cl        ;get high nibble down
  615.     call    hexdigout
  616.     call    outbx
  617.     call    blank
  618.     pop    cx
  619.     ret
  620. ;
  621. outadd1:push    cx        ;same but send upper nibble of es reg
  622.     mov    ax,es
  623.     jmp    outadd2
  624. ;
  625. ;<<<<<<<<<<<<<<<<<<<<<< MAIN CONSOL OUTPUT ROUTINE >>>>>>>>>>>>>>>>>>>>>>>>>
  626. ;
  627. CO:    IN    AL,IOBYTE
  628.     TEST    AL,1H        ;BIT 0,A  CHECK IF OUTPUT TO LIST IS ALSO REQ
  629.     JZ    LOX
  630.     TEST    AL,10H        ;BIT 4,A  KILL LF'S IF THIS IS 0
  631.     JNZ    SDCONO
  632.     MOV    AL,CL
  633.     CMP    AL,LF
  634.     JZ    SDCON5        ;KILL LF'S
  635.     PUSH    CX        ;ALL OTHERE CHARACTERS SEND EOL THEN CHARACTER
  636.     MOV    CL,']'-40H    ;FOR CLEAR TO END OF LINE
  637.     CALL    SDCONO        ;BECAUSE EOL IS SENT FOR EACH CHARACTER THE
  638.     POP    CX        ;TYPE RATE IS NICELY SLOWED DOWN TO ~ 60 BAUD
  639.     JMPS    SDCONO        ;AT NO FURTHER EXPENSE |
  640. SDCON5:    MOV    AL,CL
  641.     RET
  642. ;
  643. LOX:    CALL    SDCONO        ;OUTPUT TO BOTH PRINTER & CONSOLE
  644.     JMP    LO
  645. ;
  646. SDCONO:    IN    AL,SDSTAT    ;SD SYSTEMS VIDIO BOARD PORT
  647.     AND    AL,4H
  648.     JZ    SDCONO
  649.     MOV    AL,CL
  650.     CMP    AL,07H        ;IS IT A BELL
  651.     JZ    BELL1
  652.     CMP    AL,0H        ;SD BOARD CANNOT TAKE A NULL
  653.     JNZ    LX2
  654.     RET
  655.  
  656. LX2:    OUT    SDDATA,AL
  657.     IN    AL,IOBYTE
  658.     TEST    AL,20H        ;BIT 5,A SEE IF TIME DELAY REQ WITH CO:
  659.     JNZ    LX3
  660.     MOV    AL,20
  661.     CALL    DELAY
  662. LX3:    MOV    AL,CL        ;MAKE SURE TO RETURN WITH [AL] CONTAINING CHAR
  663.     RET
  664.  
  665. ;
  666. BELL1:    MOV    AL,06H        ;SEND A BELL
  667.     OUT    SDDATA,AL
  668.     MOV    AL,1FH
  669.     CALL    DELAY
  670.     MOV    AL,CL
  671.     OUT    SDDATA,AL
  672.     RET
  673. ;
  674. ;
  675. DELAY:    DEC    AL        ;GENERAL COUNT DOWN TIME DELAY
  676.     JNZ    LX4    
  677.     RET            ;LENGTH SET IN [A]
  678. LX4:    PUSH    AX
  679.     MOV    AL,05H
  680. MORE:    DEC    AL
  681.     PUSH    AX
  682.     XOR    AL,AL
  683. MORE2:    DEC    AL
  684.     JNZ    MORE2
  685.     POP    AX
  686.     JNZ    MORE
  687.     POP    AX
  688.     JMPS    DELAY
  689. ;
  690. ;--
  691. ;<<<<<<<<<<<<<<<<<<< MAIN CONSOL STATUS ROUTINE >>>>>>>>>>>>>>>>>>>>>>
  692. ;
  693. CSTS:    IN    AL,KEYSTAT
  694.     AND    AL,02H
  695.     JNZ    CST1
  696.     RET                ;RETURN WITH 0 IN [A] IF NOTHING THERE
  697. CST1:    DEC    AL
  698.     RET                ;RETURN WITH 0FFH IN [A] IF SOMETHING
  699. ;
  700. ;
  701. ;<<<<<<<<<<<<<<<<<<<< MAIN CONSOL INPUT ROUTINE >>>>>>>>>>>>>>>>>>>>
  702. ;
  703. CI:    CALL    CSTS        ;NEED CONSTAT TO CLEAN UP SHIFT KEYS ETC
  704.     JZ    CI
  705.     IN    AL,KEYIN
  706.     AND    AL,7FH
  707.     RET
  708. ;
  709. ;<<<<<<<<<<<<<<<<<<<<<< MAIN PRINTER STATUS ROUTINE >>>>>>>>>>>>>>>>>>>>>>>>>
  710. ;
  711. LSTAT:    IN    AL,CENTSTAT        ;FIRST FIND WHICH PRINTER IS SELECTED
  712.     TEST    AL,2
  713.     JNZ    CENSTAT
  714.     TEST    AL,20H
  715.     JNZ    TRANSTAT
  716.     XOR    AL,AL            ;NONE SELECTED
  717.     DEC    AL
  718.     RET
  719.  
  720. CENSTAT:AND    AL,00001111B    ;XXXX0110 IS READY (BIT 3=PAPER BIT 2=FAULT
  721.     CMP    AL,00000110B        ;BIT 1=SELECT  BIT 0=BUSY
  722.     JZ    LSTAT1
  723.     XOR    AL,AL
  724.     RET
  725.  
  726. TRANSTAT:AND    AL,11110000B    ;0110XXX IS READY (BIT 7=ALERT BIT 6=FAULT
  727.     CMP    AL,01100000B        ;BIT 5=SELECT BIT 4=BUSY
  728.     JZ    LSTAT1
  729.     XOR    AL,AL
  730.     RET
  731.  
  732. LSTAT1:    XOR    AL,AL        ;PUT 0FFH IN [A] IF READY & NO ZERO FLAG
  733.     DEC    AL
  734.     RET
  735. ;
  736. ;<<<<<<<<<<<<<<<<<<<<<< MAIN PRINTER OUTPUT ROUTINE >>>>>>>>>>>>>>>>>>>>>>>>>
  737. ;
  738. LO:    CALL    LSTAT
  739.     JZ    LO
  740.     MOV    AL,0FFH
  741.     OUT    CENTSTROBE,AL
  742.     MOV    AL,CL
  743.     OUT    CENTOUT,AL
  744.     IN    AL,CENTSTAT
  745.     TEST    AL,2
  746.     JNZ    LCENT
  747.     TEST    AL,20H
  748.     JNZ    LTRANS
  749.     RET                ;NO STROBE SINCE NOT SELECTED
  750. ;
  751. LCENT:    MOV    AL,11111110B        ;STROBE FOR CENTRONICS
  752.     JMPS    OVERLS
  753. LTRANS:    MOV    AL,11111101B
  754. OVERLS:    OUT    CENTSTROBE,AL
  755.     MOV    AL,0FFH
  756.     OUT    CENTSTROBE,AL
  757.     RET
  758. ;
  759. ;
  760. ;--
  761. ;
  762. CICO:    CALL    CI        ;CONSOLE INPUT WITH ECHO ON CONSOLE + LC->UC
  763.     CMP    AL,' '
  764.     JB    CHECK        ;ACCEPT ONLY SP,ESC,CR,LF
  765.     CMP    AL,'a'
  766.     JB    CIC1
  767.     CMP    AL,'z'+1
  768.     JA    CIC1
  769.     AND    AL,5FH        ;THIS CONVERTS ALL LC->UC
  770. CIC1:    PUSH    AX
  771.     PUSH    CX
  772.     MOV    CL,AL
  773.     CALL    CO        ;DISPLAY ON CONSOLE
  774.     POP    CX
  775.     POP    AX
  776.     RET
  777. ;
  778. CHECK:    CMP    AL,CR
  779.     JZ    CIC1
  780.     CMP    AL,LF
  781.     JZ    CIC1
  782.     CMP    AL,ESC
  783.     JZ    CIC1
  784.     MOV    AL,BELL        ;SEND BELL TO INDICATE BAD DATA
  785.     JMP    CIC1
  786. ;
  787. ;
  788. ;        PRINT MENU ON CRT
  789. KCMD:    MOV    BX,offset MSG10
  790.     JMP    PRINT
  791. ;
  792. ;
  793. POO:    RET            ;NO PUNCH OUTPUT AT THE MOMENT
  794. RI:    MOV    AL,1AH        ;NO READER AT THE MOMENT
  795.     RET
  796. ;
  797. finish_code    equ    $
  798. ;
  799. eject
  800. ;
  801.     dseg    
  802.     org    offset    finish_code
  803. ;
  804. ;
  805. ctable    dw    map        ;A    ;gives a nice 1 mg byte memory map
  806.     dw    err        ;B
  807.     dw    err        ;C
  808.     dw    dump        ;D
  809.     dw    err        ;E
  810.     dw    fill        ;F
  811.     dw    goto        ;G
  812.     dw    hexmath        ;H
  813.     dw    err        ;I
  814.     dw    ntest        ;J
  815.     dw    KCMD        ;K
  816.     dw    err        ;L
  817.     dw    move        ;M
  818.     dw    err        ;N
  819.     dw    err        ;O
  820.     dw    err        ;P
  821.     dw    QUERY        ;Q
  822.     dw    err        ;R
  823.     dw    esubst        ;S
  824.     dw    dispas        ;T
  825.     dw    err        ;U
  826.     dw    verify        ;V
  827.     dw    err        ;W
  828.     dw    err        ;X
  829.     dw    err        ;Y
  830.     dw    Z80        ;Z
  831. ;
  832. ;
  833. signon    db    17H,11H,cr,lf,'8086 Monitor V2.1 (J. Monahan) 3/12/1983'
  834. CLEANUP    DB    1H,10H,11H,17H,07H,'$'
  835. comhead db    'ADDR  M  T       DIFF$'
  836. mhead    db    'SUM   DIFF$'
  837. vhead    db    'SRC   M   DEST  M  DIFF$'
  838. ;
  839. MSG10    DB       0DH,0AH
  840.     DB    'A',09H,'MEMMAP',0DH,0AH
  841.     DB    'D',09H,'DISPLAY MEMORY',0DH,0AH
  842.     DB    'F',09H,'FILL MEMORY',0DH,0AH
  843.     DB    'G',09H,'GOTO ADDRESS',0DH,0AH
  844.     DB    'H',09H,'HEX MATH',0DH,0AH
  845.     DB    'J',09H,'TEST MEMORY',0DH,0AH
  846.     DB    'K',09H,'LIST COMMANDS',0DH,0AH
  847.     DB    'M',09H,'MOVE MEMORY',0DH,0AH
  848.     DB    'Q',09H,'QUERY PORT',0DH,0AH
  849.     DB    'S',09H,'SUBSTITUTE MEMORY',0DH,0AH
  850.     DB    'T',09H,'TYPE ASCII',0DH,0AH
  851.     DB    'V',09H,'COMPARE MEMORY',0DH,0AH
  852.     DB    'Z',09H,'SWITCH IN Z80',0DH,0AH,'$'
  853. ;
  854.     cseg    
  855. ;        This is a bit tricky. My z80 places a far jump in 
  856. ;        low ram if the monitor is req (ie no cpm86) to the start 
  857. ;        of the monitor before transferring control over to the 
  858. ;        8086. You may want to jump directly to the start of the
  859. ;        monitor.
  860.  
  861.     ORG    0FFF0H
  862.     DB    0EAH,00H,05H,00H,00H    ;8086 WILL JUMP TO 0000:0500H
  863. ;
  864. ;        note I initilize an 8089 IO coprocessor 
  865. ;
  866.     ORG    0FFF6H
  867.     DB    01H,01H            ;8089 SET FOR 16 BIT MEMORY
  868.     DB    00H,04H,00H,00H        ;8089 WILL JUMP TO 0000:0400H
  869.                     ;WHERE IT WILL FIND ITS SYSTEM
  870.                     ;CONFIGURATION BLOCK
  871.  
  872.  
  873.