向大虾些求教~ 希望多指点~
哪位大虾些帮忙看看下面的程序~ 不知道这么的~ 就是在最后delay定义的时候老是要出错误~ 不知道哪位大哥能帮我解决下~ 就是delay proc near ;延时子程序
push cx
mov cx,0ffffh
pp: loop pp
pop cx
ret
delay endp
这块地方有错~ 大哥些帮帮忙啊~ 江湖救急啊~
data segment ;数据段
io8255a equ 288H ;8255的A口地址
io8255b equ 289H ;8255的B口地址
io8255c equ 28aH ;8255的C口地址
io8255con equ 28bH ;8255A的控制口地址
ctr db 'enter c key to continue!',0ah,0dh ;程序初始提示信息
db 'enter other keys to exit to dos!',0ah,0dh,'$'
ctr01 db '1. zuo zhuan wan.....',0ah,0dh,'$' ;左转弯时提示信息(以下类似)
ctr02 db '2. you zhuan wan.....',0ah,0dh,'$'
ctr03 db '3. jin ji kai guan he shang.....',0ah,0dh,'$'
ctr04 db '4. sha che.....',0ah,0dh,'$'
ctr05 db '5. zuo zhuan wan sha che.....',0ah,0dh,'$'
ctr06 db '6. you zhuan wan sha che.....',0ah,0dh,'$'
ctr07 db '7. jin ji sha che.....',0ah,0dh,'$'
ctr08 db '8. jin ji zuo zhuan sha che.....',0ah,0dh,'$'
ctr09 db '9. jin ji you zhuan sha che.....',0ah,0dh,'$'
ctr10 db '10. ting kao.....',0ah,0dh,'$'
data ends
stack segment stack ;堆栈段
sta dw 50 dup(?)
stack ends
code segment ;代码段
assume cs:code,ds:data,es:data,ss:stack
main proc far
start: push ds
sub ax,ax
push ax
mov ax,data
mov ds,ax
mov es,ax
ccc: mov dx,offset ctr ;显示提示信息
mov ah,09h
int 21h
mov ah,01h
int 21h
cmp al,'c' ;若输入‘C’,则继续执行,否则返回到DOS
jz eee
mov ax,4c00h
int 21h
eee: mov dx,io8255con ;给8255A送入方式控制字89H 设置为A口输出,C口输入(因为实验箱上没B口)
mov al,89h
out dx,al
mov dx,io8255c ;将4个开关的状态送入AL
in al,dx
mov cx,0020h ;设置循环次数
bb1: cmp al,01h ;将al的值依次与01H到0AH比较
jnz bb2 ;不是01H则转bb1执行,是则调用中断在屏幕上显示相应提示信息,顺序执行下去
mov dx,offset ctr01
;左转弯状态,实现六盏灯状态为:闪、灭、闪、灭、闪、灭
mov ah,09h
int 21h ;调用09号中断,在屏幕上显示现在正处于左转弯状态
mov dx,io8255a
left: mov al,11101010b ;六盏灯状态为:亮、灭、亮、灭、亮、灭(最高两位没影响)
out dx,al
call delay0 ;调延时子程序
loop left
jmp ccc
bb2: cmp al,02h
jnz bb3
mov dx,offset ctr02
;右转弯状态,实现六盏灯状态为:灭、亮、灭、亮、灭、亮
mov ah,09h
int 21h
mov dx,io8255a
right: mov al,11010101b ;六盏灯状态为:灭、亮、灭、亮、灭、亮
out dx,al
call delay0
loop right
jmp ccc
bb3: cmp al,03h
jnz bb4
mov dx,offset ctr03 ;紧急开关合上
mov ah,09h
int 21h
mov dx,io8255a
hurry: mov al,11000000b ;六盏灯状态为:闪、闪、闪、闪、闪、闪
out dx,al
call delay0
mov al,11111111b
out dx,al
call delay0
loop hurry
jmp ccc
bb4: cmp al,04h
jnz bb5
mov dx,offset ctr04 ;刹车
mov ah,09h
int 21h
mov dx,io8255a
break: mov al,11000011b ;六盏灯状态为:灭、灭、灭、灭、亮、亮
out dx,al
call delay0
loop break
jmp ccc
bb5: cmp al,05h
jnz bb6
mov dx,offset ctr05 ;左转弯刹车
mov ah,09h
int 21h
mov dx,io8255a
leftbreak: mov al,11001010b ;六盏灯状态为:亮、灭、亮、灭、亮、灭
out dx,al
call delay0
loop leftbreak
jmp ccc
bb6: cmp al,06h
jnz bb7
mov dx,offset ctr06 ;右转弯刹车
mov ah,09h
int 21h
mov dx,io8255a
rightbreak: mov al,11000101b ;六盏灯状态为:灭、亮、灭、亮、灭、亮
out dx,al
call delay0
loop rightbreak
jmp ccc
bb7: cmp al,07h
jnz bb8
mov dx,offset ctr07 ;紧急刹车
mov ah,09h
int 21h
mov dx,io8255a
hurrybreak: mov al,11111111b ;六盏灯状态为:亮、亮、亮、亮、亮、亮
out dx,al
call delay0
loop hurrybreak
jmp ccc
bb8: cmp al,08h
jnz bb9
mov dx,offset ctr08 ;紧急左转刹车
mov ah,09h
int 21h
mov dx,io8255a
hurryleftbreak: mov al,11111111b ;六盏灯状态为:亮、亮、亮、亮、亮、亮
out dx,al
call delay0
mov al,11011111b
out dx,al
call delay0
loop hurryleftbreak
jmp ccc
bb9: cmp al,09h
jnz bb10
mov dx,offset ctr09 ;紧急右转刹车
mov ah,09h
int 21h
mov dx,io8255a
hurryrightbreak: mov al,11111111b ;六盏灯状态为:亮、亮、亮、亮、亮、亮
out dx,al
call delay0
mov al,11101111b
out dx,al
call delay0
loop hurryrightbreak
jmp ccc
bb10: cmp al,0ah
jnz bb11
mov dx,offset ctr10 ;停靠
mov ah,09h
int 21h
mov dx,io8255a
stop: mov al,11001100b ;六盏灯状态为:灭、灭、亮、亮、闪、闪
out dx,al
call delay0
mov al,11001111b
out dx,al
call delay0
loop stop
jmp ccc
bb11: jmp ccc
ret
main endp
delay proc near ;延时子程序
push cx
mov cx,0ffffh
pp: loop pp
pop cx
ret
delay endp
delay0 proc near ;延时子程序
push cx
push ax
mov cx,0080h
pp0: call delay
loop pp0
pop ax
pop cx
ret
delay0 endp
code ends
end start