PILA SEGMENT STACK 'stack' db 128 dup (?) PILA ENDS DATOS SEGMENT guarda_ip dw (?) guarda_cs dw (?) guarda_ip2 dw (?) guarda_cs2 dw (?) teclapul db 'tecla pulsada',0ah,0dh,'$' teclades db 'tecla despulsada',0ah,0dh,'$' msg db '-> Segundos transcurridos: ','$' msg_tic db 10,13,'-> Tics transcurridos: ','$' contador_seg dw 0 tecla db ? cuenta db (0) cuenta_tics dw (0) bcd db 5 dup(?),'$' DATOS ENDS INTER SEGMENT AT 0 org 4*9 vector_ip dw (?) vector_cs dw (?) org 8*4 TIC_IP DW ? TIC_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 call cambia2 bucle: cmp tecla,1 jne bucle test tecla,80h jnz cont3 jmp bucle cont3: call restituye call restituye2 mov dx,offset msg mov ah,09 int 21h push contador_seg mov ax,offset bcd push ax call to_bcd mov dx,offset msg_tic mov ah,09 int 21h push cuenta_tics mov ax,offset bcd push ax call to_bcd retf ppal 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 cambia2 proc cli mov ax,tic_cs mov guarda_cs2,ax mov ax,tic_ip mov guarda_ip2,ax mov tic_ip,offset rutina2 mov tic_cs,seg rutina2 sti ret cambia2 endp restituye2 proc cli mov ax,guarda_cs2 mov tic_cs,ax mov ax,guarda_ip2 mov tic_ip,ax sti ret restituye2 endp rutina proc far cli in al,60h mov tecla,al test tecla,80h jnz cont mov dx,offset teclapul mov ah,9 int 21h jmp fin cont:mov dx,offset teclades mov ah,9 int 21h fin:mov al,20h out 20h,al sti iret rutina endp rutina2 proc far ; cli inc cuenta inc cuenta_tics cmp cuenta,19 jnz cont2 mov cuenta,0 inc contador_seg cont2: mov al,20h out 20h,al ; sti iret rutina2 endp to_bcd proc ; cli 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: cmp ax,0 jz final xor dx,dx div si add dl,'0' dec bx mov [di][bx],dl jnz bucle2 final: mov dx,di add dx,bx mov ah,9 int 21h pop di pop si pop bp pop dx pop bx pop ax ; sti ret 4 to_bcd endp CODIGO ENDS END ppal