微机原理与接口技术课后答案清华版.pdf_第1页
微机原理与接口技术课后答案清华版.pdf_第2页
微机原理与接口技术课后答案清华版.pdf_第3页
微机原理与接口技术课后答案清华版.pdf_第4页
微机原理与接口技术课后答案清华版.pdf_第5页
已阅读5页,还剩5页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

微机原理、汇编与接口技术(朱定华 编著) 第三章习题参考答案一 作者:华中科技大学 释梵 本参考答案绝大多数经过上机测试,但因作者水平有限,一定尚有缺漏, 希望大家批评指正,QQ:564630776,本参考答案将有绪本,不得用于商 业用途! The answers below use the macros like this: standardstack macro stack segment stack stack dw 32 dup(0) stack ends endm standardstart macro begin proc far assume ss:stack,cs:code,ds:data push ds sub ax,ax push ax mov ax,data mov ds,ax endm 3.1 编写程序实现下列运算(式中W 为字变量,B 为字节变量,不考虑溢出,除法余数不再 参与运算) 说实话,不考虑溢出,令我很费解,这样的得数还有意义吗?但是回头一想,单从作作业的 角度来看倒是省了不少脑子,呵呵,那我就不考虑了。 (1) W1+W2+28-W3-W4 if1 include MACRO.LIB endif standardstack datasegment W1 dw 12 W2 dw 34 W3 dw 21 W4 dw 0 dataends codesegment standardstart mov ax,W1 add ax,W2 add ax,28 sub ax,W3 mov W4,ax ret beginendp codeends end begin (2)(W1-W2)/10-W3.W4 if1 include MACRO.LIB endif standardstack datasegment W1 dw 12 W2 dw 34 W3 dw 0 W4 dw 0 dataends codesegment standardstart mov ax,W1 sub ax,W2 mov dl,10 idiv dl mov bl,al mov bh,0 mov cl,ah mov ch,0 mov W3,bx mov W4,cx ret beginendp codeends end begin (3)(B1*B2)/(B3+6)-B4.B5 if1 include MACRO.LIB endif standardstack datasegment B1 db 1 B2 db 2 B3 db 3 B4 db 0 B5 db 0 dataends codesegment standardstart mov al,B1 imul B2 mov bl,B3 add bl,6 idiv bl mov B4,al mov B5,ah ret beginendp codeends end begin (4)(B1+B2-B3)/B4*B5)/2-W if1 include MACRO.LIB endif standardstack datasegment B1 db 5 B2 db 4 B3 db 3 B4 db 2 B5 db 1 Wdw 0 dataends codesegment standardstart mov bl,B1 add bl,B2 sub bl,B3 mov al,B4 mul B5 xchg bx,ax idiv bx mov cl,2 idiv cl mov byte ptr W,al ret beginendp codeends end begin 3.2 编写程序段实现下列BCD 数运算(式中字节变量 B 和AB 分别为压缩BCD数和非压缩 BCD 数,字节变量 W 为压缩BCD数) (1)B1+B2-(B3-B4)-B5 if1 include MACRO.LIB endif standardstack datasegment B1 db 19H B2 db 38H B3 db 44H B4 db 15H B5 db 00H dataends codesegment standardstart mov al,B1 add al,B2 DAA add al,B4 DAA sub al,B3 DAS mov B5,al ret beginendp codeends end begin (2)W1+W2-W3 if1 include MACRO.LIB endif standardstack datasegment W1 dw 4455H W2 dw 6677H W3 dw 0000H dataends codesegment standardstart mov al,byte ptrW1 add al,byte ptrW2 DAA mov byte ptrW3,al mov al,byte ptrW1+1 adc al,0 DAA add al,byte ptrW2+1 DAA mov byte ptrW3+1,al ;here we ignore the highest cf according to the subject ret beginendp codeends end begin (3)AB1*AB2/AB3-AB4 if1 include MACRO.LIB endif standardstack datasegment AB1db 07H AB2db 08H AB3db 09H AB4db 00H dataends codesegment standardstart mov ah,0 mov al,AB1 AAD mov bl,al mov al,AB2 AAD mul bl mov cx,ax mov ah,0 mov al,AB3 AAD mov dl,al mov ax,cx div dl AAM mov AB4,al ret beginendp codeends end begin (4)AB1*10+AB2-B if1 include MACRO.LIB endif standardstack datasegment AB1db 07H AB2db 08H Bdb 00H dataends codesegment standardstart mov ah,0 mov al,AB1 AAD mov cl,10 mul cl push ax mov al,AB2 AAD mov bx,ax pop ax add ax,bx AAM mov cl,4 shl ah,cl or al,ah mov B,al ret beginendp codeends end begin 3.3 写出执行下列程序段的中间结果和结果 (1)0048 0702 (2)0059 0411010704 (3)0101 0107 (4)这里的mov dl,10 因为我理解题意为十进制数10 005A09000908 (5)62 (6)0248 3.4 编写程序,将字节变量BVAR 中的压缩BCD数转换为二进制数,并存入原变量中。 if1 include MACRO.LIB endif standardstack datasegment bvardb 78H dataends codesegment standardstart mov al,bvar mov ah,al mov cl,4 shr ah,cl and al,0FH aad mov bvar,al ret beginendp codeends end begin 3.5 编写程序,求字节变量W1 和W2中的非压缩BCD数之差(W1-W2、W1=W2),将差 存到字节变量B3中。 if1 include MACRO.LIB endif standardstack datasegment W1 dw 0708H W2 dw 0504H B3 db 00H dataends codesegment standardstart mov ax,W1 mov cl,4 shl ah,cl or al,ah mov bl,al mov ax,W2 shl ah,cl or al,ah xchg al,bl sub al,bl das mov B3,al ret beginendp codeends end begin 3.6 编写求两个4 位非压缩BCD 数之和,将和送显示器显示的程序。 if1 include MACRO.LIB endif standardstack datasegment W1 db 0,4,0,5,0,6,0,7 W2 db 0,1,0,2,0,3,0,9 resultdb 5 dup(0),$ dataends codesegment standardstart mov cx,4 mov ax,0 mov si,7 mov di,4 bitand: add al,byte ptr W1si aaa add al,byte ptr W2si aaa add al,30H mov resultdi,al sub si,2 dec di mov al,ah mov ah,0 loop bitand add al,30H mov resultdi,al mov dx,offset result cmp result0,30H jne show inc dx show:mov ah,9 int 21H ret beginendp codeends end begin 3.7 编写求两个4 位压缩BCD 数之和,将和送显示器显示的程序。 if1 include MACRO.LIB endif standardstack datasegment W1 db 56H,18H W2 db 97H,42H resultdb 5 dup(0),$ dataends codesegment standardstart mov al,byte ptr W11 add al,byte ptr W21 daa mov ah,al and ah,0F0H mov cl,4 shr ah,cl and al,0FH add al,30H add ah,30H mov result4,al mov result3,ah mov ax,0 adc al,byte ptr W1 add al,byte ptr W2 daa jnc omit mov result,31H omit:mov ah,al and ah,0F0H mov cl,4 shr ah,cl and al,0FH add al,30H add ah,30H mov result2,al mov result1,ah mov al,result sub al,31H jz show mov dx,off

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论