ibmunv.inc
上传用户:xiaoan1112
上传日期:2013-04-11
资源大小:19621k
文件大小:16k
源码类别:

操作系统开发

开发平台:

Visual C++

  1. ;***
  2. ;ibmunv.inc - 20-Mar-86
  3. ;***
  4. .XLIST
  5. ;***
  6. ;
  7. ; Copyright <C> 1986, Microsoft Corporation
  8. ;
  9. ;Purpose:
  10. ;
  11. ;******************************************************************************
  12. ;******************************************************************************
  13. ; Chess ROS I/O Macro Definitions for the IBM PC
  14. ;******************************************************************************
  15. ; VECTOR INTERRUPT EQUATES
  16. ;******************************************************************************
  17. I_SCNIO=10H  ;VIDEO_IO
  18. I_CASIO=15H  ;CASSETTE_IO
  19. I_KYBIO=16H  ;KEYBOARD_IO
  20. I_PTRIO=17H  ;PRINTER_IO
  21. I_DOSIO=21H  ;MSDOS_IO
  22. ;******************************************************************************
  23. ; ROS MONITOR INTERRUPT CALL MACRO DEFINITIONS
  24. ;******************************************************************************
  25. ; The ROSMAC macro is used to define other macros. These new macros can then
  26. ; be used to access the IBM ROM bios level services. Refer to the IBM TechRef
  27. ; Manual for additional information.
  28. ROSMAC MACRO NAM,REG
  29. NAM MACRO FUNC
  30. IFNB <REG>
  31. PUSH BP
  32. PUSH SI
  33. PUSH DI
  34. ENDIF ;IFNB <REG>
  35. IFNB <FUNC>
  36. MOV AH,FUNC
  37. ENDIF ;IFNB <FUNC>
  38. INT I_&NAM
  39. IFNB <REG>
  40. POP DI
  41. POP SI
  42. POP BP
  43. ENDIF ;IFNB <REG>
  44. ENDM ;&NAM MACRO
  45. ENDM ;ROSMAC MACRO
  46. ; The SCNIOS macro is used to save a bit of code. Invoking this macro
  47. ; causes a call to the B$SCNIO routine rather than invoking the SCNIO
  48. ; macro directly. This saves 3 PUSHes and 3 POPs for all screen
  49. ; related activity.
  50. SCNIOS MACRO FUNC ;;VIDEO_IO
  51. IFNB <FUNC>
  52. MOV AH,FUNC
  53. ENDIF
  54. CALL B$SCNIO
  55. ENDM
  56. KYBIO macro func ;;[1]
  57. PUSH BP ;;[1]
  58. PUSH SI ;;[1]
  59. PUSH DI ;;[1]
  60. ifnb <func> ;;[1]
  61. MOV AH,FUNC ;;[1]
  62.   ifndef b$RcoFlg ;;[1]
  63. extrn b$RcoFlg:byte ;;[1]
  64.   endif ;;[1] ifndef
  65. OR AH,b$RcoFlg ;;[1] b$RcoFlg is either 0 or 10H in DOS3
  66. endif ;;[1] ifnb <func>
  67. INT I_KYBIO ;;[1]
  68. POP DI ;;[1]
  69. POP SI ;;[1]
  70. POP BP ;;[1]
  71. ENDM ;;[1] KYBIO
  72. ROSMAC SCNIO,R ;;VIDEO_IO
  73. ROSMAC CASIO ;;CASSETTE_IO
  74. ROSMAC PTRIO,R ;;PRINTER_IO
  75. ROSMAC DOSIO ;;MSDOS_IO
  76. ;******************************************************************************
  77. ; BIOS Video Support Functions (use with SCNIO macro):
  78. ;******************************************************************************
  79. vSetMode EQU 0 ;set screen mode
  80. vSetCursorType EQU 1 ;set cursor type
  81. vSetCursorPos EQU 2 ;set cursor position
  82. vReadCursorPos EQU 3 ;read cursor position
  83. vReadLightPen EQU 4 ;read light pen position
  84. vSelActivePage EQU 5 ;select active display page
  85. vScrollPageUp EQU 6 ;scroll active page up
  86. vScrollPageDown EQU 7 ;scroll active page down
  87. vReadChar EQU 8 ;read character and attribute
  88. vWriteChar EQU 9h ;write character and attribute
  89. vWriteCharOnly EQU 0ah ;write character only
  90. vSetPalette EQU 0bh ;set color palette
  91. vWritePixel EQU 0ch ;write pixel to screen
  92. vReadPixel EQU 0dh ;read pixel from screen
  93. vWriteTTY EQU 0eh ;write tty to active page
  94. vGetVideoState EQU 0fh ;gets current video state
  95. vSetEgaPalette EQU 010h ;set palette registers
  96. vCharGen EQU 011h ;character generator routine
  97. vAltSelect EQU 012h ;alternate select - get ega info
  98. vWriteString EQU 013h ;write string to screen
  99. vGetVgaInfo EQU 01bh ;[5]get vga information
  100. ;******************************************************************************
  101. ; BIOS Cassette Support Functions (use with CASIO macro):
  102. ;******************************************************************************
  103. cMotorOn EQU 0 ;turn cassette motor on
  104. cMotorOff EQU 1 ;turn cassette motor off
  105. cReadCassette EQU 2 ;read block from cassette device
  106. cWriteCassette EQU 3 ;write block to cassette device
  107. ;******************************************************************************
  108. ; BIOS Keyboard Support Functions (use with KYBIO macro):
  109. ;******************************************************************************
  110. kReadKeyboard EQU 0 ;read character from keyboard
  111. kPollKeyboard EQU 1 ;poll keyboard for presence of character
  112. kReadShiftKeys EQU 2 ;get status of shift keys
  113. ;******************************************************************************
  114. ; BIOS Printer Support Functions (use with PTRIO macro):
  115. ;******************************************************************************
  116. lptPrintChar EQU 0 ;print character on printer
  117. lptInitPrinter EQU 1 ;initialize printer device
  118. lptReadStatus EQU 2 ;read status of printer device
  119. ;******************************************************************************
  120. ; BIOS RS232C COM Port Support Functions:
  121. ;******************************************************************************
  122. comInitPort EQU 0 ;initialize COM port
  123. comSendByte EQU 1 ;send byte to COM port
  124. comRecByte EQU 2 ;receive byte from COM port
  125. comGetStatus EQU 3 ;get COM port status info
  126. ;******************************************************************************
  127. ; Interrupts / Interrupt Vectors / I/O Ports / Misc Constants
  128. ; The following Offsets are for Cells assuming DS:0
  129. ;******************************************************************************
  130. ; Timer Constants:
  131. TIMINT = 8H ;timer interrupt
  132. CLKINT = 20h ;X'20' Clock Interrupt Vector
  133. CLKVEC = 3C0h ;X'3C0' (ROM) Clock Interrupt vector
  134. ROMCLK = 240 ;ROM Clock Interrupt number
  135. TIMADR = 70H ;X'70' Timer Int Vector
  136. TICSAV = 512H ;X'512-515' Clock Int Vec save area
  137. TMRCTL = 1CH ;timer control interrupt
  138. TIMER0 = 40h ;X'40' Timer 0 Port Address
  139. TIMER2 = 42h ;X'42' Timer 2 Port Address
  140. TMRCMD = 43h ;X'43' Timer Control Port
  141. ; 8259 constants:
  142. INTA0 = 20h ;X'20' 8259 Interrupt Control Port
  143. INTA1 = 21H ;8259 Interrupt Mask Register Port
  144. EOI = 20h ;X'20' 8259 End-of-Interrupt ACK
  145. MSKREG = 21H ;8259 interrupt mask register
  146. ; Joystick Event Constants:
  147. GAMECD = 201H ;Game Card I/O address
  148. TRIG_A1 = 10H ;Trigger 'A1' Mask, Active Low
  149. TRIG_A2 = 20H ;Trigger 'A2' Mask, Active Low
  150. TRIG_B1 = 40H ;Trigger 'B1' Mask, Active Low
  151. TRIG_B2 = 80H ;Trigger 'B2' Mask, Active Low
  152. ; Music / Sound constants:
  153. SPEAKER = 61h ;X'61' Speaker Latch Port Address.
  154. SpkrOn = 3 ;Speaker On Mask
  155. SpkrEn = 10h ;Speaker Enable/Disable Mask
  156. SQUARE = 0B6h ;X'B6' Timer 2, Square Wave (Mode 3).
  157. SND_MAX = 32 ;Max number of Notes Que can hold
  158. TIADDR = 0C0H ;X'C0' TI sound chip address
  159. ; Keyboard Constants:
  160. KBDINT = 24H ;X'24' Keyboard Interrupt Vector
  161. KBDVEC = 3BCH ;X'3BC' (ROS) KBD Int Vector
  162. KYBINT = 9H ;keyboard interrupt
  163. ROMKBD = 239D ;ROM KBD INT vectors saved at 239*4
  164. KBDFLG = 417H ;keyboard special status flag
  165. KBDATA = 60H ;keyboard data
  166. ; Screen related constants:
  167. PALSIZ = 16 ;palette size
  168. CHREXT = 7Ch ;X'7C' Extended Character Set pointer.
  169. CRT_LEN = 44Ch ;[12] crt page length
  170. CRT_START= 44eh ;crt start address
  171. ACTIVE_PAGE = 462H ;[4] Active page# is stored here by BIOS
  172. BIOS_CursorPos = 450H ;[9]start of BIOS cursor position table
  173. CGA_STATUS = 3DAH ;[9]CGA card status port
  174. VERT_SYNC = 8 ;[9] 1 on status port means vertical sync
  175. HORZ_SYNC = 1 ;[9] 1 on status port means horizontal sync
  176. MEMRIO = 23Ch ;Port for MS Jr Booster Card signature byte
  177. CR = 13D ;ASCII carriage return
  178. LF = 10D ;ASCII  line feed
  179. BiosEquip= 410h ;bios equipment register
  180. ;[7] This macro is used to choose between word OUTs and byte OUTs when
  181. ;[7] writing to the EGA card.  The routine B$OutWord does the equivalent
  182. ;[7] of a word out 1 byte at a time because of rumoured problems with
  183. ;[7] word OUTs.  Currently, the AT&T 6300 is the only machine known to
  184. ;[7] have problems with word OUTs.  If it is decided that the speed gained
  185. ;[7] by using word OUTs is more important than supporting the AT&T thing,
  186. ;[7] change this macro and remove B$OutWord from LLCGRP.
  187. OutWord MACRO
  188. CALL B$OutWord ; or this line can read "OUT DX,AX"
  189. ; OUT DX,AX ; or this line can read "CALL B$OutWord"
  190. ENDM
  191. ; EGA (Enhanced Graphics Adapter) constants:
  192. OFFSCN=6D60H  ;first even off-screen location
  193. ;we need an off-screen location in
  194. ; video memory for writing a tiling
  195. ; pattern
  196. ; Accessing screen memory through the EGA card is handled by reading
  197. ; or writing either directly from/to memory or through a set of latch
  198. ; registers which represent each of the four color memory planes which
  199. ; are supported.  This access is controlled by sending information in
  200. ; the form of binary numbers or bit patterns to the data port associated
  201. ; with the graphics registers. The graphics register selected to receive
  202. ; the data is specified as an offset index, this offset being written to
  203. ; an address port associated with a particular data port.
  204. ; The following definitions and routines are a convenient means for
  205. ; coding these staged interactions with the hardware.
  206. ; Addresses of, or offsets to, registers used :
  207. ; SEQUENCER -----------------------------------------------------
  208. SEQADD=3C4H  ;sequencer address register(takes index)
  209. SEQDAT=3C5H  ;sequencer data port (receives data for
  210. ; register indexed above)
  211. MMREG=2 ;offset to map mask register
  212. ;/ ENABLES PLANES 0-3
  213. ;/ FOR 32-BIT WRITE
  214. MMDREG=4  ;memory mode register
  215. ; GRAPHICS --------------------------------------------------------
  216. GRPADD=3CEH  ;graphics address register
  217. GRPDAT=3CFH  ;graphics data port
  218. SRSREG=0  ;set/reset register
  219. ;/ IF WRITE MODE 0, BINARY
  220. ;/ VALUE OF COLOR TO WRITE
  221. ENBREG=1  ;enable set/reset register
  222. ;/ BITS 0-3 ENABLE PLANES
  223. ;/ FOR WRITING FROM SETRES
  224. ;/ IF 0, WRITE IS FROM
  225. ;/ PROCESSOR DATA
  226. CLCREG=2  ;color compare register
  227. ;/ BITS 0-3 ARE COLOR VALUE
  228. ;/ TO BE COMPARED
  229. DTRREG=3  ;data rotate register
  230. ;/ BITS 0-2 = POSITIONS TO
  231. ;/ ROTATE FOR WRITE
  232. ;/ BITS 3-4 = LOGICAL OPS
  233. ;/ WITH LATCHED DATA
  234. RMPREG=4  ;read map select register
  235. ;/ BINARY REP OF PLANE FOR
  236. ;/ READ
  237. RWMREG=5  ;read/write mode register
  238. ;/ WRITES : BITS 1 0
  239. ;/ 00 = DATA WRITE FROM
  240. ;/ PROCESSOR OR SET-RESET
  241. ;/ 01 = LATCH WRITE
  242. ;/ 10 = BYTE <-- COLOR
  243. ;/ READS : BIT 3
  244. ;/ 0 = READ FROM PLANE
  245. ;/ SPECIFIED BY READMP
  246. ;/ 1 = COMPARE PIXEL COLOR
  247. ;/ WITH COLOR COMPARE
  248. ;/ ODD/EVEN : BIT 4
  249. ;/ 1 = ODD/EVEN ADDRESS MODE
  250. CDCREG=7  ;color don't care register
  251. ;/ BITS 0 - 3 REPRESENT 4
  252. ;/ PLANES; 0 SPECIFIES IGNORE
  253. ;/ PLANE WHEN DOING COLOR
  254. ;/ COMPARE READ
  255. BMKREG=8  ; bit mask register
  256. ;/ BITS 0 - 7 WHEN SET TO
  257. ;/ 0 PROTECT BIT FROM WRITE
  258. ; ATTRIBUTE -----------------------------------------------------
  259. ATTADD=3C0H  ;attribute address register - used also for data
  260. ;via alternating OUTs
  261. ;[8] Constants and macros used by EGAINT10 interface.
  262. EGAINT MACRO FUNC ;[8]run EGA outs through egaint10 interface
  263. IFNB <FUNC>
  264. MOV AH,FUNC
  265. ENDIF
  266. INT 10H
  267. ENDM
  268. EGAINT10CLI MACRO ;[8]disable interrupts if HG_EGAINT10
  269. ENDM
  270. EGAINT10STI MACRO ;[8]enable interrupts if HG_EGAINT10
  271. ENDM
  272. ; COM port constants:
  273. IRQ3 = 11d*4 ;COM2 interrupt level - Int loc for COM card @ 2xxh
  274. IRQ4 = 12d*4 ;COM1 interrupt level - Int loc for COM card @ 3xxh
  275. RS232B = 400H ; X'400' RS232 Card(s) I/O addr Save area.
  276. RDAIE = 1 ; Read Data Available   Interrupt Enable
  277. TBEIE = 2 ; Transmit Buffer Empty Interrupt Enable
  278. MSRIE = 8 ; Modem Status          Interrupt Enable
  279. CTS = 10H ;Clear To Send
  280. DSR = 20H ;Data Set Ready
  281. RLSD = 80H ;Received Line Signal Detect (CD)
  282. XMIT_BUF_SIZE = 80H ;[6] length of output buffer
  283. PAGE
  284. ;******************************************************************************
  285. ; enable and disable
  286. ;******************************************************************************
  287. ENABLE EQU STI
  288. DISABLE EQU CLI
  289. ;******************************************************************************
  290. ; The PAUSE macro is required because a number of Intel's early 286 processors
  291. ; had defects. The PAUSE macro is required whenever there is a number of
  292. ; IN and OUT instructions in close proximity to each other.
  293. ; This macro insures that an instruction fetch occurs between IN and/or OUT
  294. ; instructions on the IBM PC AT machine.
  295. ; Note: OEMs should be able to disregard this macro by removing the JMP
  296. ; instruction.
  297. ;******************************************************************************
  298. PAUSE MACRO ;macro to insure that an instruction
  299. JMP $+2 ;fetch occurs between IN and/or OUT
  300. ENDM ;instructions on the IBM PC AT machine
  301. ;***************************************************************************
  302. ;
  303. ;       8086 Interrupt Handling Macros
  304. ;       MS-DOS 1.0 does not have INT 21 to GET a vector
  305. ;       hence SAVINT just moves interrupts around.
  306. ;
  307. ;***************************************************************************
  308. SVINT MACRO   savloc,intloc,reg
  309. IFB <reg>
  310. SVINT savloc,intloc,AX
  311. ELSE
  312. MOV reg,intloc
  313. MOV savloc,reg
  314. MOV reg,intloc+2
  315. MOV savloc+2,reg
  316. ENDIF
  317. ENDM
  318. ;****************************************************************************
  319. ;
  320. ; The following macros use the MS-DOS INT 21 call to change
  321. ; interrupt vectors.
  322. ;
  323. ;****************************************************************************
  324. savint macro savloc,intvec 
  325. MOV AX,3500H+INTVEC/4 ;;[2]AH=get int - AL=interrupt number
  326. int 21h
  327. mov word ptr savloc,bx ;;savloc = offset
  328. mov word ptr savloc+2,es ;;savloc+2 = segment
  329. endm
  330. setvec macro interrupt,offset_adr ;;set interrupt vector function call
  331. mov dx,offset offset_adr
  332. MOV AX,2500H+INTERRUPT ;;[2]AH=set int call - AL=interrupt
  333. int 21h
  334. endm
  335. rstvec macro interrupt,save_adr ;;restore interrupt from saved
  336. lds dx,dword ptr save_adr
  337. MOV AX,2500H+INTERRUPT ;;[2]AH=set int call - AL=interrupt
  338. int 21h
  339. endm
  340. XFRINT MACRO TOINT,FROMINT ;;move FROMINT to TOINT
  341. PUSH ES ;;save register...
  342. MOV AX,3500H+FROMINT ;;want to get FROMINT
  343. INT 21H ;;vector now in ES:BX
  344. MOV AX,ES ;;keep segment around
  345. POP ES ;;restore register...
  346. MOV DX,BX ;;move offset for put
  347. PUSH DS ;;save register...
  348. MOV DS,AX ;;segment for put
  349. MOV AX,2500H+TOINT ;;want to put TOINT
  350. INT 21H ;;vector now in DS:DX
  351. POP DS ;;restore register
  352. ENDM
  353. ;******************************************************************************
  354. ; Queue Structures for music and communications
  355. ;******************************************************************************
  356. ; This queue structure is used by the MUSIC queues and
  357. ; the COM buffer queues (both input and output). The
  358. ; field QUNOTE is not used by the COM buffer queues
  359. ; but will be present as a dummy field so that the same
  360. ; queue manipulation routines may be used.
  361. ;******************************************************************************
  362. QUE_CTRL_BLOCK STRUC
  363. QUNOTE DW ? ; Number of notes in Bkgnd queue
  364. QUETOP DW ? ; Top of Queue Location
  365. QUEBOT DW ? ; Bot of Queue Location
  366. QUELEN DW ? ; Length of Queue
  367. QUENUM DW ? ; Number of bytes in Que
  368. QUEGET DW ? ; Queue get pntr
  369. QUEPUT DW ? ; Queue put pntr
  370. QUE_CTRL_BLOCK ENDS
  371. QUSIZE = SIZE QUE_CTRL_BLOCK
  372. QLENTH = 32*6 ;room for 32 notes (exactly)
  373. QUE_CTRL_LEN = QUSIZE ;Length of Queue Control Block
  374. SPCSIZ= QLENTH+16*3 ;non-IBMPCJr queue size
  375. ;one full size; two 16-byte
  376. ;for SYNC's; NOISE queue
  377. HALSIZ= QLENTH*3+QLENTH/2 ;PC Jr queue size; Three full
  378. ;size queues; half size
  379. ;queue for noise
  380. ;******************************************************************************
  381. ; EQUates for $DONOTE input value in AL
  382. ; The value of these equates is quite important as $DONOTE depends on
  383. ; them.
  384. ; Function codes to be passed to B$DONOTE
  385. ;******************************************************************************
  386. QUERST=0D ;[3] Queue an internote pause (rest)
  387. QUENOT=1D ;[3] Queue a note
  388. TSTVOC=2D ;[3] Test if voice is active
  389. QUESYN=3D ;[3] Queue synchronization mark
  390. SETESH=4D ;[3] Queue an envelope shape request
  391. SETEPR=5D ;[3] Queue an envelope period request
  392. MKNOIS=6D ;[3] Support NOISE statement
  393. SNDONF=252D ;[3] SOUND ON/OFF
  394. BEPONF=253D ;[3] BEEP  ON/OFF
  395. STRSND=254D ;Start sound
  396. STPSND=255D ;Stop sound and flush the queues
  397. DFLVOL=-1 ;[3] Default Volume (-1)
  398. ;******************************************************************************
  399. .LIST