Aplicación de Interrupciones Teclado Mouse y Video
Aplicación de Interrupciones Teclado Mouse y Video
Aplicación de Interrupciones Teclado Mouse y Video
1
Aplicacin de Interrupciones: Teclado,
Mouse y Video
DIAGONAL EN LA PANTALLA.asm
org 100h
mov cx,1
mov al, 13h
mov ah, 0
int 10h ; set graphics video mode.
bucle1:
mov dx, cx
mov al, color ;AL = pixel color
mov ah, 0ch ;Change color for a single pixel
int 10h ;set pixel
2
color db 1
ret
3
name "keybrd"
org 100h
; print a welcome message:
mov dx, offset msg
mov ah, 9
int 21h
;============================
; eternal loop to get
; and print keys:
wait_for_key:
; check for keystroke in
; keyboard buffer:
mov dh, pos
mov dl, pos
mov bh, 0
mov ah, 2
int 10h ;Movemos el cursor
mov al,'X'
mov bh,0
mov bl,1
mov cx,1
mov ah,09h
inc pos ;Imprimimos una x
int 10h
mov ah, 1
int 16h
jz wait_for_key
; get keystroke from keyboard:
; (remove from the buffer)
mov ah, 0
int 16h
; print the key:
mov ah, 0eh
int 10h
; press 'esc' to exit:
cmp al, 1bh
jz exit
jmp wait_for_key
;============================
exit:
ret
msg db "Type anything...", 0Dh,0Ah
db "[Enter] - carriage return.", 0Dh,0Ah
db "[Ctrl]+[Enter] - line feed.", 0Dh,0Ah
db "You may hear a beep", 0Dh,0Ah
db " when buffer is overflown.", 0Dh,0Ah
db "Press Esc to exit.", 0Dh,0Ah, "$"
pos db 1
4
end
C. INTERRUPCION DE MOUSE
INTERRUPCION DE MOUSE.asm
5
; mouse test
name "mouse"
org 100h
clear_screen macro
pusha
mov ax, 0600h
mov bh, 0000_1111b
mov cx, 0
mov dh, 24
mov dl, 79
int 10h
popa
endm
jmp start
curX dw 0
curY dw 0
curB dw 0
start:
mov ax, 1003h ; disable blinking.
mov bx, 0
int 10h
ok:
clear_screen
print 7,7,0010_1011b,;" note: in the emulator you may need to press and hold
mouse buttons "
print 7,8,0010_1011b,;" because mouse interrupts are not processed in real
time. "
print 7,9,0010_1011b,;" for a real test, click external->run from the menu.
"
print 10,11,0010_1111b,;" click/hold both buttons to exit... "
check_mouse_buttons:
mov ax, 3
int 33h
7
cmp bx, 3 ; both buttons
je hide
cmp cx, curX
jne print_xy
cmp dx, curY
jne print_xy
cmp bx, curB
jne print_buttons
print_xy:
print 0,0,0000_1111b,"x="
mov ax, cx
call print_ax
print_space 4
print 0,1,0000_1111b,"y="
mov ax, dx
call print_ax
print_space 4
mov curX, cx
mov curY, dx
jmp check_mouse_buttons
print_buttons:
print 0,2,0000_1111b,"btn="
mov ax, bx
call print_ax
print_space 4
mov curB, bx
jmp check_mouse_buttons
hide:
mov ax, 2 ; hide mouse cursor.
int 33h
clear_screen
stop:
; show box-shaped blinking text cursor:
mov ah, 1
mov ch, 0
mov cl, 8
int 10h
8
print 4,7,0000_1010b," press any key.... "
mov ah, 0
int 16h
ret
print_ax proc
cmp ax, 0
jne print_ax_r
push ax
mov al, '0'
mov ah, 0eh
int 10h
pop ax
ret
print_ax_r:
pusha
mov dx, 0
cmp ax, 0
je pn_done
mov bx, 10
div bx
call print_ax_r
mov ax, dx
add al, 30h
mov ah, 0eh
int 10h
jmp pn_done
pn_done:
popa
ret
endp
9
Figura5. Muestra el Cdigo hasta la lnea 41
10
Figura 7. Muestra el Cdigo desde la lnea 81 a la 120
11
Figura 9. Muestra el Cdigo desde la lnea 152 a la 171
12