home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 23 / IOPROG_23.ISO / SOFT / ASM / KVL27EOS.ZIP / EDAY.ASH < prev    next >
Encoding:
Text File  |  1999-01-09  |  4.6 KB  |  267 lines

  1. ;
  2. ; Copyright (C) 1998 Grzegorz Kowal
  3. ;
  4.  
  5. ;;
  6. ;; EVERY DAY EQUATES AND MACROS
  7. ;;
  8.  
  9.         LOCALS
  10.  
  11.         LF        EQU    0Dh,0Ah
  12.         EOM        EQU    0Dh,0Ah,'$'
  13.  
  14.         GLOBAL        Convert:PROC
  15.         GLOBAL        ConvertH:PROC
  16.         GLOBAL        CheckCPU:PROC
  17.         GLOBAL        CPUID:PROC
  18.  
  19.  
  20. ;; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  21. ;; Term () -- terminates the program.
  22. ;;
  23. ;; Expects:    nothing
  24. ;;
  25. ;; Returns:    nothing
  26. ;;
  27. Term        MACRO
  28.         IFDEF    MousePresent
  29.           xor ax,ax
  30.           DosInt 33h
  31.         ENDIF
  32.         IFDEF    VESAPresent
  33.           mov ax,03h
  34.           DosInt 10h
  35.         ENDIF
  36.         mov    ax,4C00h
  37.         int    21h
  38.         ENDM
  39.  
  40.  
  41. ;; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  42. ;; Kill (offset) -- terminates the program with an error message.
  43. ;;
  44. ;; Expects:    offset to ASCII$ string
  45. ;;
  46. ;; Returns:    nothing
  47. ;;
  48. ;; Note:    The EOS function Exit_Error couses an error under Windows 95,
  49. ;;        that's why I made my own.
  50. ;;
  51. Kill        MACRO    P1
  52.         IFDEF    MousePresent
  53.           xor ax,ax
  54.           DosInt 33h
  55.         ENDIF
  56.         IFDEF    VESAPresent
  57.           mov ax,03h
  58.           DosInt 10h
  59.         ENDIF
  60.         mov    ah,02h
  61.         mov    dl,7
  62.         int    21h        ;; beep
  63.         mov    edx,O P1
  64.         mov    ah,09h
  65.         int    21h        ;; print
  66.         mov    ax,4C01h    ;; errorlevel 1
  67.         int    21h
  68.         ENDM
  69.  
  70.  
  71. ;; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  72. ;; GetClock ()    
  73. ;; Returns timer ticks in EAX.
  74. ;;
  75. ;; Expects:    nothing
  76. ;;
  77. ;; Returns:    EAX    = timer ticks since last reset.
  78. ;;
  79. ;; Note:    Fq    = 1.19318 MHz
  80. ;;            18.2 t/s
  81. ;;            65536 t/h
  82. ;;
  83. GetClock    MACRO
  84.         push    es
  85.         mov    ax,40h
  86.         mov    es,ax
  87.         mov    eax,es:[6Ch]
  88.         pop    es
  89.         ENDM
  90.  
  91.  
  92. ;; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  93. ;; ClockSync ()    
  94. ;; Waits until the clock triggers.
  95. ;;
  96. ;; Expects:    nothing
  97. ;;
  98. ;; Returns:    EAX    = timer
  99. ;;
  100. ClockSync    MACRO
  101. LOCAL        loop1
  102.         push    es
  103.         mov    ax,40h
  104.         mov    es,ax
  105.         mov    eax,es:[6Ch]
  106. loop1:
  107.         cmp    eax,es:[6Ch]
  108.         je    loop1
  109.         mov    eax,es:[6Ch]
  110.         pop    es
  111.         ENDM
  112.  
  113.  
  114. ;; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  115. ;; DosF (func #)    
  116. ;; Calls dos function via int 21h.
  117. ;;
  118. ;; Expects:    funtcion number (byte)
  119. ;;
  120. ;; Returns:    *
  121. ;;
  122. DosF        MACRO    P1
  123.         mov    ah,P1
  124.         int    21h
  125.         ENDM
  126.  
  127.  
  128. ;; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  129. ;; PutChar (char)
  130. ;; Displays a character with Ctrl-Break check.
  131. ;;
  132. ;; Expects:    char (byte)
  133. ;;
  134. ;; Returns:    nothing
  135. ;;
  136. PutChar        MACRO    P1
  137.         push    dx
  138.         mov    ah,2h
  139.         mov    dl,P1
  140.         int    21h
  141.         pop    dx
  142.         ENDM
  143.  
  144.  
  145. ;; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  146. ;; Print (offset)
  147. ;; Displays a string.
  148. ;;
  149. ;; Expects:    offset (ASCII$ string)
  150. ;;
  151. ;; Returns:    nothing
  152. ;;
  153. Print        MACRO    P1
  154.         push    edx
  155.         mov    edx,O P1
  156.         mov    ah,09h
  157.         int    21h
  158.         pop    edx
  159.         ENDM
  160.  
  161.  
  162. ;; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  163. ;; ClearKB ()
  164. ;; Clear the keyboard buffer.
  165. ;;
  166. ;; Expects:    nothing
  167. ;;
  168. ;; Returns:    nothing
  169. ;;
  170. ;;ClearKB        MACRO
  171. ;;        push    ds
  172. ;;        xor    ax,ax
  173. ;;        mov    ds,ax
  174. ;;        mov    ax,001Eh
  175. ;;        cli
  176. ;;        mov    ds:[041Ah],ax
  177. ;;        mov    ds:[041Ch],ax
  178. ;;        sti
  179. ;;        pop    ds
  180. ;;        ENDM
  181.  
  182.  
  183. ;; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  184. ;; GetKey ()  ->  AH,AL
  185. ;; Reads a key without echo and Ctrl-Break check.
  186. ;;
  187. ;; Expects:    nothing
  188. ;;
  189. ;; Returns:    AH    = scan code
  190. ;;        AL    = ASCII char
  191. ;;
  192. GetKey        MACRO
  193.         xor    ah,ah
  194.         DosInt    16h
  195.         ENDM
  196.  
  197.  
  198. ;; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  199. ;; KeyPressed ()  ->  ZF,AH,AL
  200. ;; Checks if a character is ready.
  201. ;;
  202. ;; Expects:    nothing
  203. ;;
  204. ;; Returns:    ZF    = [0--ready, 1--not ready]
  205. ;;        AH    = scan code
  206. ;;        AL    = ASCII char
  207. ;;
  208. KeyPressed    MACRO
  209.         mov    ah,01h
  210.         DosInt    16h
  211.         ENDM
  212.  
  213.  
  214. ;; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  215. ;; GetChar ()  ->  AL
  216. ;; Reads and echos a character with Crtl-Break check.
  217. ;;
  218. ;; Expects:    nothing
  219. ;;
  220. ;; Returns:    AL    = char
  221. ;;
  222. GetChar        MACRO
  223.         mov    ah,1h
  224.         int    21h
  225.         ENDM
  226.  
  227.  
  228. ;; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  229. ;; Beep
  230. ;;
  231. ;; Expects:    nothing
  232. ;;
  233. ;; Returns:    nothing
  234. ;;
  235. Beep        MACRO
  236.         push    dx
  237.         mov    ah,02h
  238.         mov    dl,7
  239.         int    21h
  240.         pop    dx
  241.         ENDM
  242.  
  243.  
  244. ;; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  245. ;; CMOSr (address)
  246. ;;
  247. ;; Expects:    address
  248. ;;
  249. ;; Returns:    AL = data
  250. ;;
  251. CMOSr        MACRO P1
  252.         mov    al,P1
  253.         out    70h,al
  254.         jmp    $+2
  255.         in    al,71h
  256.         ENDM
  257.  
  258.  
  259. Init_es_bx  macro Adrs
  260.             mov ebx,[Code32_Addr]
  261.             add ebx,O Adrs
  262.             shr ebx,4
  263.             mov Real_ES,ebx
  264.             lea ebx,Adrs
  265.             and ebx,0fh
  266.             endm
  267.