我有一个assember代码问题(8086 16bit),我希望它在屏幕上写一个AZ数字树,它应该在X等待按键后停止,然后显示Y和Z.我有这个代码:
Progr segment
assume cs:Progr, ds:dane, ss:stosik
start: mov ax,dane
mov ds,ax
mov ax,stosik
mov ss,ax
mov sp,offset szczyt
mov bx, 27 ;counter_rows
rows:
;here I write space
mov cx, bx ; counter_space = counter_rows + 14
add cl, 14
mov ah, 02h
mov dl, 32 ;space
space:
int 21h
loop space
;here I write letters
mov cl, 55 ;counter_char = 55 - counter_rows * 2
sub cl, bl
sub cl, bl
mov dl, 65 + 27 ;code_char = 'A' + 27 - counter_rows
sub dl, bl
letters:
int 21h
loop letters
;here I go to another line(enter)
mov dl, 0ah
int 21h
dec bx
mov cx,3
cmp cx,bx ;is bx 3
JNZ rows
dec ah ; wait for a key
int 21h
dec ah ;02h - 1 = 01h; wait for a key before end a program
int 21h
mov ax,4c00h ;set ah and al in one go and ends programo
int 21h
Progr ends
dane segment
dane ends
stosik segment
dw 100h dup(0)
szczyt Label word
stosik ends
end start
我猜这个问题是JZ ifnull jump - 我用它在X之后停止屏幕并等待按键但是它没有按照我的想法运行。 在此先感谢您的帮助
答案 0 :(得分:1)
我尽可能少地改变了:
...
dec bx
cmp bx, 1
je finish
mov cx,3
cmp cx,bx ;is bx 3
JNZ rows
mov ah, 1 ; wait for a key
int 21h
jmp rows
finish:
mov ah, 1 ; wait for a key before end a program
int 21h
mov ax,4c00h ;set ah and al in one go and ends programo
int 21h
答案 1 :(得分:0)
编辑:
您应该更改代码:
dec bx
mov cx,3
cmp cx,bx
JZ ifnull
ifnull:
dec ah
int 21h
jnz rows
用这个1:
dec bx
push cx
mov cx,3
cmp cx,bx
jnz rows ;will jupm to rows if not z
dec ah ;will continue the flow (if z)
int 21h
要做到这一点,你需要在行之前的某个地方把3放在CX中并在更改之前将其推入行中
;"I need to do rows 2 times after successful ifnull"
pop cx
pop cx;u need to push cx before rows somewhere
dec cx
cmp cx,0
jb rows
编辑后:
dec ah ; wait for a key
int 21h
这个1错了:
dec ah ;02h - 1 = 01h; wait for a key before end a program
int 21h
早些时候你把02h移到了啊,但已经减少了,在这里:
dec ah ; wait for a key -> here it is 01h
int 21h
dec ah ;02h - 1 = 01h; wait for a key before end a program -> Now it is 01h - 1 = 00h
int 21h
无论第一个dec ah
是否在循环中
所以你最好用mov ah,01h