杂记
 


ASM

作者:  2011-10-03 00:00:00     分类:Windows     标签:

dseg segment meg1 db 'Input a operator(+,-,*,/),please,and input the result:$' meg2 db 'The answer is error,retry!$' meg3 db 'The answer is over flow,retry!$' meg4 db 'Sorry,You have make a mistake 3 times!$' meg5 db 'The answer is right! You gain 10!$' meg6 db 'Total Right Error Score Rate$' meg7 db 'Press <ESC> to exit$' meg8 db 'Are you sure to exit program(Y/N)?','$' meg9 db 'Press <Enter> to continue...$' meg10 db 'The answer contain unlegal char,retry!$' meg11 db 'Are you sure to exit program?(Y/N)$' meg12 db ' $' meg13 db 'You have not input result yet,retry!$' meg14 db 'BASE OPRATION EXERCISE$' meg15 db 'The right result is:$' calin db ? dig1 dw ? dig2 dw ? score dw 0 flags db ? inans dw ? rians dw ? nonum db ? curx db ? cury db ? cury1 db ? count dw 3 total dw 0 ;´íÎó: sigcrlf db 0 qukey db 0 flag1 db ? flag2 db ? dseg ends cseg segment main proc far assume cs:cseg,ds:dseg start: push ds sub ax,ax push ax mov ax,dseg mov ds,ax repeat: call clrscr ;ÇåÆÁ call window call getnum ;µ÷Óùý³ÌÈ¡µÚÒ»¸öÊý mov dig1,ax call incalcu add total,1 mov curx,30 mov cury,16 call procurs lea dx,meg9 mov ah,9 int 21h repe_1: mov ah,8 int 21h cmp al,1bh jz quitall_2 cmp al,0dh jnz repe_1 jmp repeat quitall_2: call escquit jmp repeat ret main endp incalcu proc near ;ÊäÈëÔËËã·û mov count,3 mov cury1,10 inkey: call window mov curx,14 ;Öùâ±êÓÚ(20,5) mov cury,7 call procurs ;µ÷ÓÃÖùâ±ê¹ý³Ì lea dx,meg1 ;Êä³öÌáʾ mov ah,9 int 21h inkey1: mov ah,7 int 21h cmp al,1bh jz quitall_1 cmp al,'+' je disp1 cmp al,'-' je disp1 cmp al,'*' je disp1 cmp al,'/' je disp1 jmp inkey1 ;end of input cacer disp1: mov calin,al ;display cacer mov dl,al mov ah,02h int 21h repeat1: mov ah,8 int 21h cmp al,0dh jnz repeat1 call crlf ;»Ø³µ cmpcal: mov al,calin cmp al,'+' ;cmpare the cacers jz signadd cmp al,'-' jz signsub cmp al,'*' jz signmul cmp al,'/' jz signdiv jmp exitinc signadd: call procadd jmp exitinc signsub: call procsub jmp exitinc signmul: call procmul jmp exitinc signdiv: call procdiv jmp exitinc exitinc: ret quitall_1: call escquit jmp inkey incalcu endp cmpans proc near mov ax,rians cmp ax,inans jnz error1 right: mov cx,score inc cx mov score,cx lea bx,meg5 call msgout jmp exitcm error1: mov ax,count cmp ax,1 jz again lea bx,meg2 call msgout again: call warnout mov cx,count dec cx jz exiter mov count,cx mov curx,30 mov cl,cury1 inc cl mov cury1,cl mov cury,cl call outcacer call inanswer call cmpans jmp exitcm exiter: lea bx,meg4 call msgout mov curx,30 ;Öùâ±êÓÚ(20,5) mov cury,14 call procurs ;µ÷ÓÃÖùâ±ê¹ý³Ì lea dx,meg15 ;Êä³öÌáʾ mov ah,9 int 21h mov bx,rians call outcalcu exitcm: ret cmpans endp procadd proc near ;"+" ÔËËã×Ó¹ý³Ì call getnum mov dig2,ax mov curx,30 ;Öùâ±êÓÚ(20,5) mov cury,10 call outcacer mov ax,dig2 add ax,dig1 mov rians,ax call inanswer ;½ÓÊÕ´ð°¸ call cmpans ret procadd endp procsub proc near ;"-" ÔËËã×Ó¹ý³Ì call getnum mov dig2,ax cmp ax,dig1 jg change return1: mov curx,30 ;Öùâ±êÓÚ(20,5) mov cury,10 call outcacer ;display num1,um2 and cacer mov ax,dig1 sub ax,dig2 mov rians,ax call inanswer call cmpans jmp exitsub change: mov ax,dig2 xchg ax,dig1 mov dig2,ax jmp return1 exitsub: ret procsub endp procmul proc near ;"*" ÔËËã×Ó¹ý³Ì call getnum mov dig2,ax mov curx,30 ;Öùâ±êÓÚ(20,5) mov cury,10 call outcacer mov ax,dig1 mul dig2 mov rians,ax call inanswer ;½ÓÊÕ´ð°¸ call cmpans ret procmul endp procdiv proc near ;"/" ÔËËã×Ó¹ý³Ì mov calin,246d getseed: call getnum cmp ax,0 jz getseed mov dig2,ax mov bx,dig1 cmp bx,0 jz next3 cmp ax,dig1 jl next1 xchg ax,dig1 mov dig2,ax next1: mov ax,dig1 mov dx,0 div dig2 cmp dx,0 jz next2 sub
更多
阅读(766)     评论(0)