微机原理与应用-课后编程题-裘雪红版(2)

2020-04-14 02:54

3-9、将BUFFER下100个8位无符号数按大小顺序排列,试编程。

data segment

buffer db 0f7h,0f9h,0f1h,…… data ends

stack segment para stack 'stack' db 100 dup(?) stack ends code segment assume cs:code,ds:data,ss:stack begin: mov ax,data mov ds,ax lea di,buffer mov bl,99 next0: mov si,di mov cl,bl next3: mov al,[si] add si,1 cmp al,[si] jnc next5 ;cf=0,jump mov dl,[si] mov [si-1],dl mov [si],al next5: dec cl jnz next3 ;zf=0,jump dec bl jnz next0 mov ah,4ch int 21h code ends end begin

5

3-10、在BVFF单元中有一个BCD数A,试写程序,计算Y,结果送DES单元。 其中

?3A(A?20)Y=??A?20(20?A?60)

??80(A?60)data segment bvff db 80h des db ? data ends

stack segment para stack 'stack'

db 10 dup(?) stack ends

code segment

assume cs:code,ds:data,ss:stack begin: mov ax,data mov ds,ax

mov al,bvff cmp al,20h jnbe next1 ;cf=zf=0,>jump, mov bl,al add al,bl daa add al,bl daa jmp

next3

next1: cmp al,60h jc next2 ;cf=1,<,jump

mov al,80h

next2: jmp next3

mov bl,al

sub das jmp

next3: mov mov int code ends

end

al,20h next3

des,al ah,4ch 21h begin 3-14试编程序,统计由40000H开始的16K个单元中所存放的字符“A”的个数,并将结果存放在DX中。

(下面是统计从S1开始处,连续14个单元的字符串中字符“a”的个数)。 data segment

s1 db 'hoawareayoauaa' data ends stack segment db 200 dup(?) stack ends code segment assume

cs:code,ds:data,ss:stack,es:data start: mov ax,data mov ds,ax mov es,ax mov ax,offset s1 mov si,ax dec si xor dx,dx mov cx,14 mov al,’a’ scan: inc si cmp al,[si] jnz next inc dx next: loop scan mov ah,4ch int 21h code ends end start

6

二、练习题:

1、显示字符How are you! data segment

s1 db 'How are you!','$' data ends

stack segment para stack db 64 dup(?) stack ends code segment

assume cs:code,ds:data start: mov ax,data mov ds,ax mov ah,9h

mov dx,offset s1 int 21h mov ah,4ch int 21h code ends end start

2、ASCII码运算。求3+5=?,并且将结果显示输出。

code segment

assume cs:code start: mov al,33h mov dl,35h add dl,al sub dl,30h mov ah,02h int 21h mov ah,4ch

7

int 21h code ends end start

3、二进制数转换成码程序。ASCII

data segment binnum dw 4fffh ascbcd db 5 dup(?) data ends

stack segment para stack 'stack' db 200 dup(?) stack ends code segment

assume cs:code,ds:data,es:data,ss:stack binasc: mov ax,data mov ds,ax mov es,ax mov cx,5

xor dx,dx ;dx=0 mov ax,binnum mov bx,10

mov di,offset ascbcd binasc1:div bx

add dl,30h mov [di],dl inc di and ax,ax jz stop mov dl,0 loop binasc1 stop: mov ah,4ch int 21h code ends

end binasc

4、二进制数转换成ASCII码,并显示。 data segment binnum dw 4fffh ascbcd db 5 dup(?) data ends

stack segment para stack 'stack' db 200 dup(?) stack ends code segment

assume cs:code,ds:data,es:data,ss:stack start: mov ax,data mov ds,ax mov es,ax mov cx,5

xor dx,dx ;dx=0 mov ax,binnum mov bx,10

mov di,offset ascbcd push di binasc1:div bx

add dl,30h mov [di],dl inc di and ax,ax jz stop mov dl,0 loop binasc1 stop: pop bx mov si,di stop1: dec si mov dl,[si] mov ah,02h int 21h push bx cmp bx,si pop bx

8

jl

stop1

mov ah,4ch int 21h

code ends end start

5、m n w分别为三个8位无符号数,求q=n×m-w,然后将q用16进制数显示输出。 data segment m equ 6

n equ

8

w equ 9 data_1 db m,n,w data ends stack segment para stack db 64 dup(?)

stack ends code segment assume cs:code,ds:data start: lea si,data_1 mov ax,data mov ds,ax mov al,[si] mov bl,[si+1] mul bl mov bx,0 mov bl,[si+2] sub ax,bx mov bx,ax mov ch,4 rotate: mov

cl,4

rol bx,cl

mov al,bl and

al,0fh add al,30h cmp al,3ah jl printit add al,7h printit: mov dl,al mov ah,2 int 21h dec ch jnz rotate mov ah,4ch int 21h

code ends end start

6、m n w分别为三个8位无符号数,求q=n×m-w,然后将q用ASCII码显示输出。 data segment m equ 6

n equ 8 w equ 9 ascbcd db 5 dup(?) data_1 db m,n,w

data ends stack segment para stack db 200 dup(?) stack ends code segment assume

cs:code,ds:data,es:data,ss:stack start: lea

si,data_1

9

mov ax,data mov ds,ax mov al,[si] mov bl,[si+1] mul bl mov bx,0 mov bl,[si+2] sub ax,bx push ax

binasc: mov ax,data mov ds,ax mov es,ax mov cx,5 xor dx,dx pop bx mov ax,bx mov bx,10

mov di,offset ascbcd push di binasc1:div bx

add dl,30h mov [di],dl inc di and ax,ax jz stop mov dl,0 loop binasc1 stop: pop bx mov si,di stop1: dec si mov dl,[si] mov ah,02h int 21h push bx cmp bx,si pop bx jl stop1

mov ah,4ch int 21h

code ends end start

7、编写10个字节之和,并显示结果的程序。 data segment data_1 db 0ffh,0ffh,0ffh,0ffh,0ffh,0ffh,0ffh,0ffh,0ffh,0ffh data ends stack segment para stack db 200 dup(?) stack ends code segment assume

cs:code,ds:data,es:data,ss:stack start: mov ax,data mov ds,ax mov cx,10 lea si,data_1 xor ax,ax xor dx,dx

trsmt: mov bl,[si] add al,bl adc ah,0

10

inc dec jnz push pop

mov rotate1: mov rol mov and add cmp jl

add printit1: mov mov int dec jnz mov int code ends end start

si cx trsmt ax bx ch,4 cl,4 bx,cl al,bl al,0fh al,30h al,3ah printit1 al,7h dl,al ah,2 21h ch rotate1 ah,4ch 21h


微机原理与应用-课后编程题-裘雪红版(2).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:美容美发行业APP解决方案

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: