Laura04 de Septiembre del 2005
PreguntaEn teoria tiene q contar el numero de teclas pulsadas.
Al dar a la tecla escape se para y saca por pantalla el numero de teclas que hemos pulsado...
Pero no me funciona y me estoy volviendo loca porque no encuentro el error :( Gracias de antemano
es para el 8086:
PILA segment STACK 'stack'
db 128 dup (?)
PILA ends
DATOS SEGMENT
cuenta db 0
bcd db 5 dup(?),'$'
tecla db ?
guarda_ip dw ?
guarda_cs dw ?
DATOS ends
INTER SEGMENT AT 0
org 4*9
vector_ip dw ?
vector_cs dw ?
INTER ends
CODIGO SEGMENT
ASSUME cs:codigo, ds:datos, ss:pila, es:inter
ppal proc far
push ds
xor ax, ax
push ax
mov ax, datos
mov ds, ax
mov ax, inter
mov es, ax
call cambia
bucle: test tecla, 27h ; mientras no pulsemos escape seguimos contando
jnz bucle
call restituye
mov al, cuenta
mox ax, cuenta
push ax
mov ax, offset bcd
push ax
call to_bcd
mov dx, offset cuenta
mov ah,09
int 21h
retf
ppal endp
to_bcd proc
push ax
push bx
push dx
push bp
push si
push di
mov bp,sp
mov ax,10h[bp]
mov di,0eh[bp]
mov bx,5
mov si,0ah
bucle2: xor dx,dx
div si
add dl,'0'
dec bx
mov [di][bx],dl
jnz bucle2
pop di
pop si
pop bp
pop dx
pop bx
pop ax
ret 4
to_bcd endp
cambia proc
cli
mov ax, vector_ip
mov guarda_ip, ax
mov ax, vector_cs
mov guarda_cs, ax
mov vector_ip, offset rutina
mov vector_cs, cs
sti
ret
cambia endp
restituye proc
cli
mov ax, guarda_ip
mov vector_ip, ax
mov ax, guarda_cs
mov vector_cs, ax
sti
ret
restituye endp
rutina proc
cli
in al, 60h ; leemos de teclado
mov tecla, al
test al, 80H
jz fin
mov al, cuenta
inc ax
mov cuenta, al
fin: mov al, 20h
out 20h, al
sti
iret
rutina endp
CODIGO ends
end ppal
Al dar a la tecla escape se para y saca por pantalla el numero de teclas que hemos pulsado...
Pero no me funciona y me estoy volviendo loca porque no encuentro el error :( Gracias de antemano
es para el 8086:
PILA segment STACK 'stack'
db 128 dup (?)
PILA ends
DATOS SEGMENT
cuenta db 0
bcd db 5 dup(?),'$'
tecla db ?
guarda_ip dw ?
guarda_cs dw ?
DATOS ends
INTER SEGMENT AT 0
org 4*9
vector_ip dw ?
vector_cs dw ?
INTER ends
CODIGO SEGMENT
ASSUME cs:codigo, ds:datos, ss:pila, es:inter
ppal proc far
push ds
xor ax, ax
push ax
mov ax, datos
mov ds, ax
mov ax, inter
mov es, ax
call cambia
bucle: test tecla, 27h ; mientras no pulsemos escape seguimos contando
jnz bucle
call restituye
mov al, cuenta
mox ax, cuenta
push ax
mov ax, offset bcd
push ax
call to_bcd
mov dx, offset cuenta
mov ah,09
int 21h
retf
ppal endp
to_bcd proc
push ax
push bx
push dx
push bp
push si
push di
mov bp,sp
mov ax,10h[bp]
mov di,0eh[bp]
mov bx,5
mov si,0ah
bucle2: xor dx,dx
div si
add dl,'0'
dec bx
mov [di][bx],dl
jnz bucle2
pop di
pop si
pop bp
pop dx
pop bx
pop ax
ret 4
to_bcd endp
cambia proc
cli
mov ax, vector_ip
mov guarda_ip, ax
mov ax, vector_cs
mov guarda_cs, ax
mov vector_ip, offset rutina
mov vector_cs, cs
sti
ret
cambia endp
restituye proc
cli
mov ax, guarda_ip
mov vector_ip, ax
mov ax, guarda_cs
mov vector_cs, ax
sti
ret
restituye endp
rutina proc
cli
in al, 60h ; leemos de teclado
mov tecla, al
test al, 80H
jz fin
mov al, cuenta
inc ax
mov cuenta, al
fin: mov al, 20h
out 20h, al
sti
iret
rutina endp
CODIGO ends
end ppal
