Files
Microcomputer_System_and_In…/Lab/Lab3/material/task1/code.asm
2025-05-27 16:03:52 +08:00

47 lines
1.2 KiB
NASM
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

DATA SEGMENT
T DW 0FFH
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE, DS:DATA
START:
MOV AX, DATA
MOV DS, AX
MOV DX, 283H ; 命令口
MOV AL, 10010000B ; 1|00(A组0方式)|1(PA输入)|0(PC4-7输出)|0(B组0方式)|0(PB输出)|0(PC0-3输出)
OUT DX, AL
MOV DX, 281H ; B口
MOV AL, 00H ; LED全置0
OUT DX, AL
MOV DX, 280H ; A口
IN AL, DX ; 读入到AL
MOV DX, 281H ; B口
LP:
OUT DX, AL ; 从B口输出AL
CALL DELAY ; 延时
ROR AL, 1 ; ROR(Rotate Right)把AL向右移1位移出的位补到左边实现走马灯
JMP LP ; 无限循环
DELAY PROC
PUSH BX
PUSH AX
MOV BX, T
MOV AX, T
DL1:
DL2:
DEC BX
JNZ DL1
DEC AX
JNZ DL2
POP AX
POP BX
RET
DELAY ENDP
CODE ENDS
END START