第一范文网 - 专业文章范例文档资料分享平台

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

来源:用户分享 时间:2025/5/28 7:43:07 本文由loading 分享 下载这篇文档手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:xxxxxxx或QQ:xxxxxx 处理(尽可能给您提供完整文档),感谢您的支持与谅解。

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

;如果鍵入非數

IBM-PC汇编语言程序设计(第二版)课后习题答案(清华大学出版社)解析.doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.diyifanwen.net/c1q13z5n7k072h8v7sa970wk4t3v47w00u3z_4.html(转载请注明文章来源)
热门推荐
Copyright © 2012-2023 第一范文网 版权所有 免责声明 | 联系我们
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:xxxxxx 邮箱:xxxxxx@qq.com
渝ICP备2023013149号
Top