微机原理与接口技术李珍香版课后习题4参考答案

发布时间 : 星期二 文章微机原理与接口技术李珍香版课后习题4参考答案更新完毕开始阅读

s6 db s5 db DATA ENDS code segment

assume cs:code,ds:data start:

mov ax,data mov ds,ax mov cx,s10-grad call count mov ah,4ch int 21h count proc near mov si,0 next:mov al,grad[si] mov ah,0 mov bx,10 div bl cbw mov bx,ax sub bx,10 neg bx inc s10[bx] inc si loop next ret count endp code ends end start

将AX寄存器中的16位数据分成4组(从高到低),每组4位,然后把这四组数作为数当中的低4位分别放在AL、BL、CL和DL中。

参考程序: code segment assume cs:code start: MOV BX,AX MOV DX,AX MOV CL,4 SHR AH,CL MOV AL,AH MOV BL,BH AND BL,0FH MOV DH,DL SHR DH,CL

MOV CL,DH mov ah,4ch int 21h code ends end start

设有两个16位整数变量A和B,试编写完成下述操作的程序: (1)若两个数中有一个是奇数,则将奇数存入A中,偶数存入B中。 (2)若两个数均为奇数,则两数分别减1,并存回原变量中。 (3)若两个数均为偶数,则两变量不变。 参考程序: DATA SEGMENT a dw b dw DATA ENDS code segment

assume cs:code,ds:data start:

mov ax,data mov ds,ax lop: mov ax,a mov bx,b xor ax,bx test ax,0001H jz next test bx,0001H jz exit xchg bx,a mov b,bx jmp exit next:test bx,0001h jz exit dec b dec a exit:mov ah,4ch int 21h code ends end start

设有一段英文,其字符变量名为ENG,并以$字符结束。试编写一程序,查找单词“is”在该文中的出现次数,并将次数显示出来。(英文内容由用户自己定义)

参考程序: DATA SEGMENT

ENG db 'this is an program example$' n1 equ $-eng str db 'is'

n2 equ $-str DATA ENDS code segment

assume cs:code,ds:data,es:data start:

mov ax,data mov ds,ax mov es,ax xor dx,dx mov cl,n1 xor ch,ch cmp cx,n2 jbe disp mov al,str lea di,eng cld search:

repne scasb jne disp mov bl,str+1 cmp es:[di],bl je exist jcxz disp lop: jmp search exist:inc dl cmp cx,1 jz disp jmp lop disp: or dl,30h mov ah,2 int 21h mov ah,4ch int 21h code ends end start

请编写程序实现以下功能:设在A、B和C单元中分别存放着一个8位带符号数。试比较这3个数,若3个数都不是0,则求出3数之和并存放于D单元中;若其中有一个数为0,则把其它两个单元也清零。

参考程序: DATA SEGMENT a Db 10 b db -10 c db 30 d db DATA ENDS

code segment

assume cs:code,ds:data start:

mov ax,data mov ds,ax xor dx,dx cmp a,0 jz next mov dl,a cmp b,0 jnz lop1 next:mov b,0 mov c,0 mov a,0 jmp exit lop1:add dl,b cmp c,0 jz next add dl,c mov d,dl exit:mov ah,4ch int 21h code ends end start

从键盘输入一系列字符(以回车符结束),并按字母、数字及其它字符分类计数,最后显示出这三类的计数结果。

参考程序: data segment

s db ;统计字符 d db ;统计数字 o db ;统计其它字符 code segment

assume cs:code,ds:data start:

mov ax,data mov ds,ax lop: mov ah,1 int 21h cmp al,0dh jz disp cmp al,30h jb other cmp al,39h jbe shu

cmp al,41h jb other cmp al,5ah jbe str cmp al,61h jb other cmp al,7ah jbe str jmp lop other:inc o jmp lop shu: inc d jmp lop str: inc s jmp lop disp:

mov dl,0ah mov ah,2 int 21h mov dl,0dh mov ah,2 int 21h mov dl,s or dl,30h mov ah,2 int 21h mov dl,d or dl,30h int 21h mov dl,o or dl,30h int 21h mov ah,4ch int 21h code ends end start

联系合同范文客服:xxxxx#qq.com(#替换为@)