?? test.asm
字號:
data segmentmess1 db 'Please input the mark!',0ah,0dh,'$'mess2 db 'The average mark is:',0ah,0dh,'$'buf1 db 60db ?db 60 dup(?)buf2 db 30 dup(?)buf3 db 2 dup(0),'$'data endscode segmentassume cs:code,ds:datastart: mov ax,datamov ds,axlea dx,mess1mov ah,9int 21hcall input lea si,buf1 mov cx,[si+1] and cx,0fh shr cx,1 dec cx lea di, buf2 mov al,[di] L2: inc di add ax,[di] loop L2 div cl call output ;===================================================================================== input proc ;該子程序把輸入的成績轉換成一字節壓縮BCD碼存放 pushf push ax push cx push bx push dx push di mov dx,offset buf1 mov ah,0ah int 21h lea si,buf1 mov dl,0 mov bl,0 mov cx,[si+1] and cx,0fh shr cx,1 lea di,buf2 L1: mov dl,[si+2] ;把輸入的第一個數字給dl sub dl,30h shl dl,1 shl dl,1 shl dl,1 shl dl,1 mov bl,[si+3] ;把輸入的第二個數字給bl sub bl,30h add dl,bl mov [di],dl inc di add si,2 loop L1 pop di pop dx pop bx pop cx pop ax popf ret input endp ;=============================================================================== output proc ;該子程序把BCD碼轉換成asc碼 push bx push cx push dx push si push di mov cl,4 lea si,buf3 mov ah,al mov bl,ah shr bl,cl add bl,30h mov [si],bl and ah,0fh add ah,30h mov [si+1],ah lea dx,mess2 mov ah,9 int 21h mov dx,offset buf3 mov ah,9 int 21h pop di pop si pop dx pop cx pop bx ret output endp code ends end start
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -