微机原理实验编程题(完整)

1)(正确)比较两个无符号数的大小(量个数放在内存S3的连续两个单元中),将大数存入MAX单元中。

DATAS SEGMENT

BUF DB 1,2

CNT EQU $-BUF

DATAS ENDS

CODES SEGMENT

ASSUME CS:CODES,DS:DATAS

START:

MOV AX,DATAS

MOV DS,AX

MOV CX,CNT-1

LEA BX,BUF

MOV AL,[BX]

L2: INC BX

CMP AL,[BX]

JAE L1

MOV AL,[BX]

L1:LOOP L2

ADD AL,30H

MOV DL,AL

MOV AH,2

INT 21H

MOV AH,4CH

INT 21H

CODES ENDS

END STAR

2)(正确)试编一程序,求三个带符号数据中的最大值,并将最大值存入MAX单元中,设三个带符号数分别在三个变量X,Y,Z中存储。

DATAS SEGMENT

X DB 5

Y DB-2

Z DB 0

MAX DB?

DATAS ENDS

CODES SEGMENT

ASSUME CS:CODES,DS:DATAS

START:

MOV AX,DATAS

MOV DS,AX

MOV AL,X

MOV BL,Y

CMP AL,BL

JG L1

MOV AL,BL

L1:MOV BL,Z

CMP AL,BL

L2: MOV MAX,AL

MOV AH,4CH

INT 21H

CODES ENDS

END START

3)(正确)根据MODE单元中编号0-7分别转向L0-L7标号处,执行L0-L7处分别完成显示‘0-7’字符,即当MODE=0时,转向L0标号,完成显示‘0’,当MODE=7时,转向L7标号,完成显示‘7’。

DATAS SEGMENT

MODE DB 0

DATAS ENDS

CODES SEGMENT

ASSUME CS:CODES,DS:DATAS

START:

MOV AX,DATAS

MOV DS,AX

MOV AL,MODE

CMP AL,0

JZ L0

CMP AL,1

JZ L1

CMP AL,2

JZ L2

CMP AL,3

JZ L3

CMP AL,4

JZ L4

CMP AL,5

JZ L5

CMP AL,6

JZ L6

MOV DL,'7'

MOV AH,02H

INT 21H

JMP L8

L0:MOV DL,'0' MOV AH,02H INT 21H

JMP L8

L1:MOV DL,'1' MOV AH,02H INT 21H

JMP L8

L2:MOV DL,'2' MOV AH,02H INT 21H

JMP L8

L3:MOV DL,'3' MOV AH,02H INT 21H

JMP L8

L4:MOV DL,'4'

MOV AH,02H

INT 21H

JMP L8

L5:MOV DL,'5'

MOV AH,02H

INT 21H

JMP L8

L6:MOV DL,'6'

MOV AH,02H

INT 21H

JMP L8

L8:MOV AH,4CH

INT 21H

CODES ENDS

END START

4)(正确)根据输入值(0-4)的不同,执行不同的操作,用转移标法编写程序。CODE SEGMENT

ASSUME CS:CODE

START:LEA BX, TAB

MOV AH,1

INT 21H

SUB AL,30H

MOV AH,0

ADD AX,AX

ADD BX,BX

JMP BX

TAB:JMP SHORT MODE0 JMP SHORT MODE1 JMP SHORT MODE2 JMP SHORT MODE3 JMP SHORT MODE4 MODE0:MOV DL,30H JMP EXIT

MODE1:MOV DL,31H JMP EXIT

MODE2:MOV DL,32H JMP EXIT

MODE3:MOV DL,33H JMP EXIT

MODE4:MOV DL,34H

EXIT:MOV AH,2

INT 21H

MOV AH,4CH

INT 21H

CODE ENDS

END START

5. (正确)统计数据块中正数和负数个数(设有7个数,分别为-32,25,36,-18,-64,0,-3)

DATAS SEGMENT

T DB-32,25,36,-18,-64,0,-3

L EQU $-T

ZHENG DB?

FU DB?

DATAS ENDS

STACKS SEGMENT

STACKS ENDS

CODES SEGMENT

ASSUME CS:CODES,DS:DATAS,SS:STACKS

START:

MOV AX,DATAS

MOV DS,AX

LEA SI,T

MOV CX,L

MOV BX,0

L3: MOV AL,[SI]

CMP AL,0

JGE L1

INC BL

JMP L2

L1: JZ L2

INC BH

L2: INC SI

LOOP L3

MOV ZHENG,BH

MOV FU,BL

MOV AH,4CH INT 21H CODES ENDS

END START

6. (正确)统计学生成绩,设有10个学生的成绩分别为56,69,84,82,73,88,89,63,100和80分,试编写程序分别统计低于60分,60-69分,70-79分,80-89分,90-99分以及100分的人数,并存放到S5,S6,S7,S8,S9以及S10单元中。

DATAS SEGMENT

SCORE DB 56,69,84,82,73,88,89,63,100,80

S5 DB 30H,0DH,0AH,'$'

S6 DB 30H,0DH,0AH,'$'

S7 DB'0',0DH,0AH,'$'

S8 DB'0',0DH,0AH,'$'

S9 DB'0',0DH,0AH,'$'

S10 DB'0',0DH,0AH,'$'

R5 DB'<60 ','$'

R6 DB'60-70 ','$'

R7 DB'70-80 ','$'

R8 DB'80-90 ','$'

R9 DB'90-100 ','$'

R10 DB'=100 ','$'

DATAS ENDS

CODES SEGMENT

ASSUME DS:DATAS

START:

MOV AX,DATAS

MOV DS,AX

MOV BX,OFFSET SCORE

MOV DI,0

MOV CX,10

COMPARE:MOV AL,BYTE PTR [BX][DI] CMP AL,60

JL L6

CMP AL,70

JL L7

CMP AL,80

JL L8

CMP AL,90

JL L9

CMP AL,100

JL L10

JE E10

L6:INC S5

JMP TRY

L7:INC S6

JMP TRY

L8:INC S7

JMP TRY

L9:INC S8

JMP TRY

L10:INC S9

JMP TRY

E10:INC [S10]

TRY:INC DI

DEC CX

JNZ COMPARE

MOV DX,OFFSET R5

MOV AH,09H

INT 21H

MOV DX,OFFSET S5

MOV AH,09H

INT 21H

MOV DX,OFFSET R6

MOV AH,09H

INT 21H

MOV DX,OFFSET S6

MOV AH,09H

INT 21H

MOV DX,OFFSET R7

MOV AH,09H

INT 21H

MOV DX,OFFSET S7

MOV AH,09H

INT 21H

MOV DX,OFFSET R8

MOV AH,09H

INT 21H

MOV DX,OFFSET S8

MOV AH,09H

INT 21H

MOV DX,OFFSET R9

MOV AH,09H

INT 21H

MOV DX,OFFSET S9

MOV AH,09H

INT 21H

MOV DX,OFFSET R10

MOV AH,09H

INT 21H

MOV DX,OFFSET S10

MOV AH,09H

INT 21H

MOV AH,4CH

INT 21H

CODES ENDS

END START

7.(正确)在字符串中查找空格字符(ASCII码位20H),找到显示Y,否则显示N。DATAS SEGMENT

S DB'GHLU JIBGYBUJHNUJB'

CNT EQU $-S

DATAS ENDS

CODES SEGMENT

ASSUME CS:CODES,DS:DATAS START:

MOV AX,DATAS

MOV DS,AX

LEA BX,S

MOV CX,CNT

L1:MOV AL,[BX]

CMP AL,20H

JZ L2

INC BX

DEC CX

JNZ L1

MOV DL,'N'

MOV AH,02H

INT 21H

JMP L3

L2:MOV DL,'Y'

MOV AH,02H

INT 21H

;JMP L3

L3:MOV AH,4CH INT 21H CODES ENDS END START

相关推荐
相关主题
热门推荐