⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 clock.asm

📁 8259中断程序。接口试验程序
💻 ASM
字号:
cseg segment
	assume cs:cseg
	tcon equ 48H
	t2   equ 4AH
	contport	equ	0DFH
	dataport	equ	0DEH
	org 1000H
start:	jmp sta
	data	db	3FH, 06H, 5BH, 4FH, 66H, 6DH, 7DH, 07H, 7FH, 6FH
sta:	cli
	mov ax, 0
	mov ds, ax
	;change interrupt v
	mov ax, offset int_pr
	mov word ptr ds:[2CH], ax
	mov ax, seg int_pr
	mov word ptr ds:[2EH], ax
	;init 8259
	mov al, 00010011B
	out 20H, al
	mov al, 08H
	out 21H, al
	mov al, 00001111B
	out 21H, al
	;init 8253
	mov al, 10110110B
	mov dx, tcon
	out dx, al
	mov ax, 2710H
	mov dx, t2
	out dx, al
	mov al, ah
	out dx, al

	;init data field 500H~505H with 0
	mov cx, 6
	mov bx, 500H
init:	mov byte ptr ds:[bx], 0
	inc bx
	loop init

	;init data field 700H~707H with led code
	mov byte ptr ds:[702H], 40H	;code of "-" 
	mov byte ptr ds:[705H], 40H

	mov cx, 0	;
	sti

abcd:	mov dx, contport	;whether a key pressed
	in al, dx
	test al, 07H
	jnz hi
	jmp nom	;no key pressed,
hi:	mov dx, contport	;whether the key is "C"
	mov al, 40H
	out dx, al
	mov dx, dataport
	in al, dx
	cmp al, 0CH
	jz hi1
	jmp nom	;the key isn't "C"
hi1:	cli	;the key pressed is "C"
	mov byte ptr ds:[500H], 0
	mov byte ptr ds:[501H], 0
	call conv
hi2:	mov dx, contport	;set high bit of hour
	in al, dx
	test al, 07H
	jz hd2
	mov dx, contport
	mov al, 40H
	out dx, al
	mov dx, dataport
	in al, dx
	cmp al, 0CH
	jne gogo
	jmp h1x

gogo:	cmp al, 2
	ja hd2
	jne ttt
	cmp byte ptr ds:[505h],3
	ja hd2
ttt:    mov byte ptr ds:[505h],al
	call cony
	jmp h1
HD2:    mov al,90h
	MOV DX,COUNTPORT
   	OUT DX,AL
	MOV DX, DATAPORT
	MOV AL , BYTE PTR DS:[700H]
	OUT DX, AL
	MOV AL , BYTE PTR DS:[701H]
	OUT DX, AL	
	MOV AL , BYTE PTR DS:[702H]
	OUT DX, AL
	MOV AL , BYTE PTR DS:[703H]
	OUT DX, AL
	MOV AL , BYTE PTR DS:[704H]
	OUT DX, AL
	MOV AL , BYTE PTR DS:[705H]
	OUT DX, AL
	MOV AL , BYTE PTR DS:[706H]
	OUT DX, AL
	MOV AL, 0
	OUT DX, AL

	MOV CX, 05FFFH
	DELA:LOOP DELA
	CALL LEDDISP
	MOV CX, 05FFFH
	DELA1:LOOP DELA1
	JMP H2

	H1:MOV DX, CONTPORT
	IN AL,DX
	TEST AL, 07H
	JZ HD1
	MOV DX, CONTPORT
	MOV AL, 40H
	OUT DX,AL
	MOV DX,DATAPORT
	IN AL, DX
	CMP AL, 0CH
	JNE GOGO1
	JMP H1X
GOGO1:
	CMP AL,9
	JA HD1
CMP BYTE PTR DS:[505H],2
	JNE OK
	CMP AL,3
	JA M2
HD1:    MOV AL,90H
	MOV DX,COUTPROT
 	OUT DX,AL
 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -