1.顺序程序设计。编写一段程序,在内存中自SQTAB(0200H)地址开始的10个单元中存放0-9的平方值。要求利用简单查表法求NUM(0210H)单元中指定数(0-9)的平方值,并将所求平方值存入RESULT(0211H)单元。
2.分支程序设计,用地址表法完成。根据MODE单元中的模式字(0-7)分别转向L0-L7标号处执行。L0-L7分别完成显示'0'-'7'字符。即:当MODE=0时,转L0标号,完成显示'0';当MODE=1时,转L1标号,完成显示'1'......
3.循环程序设计。从数据段的一个数据区中,定义了100H个八位无符号数,要求找出最大数和最小数,分别存MAX和MIN单元,并显示输出。
4.子程序设计。编写一个子程序,使他能接受从键盘输入的4位十进制数,并转换成对应的二进制数存在DX寄存器中,并给出主程序的调用方式。
5 个解决方案
#1
自己UP
#2
1
data_seg segment
ORG 0200h
SQTAB DB 0,1,4,9,10h,17h,24h,31h,40h,51h
NUM DB ?
RESULT DB ?
data_seg ends
;
code_seg segment
assume cs:code_seg,ds:data_seg,es:data_seg
start:
mov ax,data_seg
mov ds,ax
mov es,ax
lea bx,SQTAB
mov al,NUM
xlat
mov RESULT,al
hlt
code_seg ends
end start
;
data_seg segment
ORG 0200h
SQTAB DB 0,1,4,9,10h,17h,24h,31h,40h,51h
NUM DB ?
RESULT DB ?
data_seg ends
;
code_seg segment
assume cs:code_seg,ds:data_seg,es:data_seg
start:
mov ax,data_seg
mov ds,ax
mov es,ax
lea bx,SQTAB
mov al,NUM
xlat
mov RESULT,al
hlt
code_seg ends
end start
;
#3
已发邮件并接分。
#4
2
data_seg segment
LADDRESS DW L0_Address
DW L1_Address
......
DW L7_Address
MODE DB ?
data_seg ends
;
code_seg segment
assume cs:code_seg,ds:data_seg,es:data_seg
start:
mov ax,data_seg
mov ds,ax
mov es,ax
lea bx,LADDRESS
xor ax,ax
mov al,MODE
mul type LADDRESS
add bx,ax
jmp word ptr [bx]
L0:
mov dl,30h
jmp outputchar
L1:
mov dl,31h
jmp outputchar
...........
L7:
mov dl,37h
outputchar:
mov ah,02
int 21
hlt
code_seg ends
end start
;
data_seg segment
LADDRESS DW L0_Address
DW L1_Address
......
DW L7_Address
MODE DB ?
data_seg ends
;
code_seg segment
assume cs:code_seg,ds:data_seg,es:data_seg
start:
mov ax,data_seg
mov ds,ax
mov es,ax
lea bx,LADDRESS
xor ax,ax
mov al,MODE
mul type LADDRESS
add bx,ax
jmp word ptr [bx]
L0:
mov dl,30h
jmp outputchar
L1:
mov dl,31h
jmp outputchar
...........
L7:
mov dl,37h
outputchar:
mov ah,02
int 21
hlt
code_seg ends
end start
;
#5
data_seg segment
SQTAB DB 100h DUP(?)
MAX DB ?
MIN DB ?
data_seg ends
;
code_seg segment
assume cs:code_seg,ds:data_seg,es:data_seg
start:
mov ax,data_seg
mov ds,ax
mov es,ax
lea bx,SQTAB
xor ax,ax
mov cx,100h
Loopup:
mov dl,BYTE PTR [bx]
cmp al,dl
jb maxnum
cmp ah,dl
jnb minnum
maxnum:
mov al,dl
jmp next
minnum:
mov ah,dl
next:
inc bx
loop Loopup
mov MAX,al
mov MIN,ah
;显示部分略。下班了,要回家。
hlt
code_seg ends
end start
;
SQTAB DB 100h DUP(?)
MAX DB ?
MIN DB ?
data_seg ends
;
code_seg segment
assume cs:code_seg,ds:data_seg,es:data_seg
start:
mov ax,data_seg
mov ds,ax
mov es,ax
lea bx,SQTAB
xor ax,ax
mov cx,100h
Loopup:
mov dl,BYTE PTR [bx]
cmp al,dl
jb maxnum
cmp ah,dl
jnb minnum
maxnum:
mov al,dl
jmp next
minnum:
mov ah,dl
next:
inc bx
loop Loopup
mov MAX,al
mov MIN,ah
;显示部分略。下班了,要回家。
hlt
code_seg ends
end start
;
#1
自己UP
#2
1
data_seg segment
ORG 0200h
SQTAB DB 0,1,4,9,10h,17h,24h,31h,40h,51h
NUM DB ?
RESULT DB ?
data_seg ends
;
code_seg segment
assume cs:code_seg,ds:data_seg,es:data_seg
start:
mov ax,data_seg
mov ds,ax
mov es,ax
lea bx,SQTAB
mov al,NUM
xlat
mov RESULT,al
hlt
code_seg ends
end start
;
data_seg segment
ORG 0200h
SQTAB DB 0,1,4,9,10h,17h,24h,31h,40h,51h
NUM DB ?
RESULT DB ?
data_seg ends
;
code_seg segment
assume cs:code_seg,ds:data_seg,es:data_seg
start:
mov ax,data_seg
mov ds,ax
mov es,ax
lea bx,SQTAB
mov al,NUM
xlat
mov RESULT,al
hlt
code_seg ends
end start
;
#3
已发邮件并接分。
#4
2
data_seg segment
LADDRESS DW L0_Address
DW L1_Address
......
DW L7_Address
MODE DB ?
data_seg ends
;
code_seg segment
assume cs:code_seg,ds:data_seg,es:data_seg
start:
mov ax,data_seg
mov ds,ax
mov es,ax
lea bx,LADDRESS
xor ax,ax
mov al,MODE
mul type LADDRESS
add bx,ax
jmp word ptr [bx]
L0:
mov dl,30h
jmp outputchar
L1:
mov dl,31h
jmp outputchar
...........
L7:
mov dl,37h
outputchar:
mov ah,02
int 21
hlt
code_seg ends
end start
;
data_seg segment
LADDRESS DW L0_Address
DW L1_Address
......
DW L7_Address
MODE DB ?
data_seg ends
;
code_seg segment
assume cs:code_seg,ds:data_seg,es:data_seg
start:
mov ax,data_seg
mov ds,ax
mov es,ax
lea bx,LADDRESS
xor ax,ax
mov al,MODE
mul type LADDRESS
add bx,ax
jmp word ptr [bx]
L0:
mov dl,30h
jmp outputchar
L1:
mov dl,31h
jmp outputchar
...........
L7:
mov dl,37h
outputchar:
mov ah,02
int 21
hlt
code_seg ends
end start
;
#5
data_seg segment
SQTAB DB 100h DUP(?)
MAX DB ?
MIN DB ?
data_seg ends
;
code_seg segment
assume cs:code_seg,ds:data_seg,es:data_seg
start:
mov ax,data_seg
mov ds,ax
mov es,ax
lea bx,SQTAB
xor ax,ax
mov cx,100h
Loopup:
mov dl,BYTE PTR [bx]
cmp al,dl
jb maxnum
cmp ah,dl
jnb minnum
maxnum:
mov al,dl
jmp next
minnum:
mov ah,dl
next:
inc bx
loop Loopup
mov MAX,al
mov MIN,ah
;显示部分略。下班了,要回家。
hlt
code_seg ends
end start
;
SQTAB DB 100h DUP(?)
MAX DB ?
MIN DB ?
data_seg ends
;
code_seg segment
assume cs:code_seg,ds:data_seg,es:data_seg
start:
mov ax,data_seg
mov ds,ax
mov es,ax
lea bx,SQTAB
xor ax,ax
mov cx,100h
Loopup:
mov dl,BYTE PTR [bx]
cmp al,dl
jb maxnum
cmp ah,dl
jnb minnum
maxnum:
mov al,dl
jmp next
minnum:
mov ah,dl
next:
inc bx
loop Loopup
mov MAX,al
mov MIN,ah
;显示部分略。下班了,要回家。
hlt
code_seg ends
end start
;