home *** CD-ROM | disk | FTP | other *** search
/ ftp.barnyard.co.uk / 2015.02.ftp.barnyard.co.uk.tar / ftp.barnyard.co.uk / cpm / walnut-creek-CDROM / CPM / NSTAR / NSUSER5Z.AQM / NSUSER5Z.ASM
Assembly Source File  |  2000-06-30  |  12KB  |  448 lines

  1. ;
  2. ;INDIVIDUAL I/O ROUTINES FOR CP/M-2 ON NORTHSTAR DD
  3. ;**************************************************
  4. ;    by Keith Petersen, W8SDZ
  5. ;      (revised July 4, 1981 by Bob Clyne)
  6. ;
  7. ;07/04/81  Added additional I/O drivers and changed to table selection
  8. ;       of drivers. (Bob Clyne)
  9. ;
  10. ;04/22/81  Changed some of the JUMP instructions to Z80 JUMP RELATIVEs
  11. ;       using Z80.LIB.  (Bob Clyne)
  12. ;
  13. ;04/21/81  Changed the list device status routine to use the code suggested
  14. ;       by Robert Halsall in the February 1981 issue of LIFELINES.
  15. ;       (Bob Clyne)
  16. ;
  17. ;03/15/81  Added check for illegal drive - currently set for a two drive
  18. ;       system. Changed clear screen character for Intertube. Added code
  19. ;       to list status routine to return with carry set if the printer is
  20. ;       busy.  (Bob Clyne)
  21. ;
  22. ;This is a special user area which allows output
  23. ;from the system to both the console and the
  24. ;TTY port when STAT'ed with the command:
  25. ;    STAT CON:=UC1:
  26. ;
  27. ;The command to output to just the TTY is:
  28. ;    STAT CON:=TTY:
  29. ;
  30. ;NOTE: Contents of IOBYTE (address 0003h)
  31. ;    0 = TTY output only
  32. ;    1 = CRT output only
  33. ;    3 = both TTY and CRT output
  34. ;
  35. ;The initialization in this version causes a cold
  36. ;boot to set CON:=CRT:.
  37. ;
  38. ;COLPT and COUL1 both output to the Horizon parallel port but the code is
  39. ;different. (RAC)
  40. ;
  41. ;Change MSIZE to the nominal system size desired
  42. ;
  43. MSIZE    EQU    58    ;<----58K SYSTEM SIZE----
  44. ;
  45. BIOS    EQU    5300H+(MSIZE-24)*1024
  46. USER    EQU    BIOS+700H    ;WHERE THE USER AREA STARTS
  47. OFFSET    EQU    2700H-USER    ;TO OVERLAY SYSGEN IMAGE
  48. IOBYTE    EQU    3        ;USE INTEL CONVENTION
  49. ;
  50. ;Define port assignments
  51. ;
  52. CRTS    EQU    03H    ;CRT STATUS PORT
  53. CRTD    EQU    02H    ;CRT DATA PORT
  54. CRTBE    EQU    01H    ;TBE MASK FOR CRT PORT
  55. KBDS    EQU    03H    ;CONSOLE KEYBOARD STATUS PORT
  56. KBDD    EQU    02H    ;CONSOLE KEYBOARD DATA PORT
  57. KBDDA    EQU    02H    ;RDA MASK FOR KBD PORT
  58. LSTS    EQU    05H    ;LIST STATUS PORT
  59. LSTD    EQU    04H    ;LIST DATA PORT
  60. LSTDA    EQU    02H    ;RDA MASK FOR LIST PORT
  61. LSTBE    EQU    01H    ;TBE MASK FOR LIST PORT
  62. MBSTATP    EQU    06H    ;MOTHERBOARD STATUS PORT - USED FOR PARALLEL PORT IO
  63. PARPT    EQU    00H    ;PARALLEL PORT
  64. PARINMSK EQU    02H    ;PARALLEL PORT INPUT CHAR AVAILABLE MASK
  65. PIFLGR     EQU    30H    ;PARALLEL PORT INPUT CHAR AVAIL. FLAG RESET
  66. PAROTMSK EQU    01H    ;PARALLEL PORT OUTPUT BUFFER EMPTY MASK
  67. POFLGR     EQU    20H    ;PARALLEL PORT OUTPUT BUFFER EMPTY FLAG RESET
  68. POSTROB     EQU    80H    ;PARALLEL PORT OUTPUT STROBE
  69. ;
  70. CLR    EQU    0CH    ;Intertec Intertube CLEAR SCREEN CHARACTER
  71. ;
  72. MACLIB Z80
  73. ;
  74. DRVS    EQU    02H    ;NUMBER OF DRIVES IN SYSTEM
  75. ;
  76.     ORG    USER    ;WHERE THE USER AREA STARTS
  77. ;
  78. ;The jump table following MUST be present in the correct sequence
  79. ;
  80. CINIT:    JMP    CINITR    ;COLD INIT I/O PORTS
  81.     JMP    CONST    ;CONSOLE STATUS
  82.     JMP    CONIN    ;CONSOLE INPUT
  83.     JMP    CONOUT    ;CONSOLE OUTPUT
  84.     JMP    LIST    ;LIST OUTPUT
  85.     JMP    PUNCH    ;PUNCH=CONSOLE OUTPUT
  86.     JMP    READER    ;READER=CONSOLE INPUT
  87. LSTAT:    JMP    LISTST    ;LIST STATUS
  88.     DB    0,0,0    ;RESERVED
  89.     DW    HORLEN    ;LENGTH OF THIS PROGRAM
  90.  
  91. CONST:    LXI    H,CSTBLE    ;BEGINNING OF JUMP TABLE
  92.     JR    CONIN1        ;SELECT CORRECT JUMP
  93.  
  94. CSREADR:LXI    H,CSRTBLE    ;BEGINNING OF READER STATUS TABLE
  95.     JR    READERA
  96.  
  97. CONIN:    LXI    H,CITBLE    ;BEGINNING OF CHARACTER INPUT TABLE
  98.  
  99. ;ENTRY AT CONIN1 WILL DECODE THE TWO LEAST SIGNIFICANT BITS OF IOBYTE.
  100. ;THIS IS USED BY CONIN, CONOUT, AND CONST.
  101.  
  102. CONIN1:    LDA    IOBYTE
  103.     RAL
  104.  
  105. ;Entry at SELDEV will form an offset into the table pointed to by HL and
  106. ;then pick up the address and jump there.
  107.  
  108. SELDEV:    ANI    06H        ;STRIP OFF UNWANTED BITS
  109.     MVI    D,0        ;FORM OFFSET
  110.     MOV    E,A
  111.     DAD    D        ;ADD OFFSET
  112.     MOV    A,M        ;PICK UP HIGH BYTE
  113.     INX    H
  114.     MOV    H,M        ;PICK UP LOW BYTE
  115.     MOV    L,A        ;FORM ADDRESS
  116.     PCHL
  117.  
  118. CONOUT:    LDA    0004H        ;GET DRIVE/USER NUMBER
  119.     ANI    0FH        ;ONLY LOOK AT DRIVE NUMBER
  120.     CPI    DRVS        ;IS IT GREATER THAN HIGHEST DRIVE ON LINE
  121.     JRC    CONOUT1        ;NO...THEN JUMP
  122.     XRA    A        ;SET DRIVE AND USER NUMBERS TO 0
  123.     STA    0004H        ;SAVE DRIVE 0 / USER 0
  124. CONOUT1:LXI    H,COTBLE    ;BEGINNING OF CHARACTER OUT TABLE
  125.     JR    CONIN1        ;DO THE DECODE
  126.  
  127. READER:    LXI    H,RTBLE        ;BEGINNING OF READER INPUT TABLE
  128.  
  129. ;Entry at READERA will decode bits 2 & 3 of IOBYTE, used by CSREADER
  130.  
  131. READERA:LDA    IOBYTE
  132.  
  133. ;Entry at READER1 will shift the bits into position, used by LIST and PUNCH.
  134.  
  135. READER1:RAR
  136.     JR    SELDEV
  137.  
  138. ;PUNCH:    Selects the correct punch device. The selection comes from bits
  139. ;4 & 5 of IOBYTE.
  140.  
  141. PUNCH:    LXI    H,PTBLE        ;BEGINNING OF PUNCH TABLE
  142.     LDA    IOBYTE
  143.  
  144. ;Entry at PNCH1 rotates bits a little more in prep for SELDEV, used by LIST.
  145.  
  146. PNCH1:    RAR
  147.     RAR
  148.     JR    READER1
  149.  
  150. ;LIST:    Select a list device based on bits 6 & 7 of IOBYTE.
  151.  
  152. LIST:    LXI    H,LTBLE        ;BEGINNING OF LIST DEVICE TABLE
  153. LIST1:    LDA    IOBYTE
  154.     RAR
  155.     RAR
  156.     JR    PNCH1
  157.  
  158. ;LISTST: Get the status of the currently assigned list device.
  159.  
  160. LISTST:    LXI    H,LSTBLE    ;BEGINNING OF THE LIST DEVICE STATUS
  161.     JR    LIST1
  162.  
  163. ;Console input table.
  164.  
  165. CITBLE:    DW    CITTY        ;Input from TTY (Horizon device 1 - right
  166.                 ;serial port, #4).
  167.     DW    CICRT        ;Input from CRT (Horizon device 0 - left
  168.                 ;serial port, #2).
  169.     DW    READER        ;Input from READER (depends on READER selection
  170.     DW    CIUC1        ;Input from User Console 1 (currently set to
  171.                 ;accept input from both CRT and TTY.
  172.  
  173. ;Console output table.
  174.  
  175. COTBLE:    DW    COTTY        ;Output to TTY, as above.
  176.     DW    COCRT        ;Output to CRT, as above.
  177.     DW    LIST        ;Output to list device (depends on bits 6 & 7
  178.                 ;of IOBYTE).
  179.     DW    COUC1        ;Same as input in table above.
  180.  
  181. ;List device table.
  182.  
  183. LTBLE:    DW    COTTY        ;Output to TTY.
  184.     DW    COCRT        ;Output to CRT.
  185.     DW    COLPT        ;Output to line printer (currently assigned to
  186.                 ;the Horizon device 2, parallel output port,
  187.                 ; port #2).
  188.     DW    COUL1        ;Output to user line printer (currently
  189.                 ;assigned to the alternate code for the
  190.                 ;Horizon device 2  parallel output port #0).
  191.  
  192. ;Punch device table.
  193.  
  194. PTBLE:    DW    COTTY        ;Output to TTY.
  195.     DW    COPTP        ;Output to paper tape punch (currently assigned
  196.                 ;to TTY).
  197.     DW    COUP1        ;Output to user punch 1 (currently assigned to
  198.                 ;user line printer 1).
  199.     DW    COUP2        ;Output to user punch 2 (currently assigned to
  200.                 ;line printer).
  201.  
  202. ;Reader device input table.
  203.  
  204. RTBLE:    DW    CITTY        ;Input from TTY.
  205.     DW    CIPTR        ;Input from paper tape reader (currently
  206.                 ;assigned to CRT).
  207.     DW    CIUR1        ;Input from user reader 1 (currently assigned
  208.                 ;to Horizon device 2 - parallel input port #0).
  209.     DW    CIUR2        ;Input from user reader 2 (currently assigned
  210.                 ;the same as CIUR1).
  211.  
  212. ;Console status table (input status ie. is character available?).
  213.  
  214. CSTBLE:    DW    CISTTY        ;Status of TTY.
  215.     DW    CISCRT        ;Status of CRT.
  216.     DW    CSREADR        ;Status of reader (depends on reader device
  217.                 ;assignment).
  218.     DW    CISUC1        ;Status of user console 1 (currently just
  219.                 ;returns status of TTY).
  220.  
  221. ;Status of reader device (input status ie. is character available?).
  222.  
  223. CSRTBLE:DW    CISTTY        ;Status of TTY.
  224.     DW    CISPTR        ;Status of paper tape reader (currently
  225.                 ;assigned to CRT).
  226.     DW    CISUR1        ;Status of user reader 1 (curently assigned to
  227.                 ;Horizon device 2 - parallel input port #0).
  228.     DW    CISUR2        ;Status of user reader 2 (currently assigned
  229.                 ;the same as CSUR1).
  230.  
  231. ;Status of the list device.
  232.  
  233. LSTBLE:    DW    COSTTY        ;Status of TTY.
  234.     DW    COSCRT        ;Status of CRT (currently always returns ready)
  235.     DW    COSLPT        ;Status of line printer (currently assigned to
  236.                 ;Horizon device 2, parallel output port,
  237.                 ;port #0).
  238.     DW    COSUL1        ;Status of the user line printer (currently
  239.                 ;assigned to the alternate code for the
  240.                 ;Horizon parallel output port).
  241.  
  242. ;CITTY:    Character in from TTY device - Horison device 1, the right serial port,
  243. ;    port #4.
  244.  
  245. CITTY:    IN    LSTS
  246.     ANI    LSTDA
  247.     JRZ    CITTY
  248.     IN    LSTD
  249.     ANI    7FH
  250.     JRZ    CITTY
  251.     RET
  252.  
  253. ;CICRT:    Character in from the CRT device - Horizon device 0, the left serial
  254. ;    port, port #2.
  255.  
  256. CIPTR:
  257. CICRT:    IN    KBDS
  258.     ANI    KBDDA
  259.     JRZ    CICRT
  260.     IN    KBDD
  261.     ANI    7FH
  262.     JRZ    CICRT
  263.     RET
  264.  
  265. ;CIUR1:    Character in from Horizon device 2, the parallel input port, port #0.
  266.  
  267. CIUR2:
  268. CIUR1:    IN    MBSTATP        ;GET MOTHERBOARD STATUS
  269.     ANI    PARINMSK    ;MASK FOR CHARACTER INPUT FLAG.
  270.     JRZ    CIUR1        ;LOOP IF NOTHING THERE.
  271.     IN    PARPT        ;GET THE CHARACTER
  272.     PUSH    PSW        ;SAVE IT
  273.     MVI    A,PIFLGR    ;RESET CODE FOR PARALLEL INPUT FLAG
  274.     OUT    MBSTATP        ;RESET THE FLAG
  275.     POP    PSW        ;RESTORE THE CHARACTER
  276.     RET
  277.  
  278. ;CIUC1:    Character in from either TTY or CRT.
  279.  
  280. CIUC1:    IN    LSTS
  281.     ANI    LSTDA
  282.     JRZ    CIUC1A
  283.     IN    LSTD
  284.     ANI    7FH
  285.     JRZ    CIUC1        ;IGNORE NULLS
  286.     RET
  287. CIUC1A:    IN    KBDS
  288.     ANI    KBDDA
  289.     JRZ    CIUC1
  290.     IN    KBDD
  291.     ANI    7FH
  292.     JRZ    CIUC1
  293.     RET
  294.  
  295. ;COTTY:    Character out to TTY - Horizon device 1, right serial port, port #4.
  296.  
  297. COPTP:
  298. COTTY:    IN    LSTS
  299.     ANI    LSTBE
  300.     JRZ    COTTY
  301.     MOV    A,C
  302.     ANI    7FH
  303.     OUT    LSTD
  304.     RET
  305.  
  306. ;COCRT:    Character out to CRT - Horizon device 0, left serial port, port #2.
  307.  
  308. COCRT:    IN    CRTS
  309.     ANI    CRTBE
  310.     JRZ    COCRT
  311.     MOV    A,C
  312.     ANI    7FH
  313.     RZ
  314.     CPI    7FH
  315.     RZ
  316.     OUT    CRTD
  317.     RET
  318.  
  319. ;COLPT:    Character out to lineprinter, Horizon device 2, parallel output port,
  320. ;    port #0. This code is essentially the same as that furnished by
  321. ;    Lifeboat in USER.ASM.
  322.  
  323. COUP2:
  324. COLPT:    IN    MBSTATP
  325.     ANI    PAROTMSK
  326.     JRZ    COLPT
  327.     MVI    A,POFLGR
  328.     OUT    MBSTATP
  329.     MOV    A,C
  330. TIN1:    ORI    80H        ;SET STROBE FALSE
  331.     OUT    PARPT        ;SEND CHARACTER
  332.     XRI    80H        ;TOGGLE STROBE
  333.     OUT    PARPT
  334.     XRI    80H        ;TOGGLE STROBE AGAIN
  335.     OUT    PARPT
  336.     ANI    7FH        ;MASK TO ASCII
  337.     RET
  338.  
  339.  
  340. ;COUL1:    Character out to user lineprinter 1, user punch 1, Horizon device 2,
  341. ;     parallel output port, port #0. This is alternate code similar to
  342. ;    that furnished by North Star in SOFT-DOC Revision 2.1.
  343.  
  344. COUP1:
  345. COUL1:    IN    MBSTATP
  346.     ANI    PAROTMSK
  347.     JRZ    COUL1
  348.     MOV    A,C        ;GET CHARACTER INTO ACCUMULATOR
  349.     OUT    PARPT        ;SEND IT
  350.     MVI    A,POFLGR    ;PARALLEL OUTPUT FLAG RESET
  351.     OUT    MBSTATP        ;SEND IT TO MOTHERBOARD STAUS PORT
  352.     MOV    A,C        ;GET CHARACTER BACK IN THE ACCUMULATOR.
  353.     RET
  354.  
  355. ;COUC1:    Character out to user console 1, currently outputs to both TTY & CRT.
  356.  
  357. COUC1:    CALL    COTTY
  358.     JR    COCRT
  359.  
  360. ;CISTTY:    Input status for TTY ie is a character available?
  361.  
  362. CISTTY:    IN    LSTS
  363. CSCOM:    RRC
  364. CSCOM1:    RRC
  365.     SBB    A
  366.     RET
  367.  
  368. ;CISCRT:    Input status for CRT ie is a character available?
  369.  
  370. CISPTR:
  371. CISCRT:    IN    KBDS
  372.     JR    CSCOM
  373.  
  374. ;CISUC1:    Input status for user console 1, checks for a character ready
  375. ;        on either the CRT or TTY.
  376.  
  377. CISUC1:    CALL    CISTTY        ;CHECK FOR CHARACTER WAITING ON TTY
  378.     RNZ            ;CHARACTER THERE, RETURN
  379.     JR    CISCRT        ;GO CHECK FOR CHARACTER AT CRT
  380.  
  381. ;CISUR1:    Input status for user reader 1, Horizon device 2, parallel
  382. ;        output port, port #0.
  383.  
  384. CISUR2:
  385. CISUR1:    IN    MBSTATP
  386.     JR    CSCOM
  387.  
  388. ;COSCRT:    Output status of CRT device, always returns ready.
  389.  
  390. COSCRT:
  391. READY:    MVI    A,0FFH
  392.     RET
  393.  
  394. ;COSTTY: Status of TTY device for output. Returns 0 in ACC and Z and C flags
  395. ;     set if not ready and 0FFH in ACC and Z and C flags reset if ready.
  396.  
  397. COSUC1:
  398. COSTTY:    IN    LSTS
  399. COSCOM:    RRC            ;Rotate the status bit to the carry bit
  400.     SBB    A        ;Subtract the ACC from itself the subtract the
  401.                 ;carry bit.
  402.     CMC            ;WORDSTAR expects carry set if NOT ready
  403.     RET
  404.  
  405.  
  406. ;CSUL1:    Status of user line printer, Horizon device 2, parallel output port,
  407. ;    port #0.
  408.  
  409. COSLPT:
  410. COSUL1:    IN    MBSTATP
  411.     JR    COSCOM
  412.  
  413. ;Cold initialization
  414. ;
  415. CINITR:    MVI    A,01H    ;SETS CON:=CRT:
  416.     STA    IOBYTE
  417.     XRA    A    ;INIT MOTHER BOARD
  418.     OUT    6
  419.     OUT    6
  420.     OUT    6
  421.     OUT    6
  422.     MVI    A,0C1H    ;INIT MEMORY BOARDS
  423.     OUT    0C0H
  424. ;Set up serial ports
  425. ;0CEH sets 2 stop bits, 16X clock, 8 bits, no parity
  426. ;4EH sets 1 stop bit, 6X clock, 8 bits, no parity
  427. ;    MVI    A,0CEH    ;FOR 2 STOP BITS (COMMENTED OUT)
  428.     MVI    A,4EH    ;FOR 1 STOP BIT
  429.     OUT    3    ;TO FIRST SERIAL PORT
  430.     OUT    5    ;TO SECOND SERIAL PORT
  431.     MVI    A,37H    ;CMMD: RTS ER RXF DTR TXEN
  432.     OUT    3    ;FIRST PORT
  433.     OUT    5    ;SECOND PORT
  434.     IN    2    ;CLEAR INPUT BUFFERS
  435.     IN    4    ;ON BOTH SERIAL PORTS
  436.     MVI    A,CLR    ;SCREEN CLEAR
  437.     OUT    2    ;TO FIRST PORT
  438. ;Set up parallel port
  439.     MVI    A,30H
  440.     OUT    6    ;RESET PARALLEL PORT PI FLAG
  441.     MVI    A,60H    ;CODE TO SET PO FLAG
  442.     OUT    6
  443.     RET
  444. ;
  445. HORLEN:    EQU    $-USER    ;LENGTH
  446. ;
  447.     END
  448.