汇编代码如下
程序代码:
ASSUME CS:CODE,DS:DATA
DATA segment
db 03h,06h,0Ch,09h,00h,00h
DATA ends
CODE SEGMENT
HEAD: MOV DX,0606H
MOV AL,82H
OUT DX,AL
LOP1: MOV AX,DATA
MOV DS,AX
;读取bl输入的值放入al中
mov dx, 0602h
in al, dx
;正反转
mov ah, al
and al,00000001b
mov bx,5
mov ds:bx,al
;档位
and ah,00000110b
ror ah,1h
mov bx,4
mov ds:bx,ah
; mov dx, 0600h
; mov al,00000000b
; out dx,al
call dang
; mov al,01000000b
; out dx,al
; call dang
;CALL ZHUAN ;转一圈
call xiyi
LOP4: JMP LOP1
;mov ax,4c00h
;int 21h
;----------------------------------------
DELAY: MOV CX,0AAAAH
LOP2: LOOP LOP2
RET
;----------------------------------------
;----------------------------------------
DELAY3:
call DELAY
ret
DELAY2:
call DELAY
call DELAY
ret
DELAY1:
call DELAY
call DELAY
call DELAY
ret
;----------------------------------------
;----------------------------------------
;洗衣模式
xiyi:
MOV AX,DATA
MOV DS,AX
MOV BX,4
mov AL,DS:BX
CMP AL,01H
JE qingrou
CMP AL,02H
JE r1
CMP AL,03H
JE r2
ret
r1: jmp zhengchang
ret
r2: jmp shuaigan
ret
;----------------------------------------
;轻柔 4回合
qingrou:
p1: call cWise1
call cWise1
call cWise1
call cWise1
call cWise1
call cWise1
call cWise1
call cWise1
call cWise1
call cWise1
call cWise1
call cWise1
call cWise1
p2: call ccWise1
call ccWise1
call ccWise1
call ccWise1
call ccWise1
call ccWise1
call ccWise1
call ccWise1
call ccWise1
call ccWise1
call ccWise1
call ccWise1
call ccWise1
ret
;正常 4回合
zhengchang:
call cWise2
call cWise2
call cWise2
call cWise2
call cWise2
call cWise2
call cWise2
call cWise2
call cWise2
call cWise2
call cWise2
call cWise2
call cWise2
p4: call ccWise2
call ccWise2
call ccWise2
call ccWise2
call ccWise2
call ccWise2
call ccWise2
call ccWise2
call ccWise2
call ccWise2
call ccWise2
call ccWise2
call ccWise2
ret
;甩干 4回合
shuaigan:
;正反一圈
p5: call cWise3
call cWise3
call cWise3
call cWise3
call cWise3
call cWise3
call cWise3
call cWise3
call cWise3
call cWise3
call cWise3
call cWise3
call cWise3
p6: call ccWise3
call ccWise3
call ccWise3
call ccWise3
call ccWise3
call ccWise3
call ccWise3
call ccWise3
call ccWise3
call ccWise3
call ccWise3
call ccWise3
call ccWise3
ret
;----------------------------------------
;---------------------------------------
;转一圈
zhuan:
MOV AX,DATA
MOV DS,AX
MOV BX,5
MOV AL,DS:BX
CMP AL,00H
JE CWISE
JMP CCWISE
RET
;---------------------------------------
;---------------------------------------
;正转一圈
cWise:
MOV AX,DATA
MOV DS,AX
MOV BX,4
mov AL,DS:BX
CMP AL,01H
JE l1
CMP AL,02H
JE cWise2
CMP AL,03H
JE cWise3
JMP LOP1
l1: JMP cWise1
RET
cWise3:
MOV AX,DATA
MOV DS,AX
MOV DX,0600H
MOV BX,00H
MOV CL,DS:BX
MOV AL,CL
; OR AL,01001111B ;方向
OUT DX,AL
; call DANG
CALL DELAY3
ADD BX,01H
MOV CL,DS:BX
MOV AL,CL
; OR AL,01001111B ;档位
OUT DX,AL
; call DANG
CALL DELAY3
ADD BX,01H
MOV CL,DS:BX
MOV AL,CL
; OR AL,01001111B
OUT DX,AL
; call DANG
CALL DELAY3
ADD BX,01H
MOV CL,DS:BX
MOV AL,CL
; OR AL,01001111B
OUT DX,AL
; call DANG
CALL DELAY3
ret
cWise2:
MOV AX,DATA
MOV DS,AX
MOV DX,0600H
MOV BX,00H
MOV CL,DS:BX
MOV AL,CL
OUT DX,AL
CALL DELAY2
ADD BX,01H
MOV CL,DS:BX
MOV AL,CL
OUT DX,AL
CALL DELAY2
ADD BX,01H
MOV CL,DS:BX
MOV AL,CL
OUT DX,AL
CALL DELAY2
ADD BX,01H
MOV CL,DS:BX
MOV AL,CL
OUT DX,AL
CALL DELAY2
ret
cWise1:
MOV AX,DATA
MOV DS,AX
MOV DX,0600H
MOV BX,00H
MOV CL,DS:BX
MOV AL,CL
OUT DX,AL
CALL DELAY1
ADD BX,01H
MOV CL,DS:BX
MOV AL,CL
OUT DX,AL
CALL DELAY1
ADD BX,01H
MOV CL,DS:BX
MOV AL,CL
OUT DX,AL
CALL DELAY1
ADD BX,01H
MOV CL,DS:BX
MOV AL,CL
OUT DX,AL
CALL DELAY1
ret
;反转一圈
ccWise:
MOV AX,DATA
MOV DS,AX
MOV BX,4
mov AL,DS:BX
CMP AL,01H
JE ccWise1
CMP AL,02H
JE ccWise2
CMP AL,03H
JE ccWise3
RET
ccwise3:
MOV AX,DATA
MOV DS,AX
MOV DX,0600H
MOV BX,03H
MOV CL,DS:BX
MOV AL,CL
OUT DX,AL
CALL DELAY3
DEC BX
MOV CL,DS:BX
MOV AL,CL
OUT DX,AL
CALL DELAY3
DEC BX
MOV CL,DS:BX
MOV AL,CL
OUT DX,AL
CALL DELAY3
DEC BX
MOV CL,DS:BX
MOV AL,CL
OUT DX,AL
CALL DELAY3
RET
ccwise2:
MOV AX,DATA
MOV DS,AX
MOV DX,0600H
MOV BX,03H
MOV CL,DS:BX
MOV AL,CL
OUT DX,AL
CALL DELAY2
DEC BX
MOV CL,DS:BX
MOV AL,CL
OUT DX,AL
CALL DELAY2
DEC BX
MOV CL,DS:BX
MOV AL,CL
OUT DX,AL
CALL DELAY2
DEC BX
MOV CL,DS:BX
MOV AL,CL
OUT DX,AL
CALL DELAY2
ret
ccwise1:
MOV AX,DATA
MOV DS,AX
MOV DX,0600H
MOV BX,03H
MOV CL,DS:BX
MOV AL,CL
OUT DX,AL
CALL DELAY1
DEC BX
MOV CL,DS:BX
MOV AL,CL
OUT DX,AL
CALL DELAY1
DEC BX
MOV CL,DS:BX
MOV AL,CL
OUT DX,AL
CALL DELAY1
DEC BX
MOV CL,DS:BX
MOV AL,CL
OUT DX,AL
CALL DELAY1
ret
;---------------------------------------
;---------------------------------------
;数码管显示
light0:
mov dx, 0604h ; 控制端口a
mov al, 3fh
out dx, al ; 将al数据输出
ret
light1:
mov dx, 0604h ; 控制端口a
mov al, 06h
out dx, al ; 将al数据输出
ret
;数字2
light2:
mov dx, 0604h ; 控制端口a
mov al, 5Bh
out dx, al ; 将al数据输出
ret
;数字3
light3:
mov dx, 0604h ; 控制端口a
mov al, 4Fh
out dx, al ; 将al数据输出
ret
;数字4
light4:
mov dx, 0604h ; 控制端口a
mov al, 66h
out dx, al ; 将al数据输出
ret
;数字5
light5:
mov dx, 0604h ; 控制端口a
mov al, 6Dh
out dx, al ; 将al数据输出
ret
;数字6
light6:
mov dx, 0604h ;控制端口a
mov al, 7Dh
out dx, al ; 将al数据输出
ret
;数字7
light7:
mov dx, 0604h ; 控制端口a
mov al, 07h
out dx, al ; 将al数据输出
ret
;数字8
light8:
mov dx, 0604h ; 控制端口a
mov al, 7Fh
out dx, al ; 将al数据输出
ret
;---------------------------------------
;---------------------------------------
;输出档位
dang:
MOV AX,DATA
MOV DS,AX
MOV BX,04H
MOV AL,DS:BX
mov cl, 0H ;判断0
cmp al, cl
je light0
mov cl, 01H ;判断1
cmp al, cl
je light1
mov cl, 02H ;判断2
cmp al, cl
je light2
mov cl, 03H ;判断3
cmp al, cl
je light3
;输出方向
Fang:
MOV AX,DATA
MOV DS,AX
MOV BX,05H
MOV AL,DS:BX
mov cl, 0H ;判断0
cmp al, cl
je light0
mov cl, 01H ;判断1
cmp al, cl
je light1
;---------------------------------------
CODE ENDS
END HEAD
DATA segment
db 03h,06h,0Ch,09h,00h,00h
DATA ends
CODE SEGMENT
HEAD: MOV DX,0606H
MOV AL,82H
OUT DX,AL
LOP1: MOV AX,DATA
MOV DS,AX
;读取bl输入的值放入al中
mov dx, 0602h
in al, dx
;正反转
mov ah, al
and al,00000001b
mov bx,5
mov ds:bx,al
;档位
and ah,00000110b
ror ah,1h
mov bx,4
mov ds:bx,ah
; mov dx, 0600h
; mov al,00000000b
; out dx,al
call dang
; mov al,01000000b
; out dx,al
; call dang
;CALL ZHUAN ;转一圈
call xiyi
LOP4: JMP LOP1
;mov ax,4c00h
;int 21h
;----------------------------------------
DELAY: MOV CX,0AAAAH
LOP2: LOOP LOP2
RET
;----------------------------------------
;----------------------------------------
DELAY3:
call DELAY
ret
DELAY2:
call DELAY
call DELAY
ret
DELAY1:
call DELAY
call DELAY
call DELAY
ret
;----------------------------------------
;----------------------------------------
;洗衣模式
xiyi:
MOV AX,DATA
MOV DS,AX
MOV BX,4
mov AL,DS:BX
CMP AL,01H
JE qingrou
CMP AL,02H
JE r1
CMP AL,03H
JE r2
ret
r1: jmp zhengchang
ret
r2: jmp shuaigan
ret
;----------------------------------------
;轻柔 4回合
qingrou:
p1: call cWise1
call cWise1
call cWise1
call cWise1
call cWise1
call cWise1
call cWise1
call cWise1
call cWise1
call cWise1
call cWise1
call cWise1
call cWise1
p2: call ccWise1
call ccWise1
call ccWise1
call ccWise1
call ccWise1
call ccWise1
call ccWise1
call ccWise1
call ccWise1
call ccWise1
call ccWise1
call ccWise1
call ccWise1
ret
;正常 4回合
zhengchang:
call cWise2
call cWise2
call cWise2
call cWise2
call cWise2
call cWise2
call cWise2
call cWise2
call cWise2
call cWise2
call cWise2
call cWise2
call cWise2
p4: call ccWise2
call ccWise2
call ccWise2
call ccWise2
call ccWise2
call ccWise2
call ccWise2
call ccWise2
call ccWise2
call ccWise2
call ccWise2
call ccWise2
call ccWise2
ret
;甩干 4回合
shuaigan:
;正反一圈
p5: call cWise3
call cWise3
call cWise3
call cWise3
call cWise3
call cWise3
call cWise3
call cWise3
call cWise3
call cWise3
call cWise3
call cWise3
call cWise3
p6: call ccWise3
call ccWise3
call ccWise3
call ccWise3
call ccWise3
call ccWise3
call ccWise3
call ccWise3
call ccWise3
call ccWise3
call ccWise3
call ccWise3
call ccWise3
ret
;----------------------------------------
;---------------------------------------
;转一圈
zhuan:
MOV AX,DATA
MOV DS,AX
MOV BX,5
MOV AL,DS:BX
CMP AL,00H
JE CWISE
JMP CCWISE
RET
;---------------------------------------
;---------------------------------------
;正转一圈
cWise:
MOV AX,DATA
MOV DS,AX
MOV BX,4
mov AL,DS:BX
CMP AL,01H
JE l1
CMP AL,02H
JE cWise2
CMP AL,03H
JE cWise3
JMP LOP1
l1: JMP cWise1
RET
cWise3:
MOV AX,DATA
MOV DS,AX
MOV DX,0600H
MOV BX,00H
MOV CL,DS:BX
MOV AL,CL
; OR AL,01001111B ;方向
OUT DX,AL
; call DANG
CALL DELAY3
ADD BX,01H
MOV CL,DS:BX
MOV AL,CL
; OR AL,01001111B ;档位
OUT DX,AL
; call DANG
CALL DELAY3
ADD BX,01H
MOV CL,DS:BX
MOV AL,CL
; OR AL,01001111B
OUT DX,AL
; call DANG
CALL DELAY3
ADD BX,01H
MOV CL,DS:BX
MOV AL,CL
; OR AL,01001111B
OUT DX,AL
; call DANG
CALL DELAY3
ret
cWise2:
MOV AX,DATA
MOV DS,AX
MOV DX,0600H
MOV BX,00H
MOV CL,DS:BX
MOV AL,CL
OUT DX,AL
CALL DELAY2
ADD BX,01H
MOV CL,DS:BX
MOV AL,CL
OUT DX,AL
CALL DELAY2
ADD BX,01H
MOV CL,DS:BX
MOV AL,CL
OUT DX,AL
CALL DELAY2
ADD BX,01H
MOV CL,DS:BX
MOV AL,CL
OUT DX,AL
CALL DELAY2
ret
cWise1:
MOV AX,DATA
MOV DS,AX
MOV DX,0600H
MOV BX,00H
MOV CL,DS:BX
MOV AL,CL
OUT DX,AL
CALL DELAY1
ADD BX,01H
MOV CL,DS:BX
MOV AL,CL
OUT DX,AL
CALL DELAY1
ADD BX,01H
MOV CL,DS:BX
MOV AL,CL
OUT DX,AL
CALL DELAY1
ADD BX,01H
MOV CL,DS:BX
MOV AL,CL
OUT DX,AL
CALL DELAY1
ret
;反转一圈
ccWise:
MOV AX,DATA
MOV DS,AX
MOV BX,4
mov AL,DS:BX
CMP AL,01H
JE ccWise1
CMP AL,02H
JE ccWise2
CMP AL,03H
JE ccWise3
RET
ccwise3:
MOV AX,DATA
MOV DS,AX
MOV DX,0600H
MOV BX,03H
MOV CL,DS:BX
MOV AL,CL
OUT DX,AL
CALL DELAY3
DEC BX
MOV CL,DS:BX
MOV AL,CL
OUT DX,AL
CALL DELAY3
DEC BX
MOV CL,DS:BX
MOV AL,CL
OUT DX,AL
CALL DELAY3
DEC BX
MOV CL,DS:BX
MOV AL,CL
OUT DX,AL
CALL DELAY3
RET
ccwise2:
MOV AX,DATA
MOV DS,AX
MOV DX,0600H
MOV BX,03H
MOV CL,DS:BX
MOV AL,CL
OUT DX,AL
CALL DELAY2
DEC BX
MOV CL,DS:BX
MOV AL,CL
OUT DX,AL
CALL DELAY2
DEC BX
MOV CL,DS:BX
MOV AL,CL
OUT DX,AL
CALL DELAY2
DEC BX
MOV CL,DS:BX
MOV AL,CL
OUT DX,AL
CALL DELAY2
ret
ccwise1:
MOV AX,DATA
MOV DS,AX
MOV DX,0600H
MOV BX,03H
MOV CL,DS:BX
MOV AL,CL
OUT DX,AL
CALL DELAY1
DEC BX
MOV CL,DS:BX
MOV AL,CL
OUT DX,AL
CALL DELAY1
DEC BX
MOV CL,DS:BX
MOV AL,CL
OUT DX,AL
CALL DELAY1
DEC BX
MOV CL,DS:BX
MOV AL,CL
OUT DX,AL
CALL DELAY1
ret
;---------------------------------------
;---------------------------------------
;数码管显示
light0:
mov dx, 0604h ; 控制端口a
mov al, 3fh
out dx, al ; 将al数据输出
ret
light1:
mov dx, 0604h ; 控制端口a
mov al, 06h
out dx, al ; 将al数据输出
ret
;数字2
light2:
mov dx, 0604h ; 控制端口a
mov al, 5Bh
out dx, al ; 将al数据输出
ret
;数字3
light3:
mov dx, 0604h ; 控制端口a
mov al, 4Fh
out dx, al ; 将al数据输出
ret
;数字4
light4:
mov dx, 0604h ; 控制端口a
mov al, 66h
out dx, al ; 将al数据输出
ret
;数字5
light5:
mov dx, 0604h ; 控制端口a
mov al, 6Dh
out dx, al ; 将al数据输出
ret
;数字6
light6:
mov dx, 0604h ;控制端口a
mov al, 7Dh
out dx, al ; 将al数据输出
ret
;数字7
light7:
mov dx, 0604h ; 控制端口a
mov al, 07h
out dx, al ; 将al数据输出
ret
;数字8
light8:
mov dx, 0604h ; 控制端口a
mov al, 7Fh
out dx, al ; 将al数据输出
ret
;---------------------------------------
;---------------------------------------
;输出档位
dang:
MOV AX,DATA
MOV DS,AX
MOV BX,04H
MOV AL,DS:BX
mov cl, 0H ;判断0
cmp al, cl
je light0
mov cl, 01H ;判断1
cmp al, cl
je light1
mov cl, 02H ;判断2
cmp al, cl
je light2
mov cl, 03H ;判断3
cmp al, cl
je light3
;输出方向
Fang:
MOV AX,DATA
MOV DS,AX
MOV BX,05H
MOV AL,DS:BX
mov cl, 0H ;判断0
cmp al, cl
je light0
mov cl, 01H ;判断1
cmp al, cl
je light1
;---------------------------------------
CODE ENDS
END HEAD
只有本站会员才能查看附件,请 登录