📄 nxr2.asm
字号:
cls macro al1,bh1,ch1,cl1,dh1,dl1 ; 窗口
push cx
push ax
push dx
push bx
mov ah,6h
mov al,al1
mov bh,bh1
mov ch,ch1
mov cl,cl1
mov dh,dh1
mov dl,dl1
int 10h
pop bx
pop dx
pop ax
pop cx
endm
app macro opt ; 二进制转十进制
push ax
push bx
push dx
mov al,opt
cbw
mov bl,10
div bl
mov bh,ah
mov dl,al
add dl,30h
mov ah,02h
int 21h
mov dl,bh
add dl,30h
mov ah,02h
int 21h
pop dx
pop bx
pop ax
endm
put macro pa ;字符串输出
push dx
push ax
lea dx,pa
mov ah,09h
int 21h
pop ax
pop dx
endm
sign macro opt ; 字符输出
push dx
push ax
mov dl,opt
mov ah,02h
int 21h
pop ax
pop dx
endm
locate macro dh1,dl1 ;定坐标
mov ah,2h
mov bh,0
mov dh,dh1
mov dl,dl1
int 10h
endm
data segment
str db '***** welcome to the test *****',0ah,0dh,'$'
str1 db 'please press " enter " to enter.',0ah,0dh,'$'
str2 db'please press " q "to quit.',0ah,0dh,'$'
str3 db'the number of the right answer is:','$'
str4 db 'your score is:' ,'$'
str5 db' you want continue?', '$'
string5 db 'when you want to test again' ,0ah,0dh,'$'
string6 db ' please press "y" ' ,0ah,0dh ,'$'
string7 db 'or please press n ',0ah,0dh,'$'
string8 db'your score is :100',0ah,0dh,'$'
number db 'please input a number:','$'
number0 db 0
number1 db 0
buff db 0,0
buff1 db ?
result1 db 'right!',0ah,0dh,'$'
result2 db 'wrong!',0ah,0dh,'$'
line db 0ah,0dh,'$'
s1 db '******* * * * * * * * **** ' , '$'
s2 db ' * * * * * * * * * * * ' , '$'
s3 db ' * ******* * * * * * ** **** ' , '$'
s4 db ' * * * * * * * * * * * * * ', '$'
s5 db ' * * * * * * * * * **** ' , '$'
data ends
;*************************************************
code segment
main proc far
assume cs:code,ds:data
start:
mov ax,data
mov ds,ax
call mian
s: mov number0,0
mov number1,0
cls 0,1eh,0,0,24,79
cls 0,30h,3,0,24,36
cls 0,20h,1,1,1,78
cls 0,0e4h,3,38,24,78
locate 1,20
put number
call tra_b
mov bh,0
mov bp,bx
cbw
mov number0,bl
locate 3,0
locate1:
call jia
jmp lope1
lope: jmp s
lope1:call tra_b
cmp dl,bl
je f
put result2
jmp b
f: inc number1
put result1
mov ah,02h
mov dl,07h
int 21h
b: dec bp
jnz locate1
call pan
locate 11,40
put str5
w:mov ah,07h
int 21h
cmp al,'y'
je lope
cmp al,'Y'
je lope
cmp al,'n'
je exit
cmp al,'N'
je exit
jmp w
;call back
;jne exit
;jmp s
exit: call th
mov ah,4ch
int 21h
;***************************
mian proc near
cls 0,9eh,0,0,24,79
cls 0,44h,4,18,21,59
cls 0,0a8h,5,20,10,57
cls 0,0e4h,10,20,20,57
locate 7,22
mov ah,09h
lea dx,str
int 21h
locate 12,25
mov ah,09h
lea dx,str1
int 21h
locate 14,25
mov ah,09h
lea dx,str2
int 21h
a: mov ah,07h
int 21h
cmp al,'q'
jne e
mov ah,4ch
int 21h
e:cmp al,13
jne a
ret
mian endp
;**************************
tra_b proc near ; 十进制转换二进制
push ax
mov bh,10d
mov bl,0
mov ah,01h
int 21h
sub al,'0'
mov bl,al
c:mov ah,01h
int 21h
;cmp al,1bh
;je c
cmp al,0dh
je return0
sub al,'0'
xchg al,bl
mul bh
add bl,al
jmp c
return0: put line
pop ax
ret
tra_b endp
;*************************
jia proc near
mov ah,2ch ;运算
int 21h
mov dh,0
mov [buff+0] ,dl
app [buff+0]
sign '+'
push cx
wait1: mov cx,500 ; 延时
delay: push cx
mov cx,100
delay1:loop delay1
pop cx
loop delay
dec bx
jnz wait1
pop cx
mov ah,2ch
int 21h
mov dh,0
mov [buff+1],dl
app [buff+1]
sign '='
mov si,word ptr [buff+1]
add si,word ptr [buff+0]
mov dx,si
ret
jia endp
;*************************************************
pan proc near
locate 20,0
put str3
mov cl,number1
app cl
cmp number0 ,cl
je p
locate 21,32
put line
put str4
mov ax,100d
mul cl
mov bl,number0
div bl
mov cl,al
app cl
jmp q
put line
p:locate 21,0
put string8
q:locate 15,40
put string5
locate 16,40
put string6
locate 17,40
put string7
ret
pan endp
;*************************************************
th proc near
cls 0,9eh,0,0,24,79
locate 10,10
put s1
locate 11,10
put s2
locate 12,10
put s3
locate 13,10
put s4
locate 14,10
put s5
ret
th endp
main endp
code ends
end start
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -