IBM-PC汇编语言程序设计(第二版)课后习题答案(清华大学出版社)解析 联系客服

发布时间 : 星期五 文章IBM-PC汇编语言程序设计(第二版)课后习题答案(清华大学出版社)解析更新完毕开始阅读2c291f90ab00b52acfc789eb172ded630a1c986f

MOV ES,AX

MOV EAX,DS:AUGEND ADD EAX,ES:ADDEND MOV DS:SUM,EAX C_SEG ENDS

END START ;结束 19.需要加上PTR伪操作的有: (2)(3)(4)

第五章 1.程序實現:(經DEBUG調試通過) code segment main proc far

assume cs:code start:

mov ah,1h int 21h

sub al,20h mov ah,2 mov dl,al int 21h main endp code ends end start 2.程序實現:(經DEBUG調試通過) code segment

assume cs:code mov ah,1h int 21h sub al,1h mov cl,3 again:

mov dl,al mov ah,2 int 21h inc al loop again code ends end

3.程序實現:(經DEBUG調試通過) code segment

assume cs:code

mov ax,0f0feh

mov cl,4 ;把AX的最高四位

rol ax,cl ;移到最右面

and al,0fh ;再把AL的高四位清0 mov dl,al rol ax,cl and al,0fh mov cl,al rol ax,cl and al,0fh mov bl,al rol ax,cl and al,0fh code ends end

4.程序實現:(經DEBUG調試通過~~) data segment

string1 db 20,0,20 dup (?) string2 db 20,0,20 dup (?)

string3 db 'please input string1!','$' string5 db 'match!','$' string6 db 'nomatch!','$' data ends

code segment

MAIN PROC FAR

assume cs:code, ds:data start:

push ax ;保護現場 push bx push cx push dx mov ax,data mov ds,ax

mov dx,offset string3

call info ;在屏幕上輸出提示信息 mov dx,offset string1

call input ;在第一緩衝區輸入字符串 mov dx,offset string4

call info ;在屏幕上輸出提示信息 mov dx,offset string2

call input ;在第二緩衝區輸入字符串 call check ;比較兩個字符串 pop dx ;寄存器出棧 pop cx pop bx pop ax

main endp

;輸入字符串到緩衝區的過程 INPUT PROC NEAR push ax

mov ah,0AH int 21h pop ax ret INPUT ENDP

;在屏幕上輸出提示信息的過程 INFO PROC NEAR push ax mov ah,9 int 21h

call crlf ;回車換行 pop ax ret INFO ENDP

;回車換行 的過程 CRLF PROC NEAR push dx push ax mov dl,0dh mov ah,2 int 21h mov dl,0ah mov ah,2 int 21h pop ax pop dx ret CRLF ENDP

;比較兩字符串是否相同並且在屏幕上輸出相應信息的過程 CHECK PROC NEAR push ax push cx push si push di mov ax,0 mov cx,0

mov cl,string1+1 mov si,2 mov di,2 re:

mov al,string1[di] cmp al,string2[si] jnz no inc di inc si dec cx jnz re

mov dx ,offset string5 call info jmp exit no:

mov dx,offset string6 call info exit:

pop di pop si pop cx pop ax ret CHECK ENDP code ends end start

5.程序實現:(經DEBUG調試通過) data segment

info1 db 'PLEASE INPUT A NUMBER','$' ;提示信息,下同

info2 db 'WRONG NUMBER! PLEASE INPUT ANOTHER NUMBER!','$' 字值,報錯,並提示輸入新的數字

data ends code segment

MAIN PROC FAR

assume cs:code,ds:data start:

mov ax,data mov ds,ax

mov dx,offset info1

call info ;提示輸入一個數字 call input ;輸入過程

call check ;檢查是否非數字字符 call bell ;響鈴N次,N為鍵入數字 ret MAIN ENDP

;在屏幕上輸出提示信息的過程 INFO PROC NEAR push ax

;如果鍵入非數