home *** CD-ROM | disk | FTP | other *** search
/ Phoenix CD 2.0 / Phoenix_CD.cdr / 01e / miscutil.zip / BIOS.MAC < prev    next >
Text File  |  1986-03-03  |  9KB  |  493 lines

  1. ;
  2. ;            BIOS Macros
  3. ;
  4. ;    These macros define the indeterfaces to the BIOS.  These macros aid in
  5. ; making calls to BIOS from other assembly language routines.  These macros
  6. ; provide the complete interface to the particular BIOS function.
  7. ;
  8. ;
  9. ;        LDREG
  10. ;
  11. ;    This macro is an "inner" macro for the use by the BIOS interface macros.
  12. ; It allows the caller of a macro to specify a register or a literal value as
  13. ; the parameter to the macro.  This macro loads the correct register specified
  14. ; by the caller of the macro with the contents of the register, literal or
  15. ; memory location also specified.  No code will be generated if the two
  16. ; parameters are the same.
  17. ;
  18. ldreg        macro        destreg,source
  19.         ifdif        <destreg>,<source>
  20.         mov        destreg,source
  21.         endif
  22.         endm
  23. ;
  24. ;        TSTNSET
  25. ;
  26. ;    This macro will compare the value of two fields, if they are equal the
  27. ; third parameter will be OR'd into AL.
  28. ;
  29. tstnset     macro        src1,src2,orval
  30.         ifidn        <src1>,<src2>
  31.         or        al,orval
  32.         endif
  33.         endm
  34. ;
  35. ;        IRS232
  36. ;
  37. ;    This macro will generate a call to BIOS to initialize the RS232 port.
  38. ;
  39. irs232        macro        initparms,linenum
  40.         ldreg        dx,linenum
  41.         ldreg        al,initparms
  42.         mov        ah,0
  43.         int        14h
  44.         endm
  45. ;
  46. ;        IRS232A
  47. ;
  48. ;    This macro will generate a call to BIOS to initialize the RS232 port.
  49. ; This macro allows the fields to be specified that initialize the port.
  50. ;
  51. irs232a     macro        baudrate,parity,stopbits,datalen,linenum
  52.         ldreg        dx,linenum
  53.         sub        ax,ax
  54. ;        tstnset     baudrate,110,00000000b
  55.         tstnset     baudrate,150,00100000b
  56.         tstnset     baudrate,300,01000000b
  57.         tstnset     baudrate,600,01100000b
  58.         tstnset     baudrate,1200,10000000b
  59.         tstnset     baudrate,2400,10100000b
  60.         tstnset     baudrate,4800,11000000b
  61.         tstnset     baudrate,9600,11100000b
  62. ;        tstnset     parity,none,00000000b
  63.         tstnset     parity,odd,00001000b
  64.         tstnset     parity,even,00011000b
  65. ;        tstnset     stopbits,1,00000000b
  66.         tstnset     stopbits,2,00000100b
  67.         tstnset     datalen,7,00000010b
  68.         tstnset     datalen,8,00000011b
  69.         int        14h
  70.         endm
  71. ;
  72. ;        SENDCHR
  73. ;
  74. ;    This macro will send a character over the RS232 line.
  75. ;
  76. sendchr     macro        char,linenum
  77.         ldreg        dx,linenum
  78.         ldreg        al,char
  79.         mov        ah,1
  80.         int        14h
  81.         endm
  82. ;
  83. ;        RECVCHR
  84. ;
  85. ;    This macro will recieve a character from the RS232 line.
  86. ;
  87. recvchr     macro        linenum
  88.         ldreg        dx,linenum
  89.         mov        ah,2
  90.         int        14h
  91.         endm
  92. ;
  93. ;        COMSTAT
  94. ;
  95. ;    This macro will get the status of the RS232 line.
  96. ;
  97. comstat     macro        linenum
  98.         ldreg        dx,linenum
  99.         mov        ah,3
  100.         int        14h
  101.         endm
  102. ;
  103. ;        GETKBCHAR
  104. ;
  105. ;    This macro will get a character from the keyboard.
  106. ;
  107. getkbchar    macro
  108.         mov        ah,0
  109.         int        16h
  110.         endm
  111. ;
  112. ;        TSTKBCHAR
  113. ;
  114. ;    This macro will test to see if a character is available from the keybd.
  115. ;
  116. tstkbchar    macro
  117.         mov        ah,1
  118.         int        16h
  119.         endm
  120. ;
  121. ;        GETKBSHIFT
  122. ;
  123. ;    This macro will get the keyboard shift state.
  124. ;
  125. getkbshift    macro
  126.         mov        ah,2
  127.         int        16h
  128.         endm
  129. ;
  130. ;        DSKRESET
  131. ;
  132. ;    This macro will reset the diskette controller.
  133. ;
  134. dskreset    macro
  135.         mov        ah,0
  136.         int        16h
  137.         endm
  138. ;
  139. ;        GETDSKSTAT
  140. ;
  141. ;    This macro will get the diskette status of the last operation performed.
  142. ;
  143. getdskstat    macro
  144.         mov        ah,1
  145.         int        16h
  146.         endm
  147. ;
  148. ;        DSKREAD
  149. ;
  150. ;    This macro will read from the diskette.
  151. ;
  152. dskread     macro        drive,head,track,sector,numsecs,buffoff
  153.         ldreg        dl,drive
  154.         ldreg        dh,head
  155.         ldreg        ch,track
  156.         ldreg        cl,sector
  157.         ldreg        al,numsecs
  158.         ldreg        bx,buffoff
  159.         mov        ah,2
  160.         int        16h
  161.         endm
  162. ;
  163. ;        DSKWRITE
  164. ;
  165. ;    This macro will write to the diskette.
  166. ;
  167. dskwrite    macro        drive,head,track,sector,numsecs,buffoff
  168.         ldreg        dl,drive
  169.         ldreg        dh,head
  170.         ldreg        ch,track
  171.         ldreg        cl,sector
  172.         ldreg        al,numsecs
  173.         ldreg        bx,buffoff
  174.         mov        ah,3
  175.         int        16h
  176.         endm
  177. ;
  178. ;        DSKVERFY
  179. ;
  180. ;    This macro will verify the diskette.
  181. ;
  182. dskverfy    macro        drive,head,track,sector,numsecs,buffoff
  183.         ldreg        dl,drive
  184.         ldreg        dh,head
  185.         ldreg        ch,track
  186.         ldreg        cl,sector
  187.         ldreg        al,numsecs
  188.         ldreg        bx,buffoff
  189.         mov        ah,4
  190.         int        16h
  191.         endm
  192. ;
  193. ;        DSKFORMAT
  194. ;
  195. ;    This macro will format the diskette.
  196. ;
  197. dskformat    macro        drive,head,track,sector,numsecs,buffoff
  198.         ldreg        dl,drive
  199.         ldreg        dh,head
  200.         ldreg        ch,track
  201.         ldreg        cl,sector
  202.         ldreg        al,numsecs
  203.         ldreg        bx,buffoff
  204.         mov        ah,5
  205.         int        16h
  206.         endm
  207. ;
  208. ;        PRNTCHAR
  209. ;
  210. ;    This macro will print a character on the printer.
  211. ;
  212. prntchar    macro        char,printer
  213.         ldreg        al,char
  214.         ldreg        dx,printer
  215.         mov        ah,0
  216.         int        17h
  217.         endm
  218. ;
  219. ;        INIPRNTR
  220. ;
  221. ;    This macro will initialize the printer.
  222. ;
  223. iniprntr    macro        printer
  224.         ldreg        dx,printer
  225.         mov        ah,1
  226.         int        17h
  227.         endm
  228. ;
  229. ;        PRNTSTAT
  230. ;
  231. ;    This macro will get the printer status.
  232. ;
  233. prntstat    macro        printer
  234.         ldreg        dx,printer
  235.         mov        ah,2
  236.         int        17h
  237.         endm
  238. ;
  239. ;        SETCRTMODE
  240. ;
  241. ;    This macro will set the vidio mode for the CRT.
  242. ;
  243. setcrtmode    macro        modeval
  244.         ldreg        al,modeval
  245.         mov        ah,0
  246.         int        10h
  247.         endm
  248. ;
  249. ;        SCRTMODE
  250. ;
  251. ;    This macro will set the vidio mode for the CRT.  It will allow the
  252. ; caller of the macro to set the mode symbolicly.
  253. ;
  254. scrtmode    macro        modeval
  255.         sub        al,al
  256. ;        tstnset     modeval,bw40x25,0
  257.         tstnset     modeval,color40x25,1
  258.         tstnset     modeval,bw80x25,2
  259.         tstnset     modeval,color80x25,3
  260.         tstnset     modeval,color320x200,4
  261.         tstnset     modeval,bw320x200,5
  262.         tstnset     modeval,bw640x200,6
  263.         mov        ah,0
  264.         int        10h
  265.         endm
  266. ;
  267. ;        SETCURTYPE
  268. ;
  269. ;    This macro will set the cursor type.
  270. ;
  271. setcurtype    macro        start,end
  272.         ldreg        ch,start
  273.         ldreg        cl,end
  274.         mov        ah,1
  275.         int        10h
  276.         endm
  277. ;
  278. ;        SETCURPOS
  279. ;
  280. ;    This macro will set the cursor position.
  281. ;
  282. setcurpos    macro        row,col,crtpage
  283.         ldreg        dh,row
  284.         ldreg        dl,col
  285.         ldreg        bh,crtpage
  286.         mov        ah,2
  287.         int        10h
  288.         endm
  289. ;
  290. ;        GETCURPOS
  291. ;
  292. ;    This macro will get the cursor position.
  293. ;
  294. getcurpos    macro        crtpage
  295.         ldreg        bh,crtpage
  296.         mov        ah,3
  297.         int        10h
  298.         endm
  299. ;
  300. ;        GETPENPOS
  301. ;
  302. ;    This macro will get the light pen position.
  303. ;
  304. getpenpos    macro
  305.         mov        ah,4
  306.         int        10h
  307.         endm
  308. ;
  309. ;        SETPAGE
  310. ;
  311. ;    This macro will set the display page.
  312. ;
  313. setpage     macro        crtpage
  314.         ldreg        al,crtpage
  315.         mov        ah,5
  316.         int        10h
  317.         endm
  318. ;
  319. ;        SCROLLUP
  320. ;
  321. ;    This macro will scroll the page up.
  322. ;
  323. scrollup    macro        lines,ulcrow,ulccol,lrcrow,lrccol,attr
  324.         ldreg        al,lines
  325.         ldreg        ch,ulcrow
  326.         ldreg        cl,ulccol
  327.         ldreg        dh,lrcrow
  328.         ldreg        dl,lrccol
  329.         ldreg        bh,attr
  330.         mov        ah,6
  331.         int        10h
  332.         endm
  333. ;
  334. ;        SCROLLDOWN
  335. ;
  336. ;    This macro will scroll the page down.
  337. ;
  338. scrolldown    macro        lines,ulcrow,ulccol,lrcrow,lrccol,attr
  339.         ldreg        al,lines
  340.         ldreg        ch,ulcrow
  341.         ldreg        cl,ulccol
  342.         ldreg        dh,lrcrow
  343.         ldreg        dl,lrccol
  344.         ldreg        bh,attr
  345.         mov        ah,7
  346.         int        10h
  347.         endm
  348. ;
  349. ;        READATRCHR
  350. ;
  351. ;    This macro will read the attribute and character at the current cursor
  352. ; position.
  353. ;
  354. readatrchr    macro        page
  355.         ldreg        bh,page
  356.         mov        ah,8
  357.         int        10h
  358.         endm
  359. ;
  360. ;        WRITEATRCHR
  361. ;
  362. ;    This macro will write the attribute and character at the current cursor
  363. ; position.
  364. ;
  365. writeatrchr    macro        char,attr,count,page
  366.         ldreg        al,char
  367.         ldreg        bl,attr
  368.         ldreg        cx,count
  369.         ldreg        bh,page
  370.         mov        ah,9
  371.         int        10h
  372.         endm
  373. ;
  374. ;        WRITECHAR
  375. ;
  376. ;    This macro will write the character at the current cursor position.
  377. ;
  378. writechar    macro        char,count,page
  379.         ldreg        al,char
  380.         ldreg        cx,count
  381.         ldreg        bh,page
  382.         mov        ah,10
  383.         int        10h
  384.         endm
  385. ;
  386. ;        SETPALETTE
  387. ;
  388. ;    This macro will set the color palette.
  389. ;
  390. setpalette    macro        colorid,colorval
  391.         ldreg        bh,colorid
  392.         ldreg        bl,colorval
  393.         mov        ah,11
  394.         int        10h
  395.         endm
  396. ;
  397. ;        WRITEDOT
  398. ;
  399. ;    This macro will write a dot on the CRT.
  400. ;
  401. writedot    macro        row,col,color
  402.         ldreg        dx,row
  403.         ldreg        cx,col
  404.         ldreg        al,color
  405.         mov        ah,12
  406.         int        10h
  407.         endm
  408. ;
  409. ;        READDOT
  410. ;
  411. ;    This macro will read a dot from the CRT.
  412. ;
  413. readdot     macro        row,col
  414.         ldreg        dx,row
  415.         ldreg        cx,col
  416.         mov        ah,13
  417.         int        10h
  418.         endm
  419. ;
  420. ;        TELEWRITE
  421. ;
  422. ;    This macro will perform a teletype write.
  423. ;
  424. telewrite    macro        char,color,page
  425.         ldreg        al,char
  426.         ldreg        bl,color
  427.         ldreg        bh,page
  428.         mov        ah,14
  429.         int        10h
  430.         endm
  431. ;
  432. ;        VIDIOSTATE
  433. ;
  434. ;    This macro will get the current vidio state.
  435. ;
  436. vidiostate    macro
  437.         mov        ah,15
  438.         int        10h
  439.         endm
  440. ;
  441. ;        GETMEMSIZE
  442. ;
  443. ;    This macro will return the amount of memory in 1K increments.
  444. ;
  445. getmemsize    macro
  446.         int        12h
  447.         endm
  448. ;
  449. ;        EQUIPMENT
  450. ;
  451. ;    This macro will return the kinds of devices that are attached to the
  452. ; system.
  453. ;
  454. equipment    macro
  455.         int        11h
  456.         endm
  457. ;
  458. ;        CASMOTOR
  459. ;
  460. ;    This macro will turn the cassette motor on or off.
  461. ;
  462. casmotor    macro        motorstate
  463.         ifidn        <motorstate>,<on>
  464.         mov        ah,0
  465.         endif
  466.         ifidn        <motorstate>,<off>
  467.         mov        ah,1
  468.         endif
  469.         int        15h
  470.         endm
  471. ;
  472. ;        CASREAD
  473. ;
  474. ;    This macro will read 256 byte blocks from the cassette.
  475. ;
  476. casread     macro        numbytes,buffoff
  477.         ldreg        cx,numbytes
  478.         ldreg        bx,buffoff
  479.         mov        ah,2
  480.         int        15h
  481.         endm
  482. ;
  483. ;        CASWRITE
  484. ;
  485. ;    This macro will write 256 byte blocks to the cassette.
  486. ;
  487. caswrite    macro        numbytes,buffoff
  488.         ldreg        cx,numbytes
  489.         ldreg        bx,buffoff
  490.         mov        ah,3
  491.         int        15h
  492.         endm
  493.