home *** CD-ROM | disk | FTP | other *** search
/ World of Shareware - Software Farm 2 / wosw_2.zip / wosw_2 / PROG / INT09.ZIP / INT09.ASM < prev    next >
Encoding:
Assembly Source File  |  1993-08-01  |  8.0 KB  |  304 lines

  1. ;
  2. ; INT09.ASM by Celso Minnitti, Jr
  3. ;
  4. ; Date: 09/03/1992 to 07-30-1993
  5. ;
  6. ; Compile:  TASM INT09
  7. ;        TLINK /t INT09
  8. ;
  9.  
  10. ; This program will handle the INTerrupt 9 and output the values of
  11. ; port 60h, and port 61h every time one key is pressed.
  12.  
  13. ; Port 60h = (keyboard data, scan code of key)
  14. ; Port 61h = (control status of 8255)
  15.  
  16. SC_F10        EQU 44h ; scancode of F10 key
  17. ATTR        EQU 3Fh
  18.  
  19. code   segment byte public 'CODE'
  20.        assume cs:code, ds:code, es:code
  21.        org    100h
  22.  
  23. start:          call    cls                      ; clear screen
  24.         call    init             ; initialize vidseg variable
  25.         call    simgd             ; show imagedata
  26.         mov    ax,0C00h         ; ah= row, al=col
  27.         call    gotoxy             ; put cursor at row=12, col=0
  28.  
  29.         mov    ax,3509h         ; get int9
  30.         int    21h
  31.         push    es             ; save seg
  32.         push    bx             ; save off
  33.  
  34.         mov    ax,2509h         ; set int9
  35.         mov    dx,offset int_9
  36.         int    21h
  37.  
  38. ag:        cmp    [exit],1
  39.         jne    ag
  40.         mov    ax,2509h         ; restore int 9
  41.         pop    dx             ; seg
  42.         pop    ds             ; off
  43.         int    21h
  44.         mov    ax,4c00h         ; exit to DOS
  45.         int    21h
  46.  
  47.  
  48. ;**************************************************************************
  49. ;            INT 9 (IRQ 1, Keyboard Interrupt)
  50. ;**************************************************************************
  51.  
  52. int_9:          push    ax
  53.         push    di
  54.         push    es
  55.  
  56.         mov    es,cs:[vidseg]
  57.  
  58.         mov    di, 01*160 + 09*2
  59.         in    al,60h
  60.         call    print8h          ; print value of int 60h
  61.  
  62.         mov    di, 02*160 + 09*2
  63.         in    al,61h
  64.         call    print8h          ; print value of int 61h
  65.  
  66.         in    al,60h             ; read the scan code data
  67.         cmp    al,SC_F10         ; F10 press?
  68.         jne    int91
  69.         mov    cs:[exit],1         ; if yes, then exit =1
  70.  
  71. int91:        in    al,61h             ;
  72.         push    ax             ; save control status
  73.         or    al,80h             ; set bit 7 (latch) of 8255
  74.         out    61h,al             ; to acknowlodge data
  75.         pop    ax             ; restore control status
  76.         out    61h,al
  77.  
  78.         mov    al,20h             ; send EOI to 8259 (PIC)
  79.         out    20h,al
  80.         pop    es
  81.         pop    di
  82.         pop    ax
  83.         iret
  84.  
  85. ;**************************************************************************
  86. ;                PRINTxH, x=8 bits
  87. ;
  88. ;         AL, = # to print in hexadecimal at ES:DI
  89. ;              ES:DI= SEG:OFF of video memory
  90. ;**************************************************************************
  91. print8h     proc    near
  92.         push    ax
  93.         push    cx
  94.         push    dx
  95.         push    di
  96.  
  97. pri81:        mov    cx,2
  98.         mov    dl,al
  99.         mov    ah,ATTR
  100. pri82:        rol    dl,1
  101.         rol    dl,1
  102.                 rol     dl,1
  103.                 rol     dl,1
  104.  
  105.         mov    al,dl
  106.         and    al,0fh
  107.         daa
  108.         add    al,0f0h
  109.         adc    al,40h
  110.         stosw
  111.         loop    pri82
  112.  
  113.         pop    di
  114.         pop    dx
  115.         pop    cx
  116.         pop    ax
  117.         ret
  118. print8h     endp
  119.  
  120. ;**************************************************************************
  121. ;                   CLS
  122. ;**************************************************************************
  123. cls             proc    near
  124.         push    ax
  125.         push    bx
  126.         push    cx
  127.         push    dx
  128.         mov    ah,6
  129.         mov    al,0
  130.         xor    cx,cx
  131.         mov    dh,24
  132.         mov    dl,79
  133.         mov    bh,7
  134.         int    10h
  135.         pop    dx
  136.         pop    cx
  137.         pop    bx
  138.         pop    ax
  139.         ret
  140. cls             endp
  141.  
  142. ;**************************************************************************
  143. ;                  GOTOXY
  144. ;                 AH= row, AL= col
  145. ;**************************************************************************
  146. gotoxy        proc    near
  147.         push    ax
  148.                 push    bx
  149.         mov    dx,ax
  150.         mov    ah,2
  151.         mov    bh,0             ; page 0
  152.         int    10h
  153.         pop    bx
  154.         pop    ax
  155.                 ret
  156. gotoxy          endp
  157.  
  158.  
  159. simgd:        mov    cx,IMAGEDATA_LENGTH
  160.         mov    si,offset IMAGEDATA
  161.         xor    di,di
  162.         mov    es,[vidseg]
  163.         call    uncrunch
  164.         ret
  165.  
  166. ;**************************************************************************
  167. ;                   INIT
  168. ; Initialize:
  169. ; vidseg = B800 (color) or B000 (mono)
  170. ;**************************************************************************
  171. init        proc    near
  172.         push    ds
  173.         xor    ax,ax
  174.         mov    ds,ax
  175.                 mov     al,byte ptr ds:[410h]
  176.         pop    ds
  177.  
  178.         and    al,30h
  179.         cmp    al,30h
  180.         mov    ax,0B800h
  181.         jnz    init1
  182.         mov    ax,0B000h
  183. init1:        mov    word ptr [vidseg],ax
  184.         ret
  185. init        endp
  186.                 
  187. ;**************************************************************************
  188. ;                 UNCRUNCH
  189. ;           for crunched images from TheDraw v4.3
  190. ;
  191. ;                 DS:SI = Crunched image source pointer
  192. ;          ES:DI = Display address pointer
  193. ;          CX    = Length of ImageData source data
  194. ;**************************************************************************
  195.  
  196. uncrunch    proc    near
  197.  
  198.        PUSH    SI               ;Save registers.
  199.        PUSH    DI
  200.        PUSH    AX
  201.        PUSH    CX
  202.        PUSH    DX
  203.  
  204.        MOV     DX,DI                   ;Save X coordinate for later.
  205.        XOR     AX,AX                   ;Set Current attributes.
  206.        CLD
  207.  
  208. LOOPA: LODSB                           ;Get next character.
  209.        CMP     AL,27                   ;Does user want to toggle the blink
  210.        JNZ     ForeGround              ;attibute?
  211.        XOR     AH,128                  ;Done.
  212.        JMP     Short Next
  213.  
  214. ForeGround:
  215.        CMP     AL,16                   ;If less than 16, then change the
  216.        JNC     BackGround              ;foreground color.  Otherwise jump.
  217.        AND     AH,70H                  ;Strip off old foreground.
  218.        OR      AH,AL
  219.        JMP     Short Next
  220.  
  221. BackGround:
  222.        CMP     AL,24                   ;If less than 24, then change the
  223.        JZ      NextLine                ;background color.  If exactly 24,
  224.        JNC     MultiOutput             ;then jump down to next line.
  225.        SUB     AL,16                   ;Otherwise jump to multiple output
  226.        ADD     AL,AL                   ;routines.
  227.        ADD     AL,AL
  228.        ADD     AL,AL
  229.        ADD     AL,AL
  230.        AND     AH,8FH                  ;Strip off old background.
  231.        OR      AH,AL
  232.        JMP     Short Next
  233.  
  234. NextLine:
  235.        ADD     DX,160                  ;If equal to 24,
  236.        MOV     DI,DX                   ;then jump down to
  237.        JMP     Short Next              ;the next line.
  238.  
  239. MultiOutput:
  240.        CMP     AL,25                   ;If equal to 25,
  241.        JNZ     NotMultiSpaces          ;then use the
  242.        LODSB                           ;following code as
  243.        PUSH    CX                      ;a count and output
  244.        XOR     CH,CH                   ;said number of
  245.        MOV     CL,AL                   ;spaces.
  246.        MOV     AL,32
  247.        JMP     Short StartOutput       ;Use below loop.
  248.  
  249. NotMultiSpaces:
  250.        CMP     AL,26                   ;If equal to 26, then using
  251.        JNZ     NormalLetter            ;the following two codes, display
  252.        LODSB                           ;<x> number of <y> characters.
  253.        DEC     CX                      ;Adjust main counter.
  254.        PUSH    CX                      ;Display as many of
  255.        XOR     CH,CH                   ;whatever the user
  256.        MOV     CL,AL                   ;wants.
  257.        LODSB                           ;Get character.
  258.  
  259. StartOutput:
  260.        JCXZ    Stop                    ;Abort if already at zilch.
  261. LOOPB: STOSW
  262.        LOOP    LOOPB
  263. Stop:  POP     CX
  264.        DEC     CX                      ;Adjust main counter.
  265.  
  266. NormalLetter:
  267.        STOSW                           ;Save screen letter.
  268.  
  269. Next:  JCXZ    Done                    ;Get next, unless CX
  270.        LOOP    LOOPA                   ;has already gone to zero.
  271.  
  272. Done:  POP     DX                      ;Restore registers.
  273.        POP     CX
  274.        POP     AX
  275.        POP     DI
  276.        POP     SI
  277.        RET
  278.  
  279. uncrunch    endp
  280.  
  281. ; TheDraw Assembler Crunched Screen Image
  282.  
  283. IMAGEDATA_WIDTH EQU 41
  284. IMAGEDATA_DEPTH EQU 11
  285. IMAGEDATA_LENGTH EQU 243
  286. IMAGEDATA LABEL BYTE
  287.         DB      11,19,'┌',26,10,'─┐',16,25,4,'Hit the following keys'
  288.         DB      ':',24,19,'│ ',14,'in ',0,'60h=',15,'44 ',11,'│',24,'│'
  289.         DB      ' ',14,'in ',0,'61h=',15,'30 ',11,'│',16,25,4,15,'Ct'
  290.         DB      'rl-Alt-Del',24,11,19,'│',25,10,'│',16,25,4,14,'Caps'
  291.         DB      ' Lock',24,11,19,'└',14,'F10 to exit',11,'┘',16,25,4,15
  292.         DB      'Num Lock',24,25,17,14,'Scrool Lock',24,25,17,15,'An'
  293.         DB      'y HotKey at all...',24,24,25,17,11,'or ',14,19,'F10'
  294.         DB      16,' ',11,'to exit.',24,24,15,'Intriguing? See ',12,'I'
  295.         DB      'NT09.ASM ',15,'for details.',24
  296.  
  297.  
  298. exit        db    0
  299. vidseg        dw    0
  300.  
  301. code            ends
  302. end        start
  303.  
  304.