微机原理与汇编语言复习题及参考答案

JMP NEXT

GRADE8:CMP AL,80

JB GRADE7 ;小于80,转向GRADE7 INC[S8] ;S8单元内容增1 JMP NEXT

GRADE7:CMP AL,70

JB GRADE6 ;小于70,转向GRADE6 INC [S7] ;S7单元内容增1 JMP NEXT

GRADE6: INC [S6] ;S6单元内容增1 JMP NEXT

EXIT: POP AX POP SI POP CX RET

GRADES ENDP

3.

(1)参考程序如下: DATA SEGMENT

BUF1 DB -10,0,11,55,125,38,-69,… ;N字节数据 CN EQU $-BUF1 BUF2 DB CN DUP(?) DATA ENDS

CODE SEGMENT

ASSUME CS:CODE,DS:DATA START: MOV AX,DATA MOV DS,AX

MOV BX,OFFSET BUF1 LEA SI,BUF2 MOV CX,CN

LOP1: MOV AL,[BX] MOV [SI],AL INC BX INC SI LOOP LOPl MOV AH,4CH INT 21H CODE ENDS END START

(2)程序的数据定义部分与(1)中相同,不再重复。参考程序段如下: CODE SEGMENT

ASSUME CS:CODE,DS:DATA,ES:DATA START: MOV AX,DATA MOV DS,AX

MOV ES,AX

MOV SI,OFFSET BUF1 MOV DI,OFFSET BUF2 CLD

MOV CX,CN REP MOVSB MOV AH,4CH INT 21 H CODE ENDS END START

(3)程序的开头和结尾与(2)中相同,不再重复。参考程序段如下: MOV DS,AX MOV ES,AX

MOV SI,OFFSET BUF1 MOV DI,OFFSET BUF2 CLD

MOV CX,CN LOP: LODSB INC SISTOSB INC DI LOOP LOP

4. 参考答案如下: DATA SEGMENT

BUFFER DB OOH, 12H,3BH,43H,60H,OCH DB 8AH,OABH,37H,OFFH,32H,47H

COUNT EQU $-OFFSET BUFFER DATA ENDS

CODE SEGMENT

ASSUME CS:CODE,DS:DATA START: MOV AX,DATA MOV DS,AX

MOV SI,OFFSET BUFFER MOV CX,COUNT

MOV AL,[SI] ;把第一个数取到AL中 INC SI

DEC CX ;比较COUNT-1次 COMPA: CMP AL,[SI];比较,找出大数 JA NEXT MOV AL,[SI] NEXT: INC SI

LOOP COMPA ;比较完否?

MOV BL,AL ;是,大数在AL中,将其存入BX中 MOV DL,AL MOV CL,4

SHR DL,CL

CMP DL,OAHJB L1 ADD DL,7

Ll: ADD DL,30H MOV AH,02H

INT 21H ;显示高位

MOV DL,BL ;将大数放到DL中 AND DL,OFH ;将高4位屏蔽 CMP DL,OAH JB L2 ADD DL,7

L2: ADD DL,30H MOV AH,02H

INT 21 H ;显示低位 MOV AH,4CH INT 21H CODE ENDS END START

5. 参考答案如下: DATA SEGMENT ADRX DW 144 ADRY DW 12 DATA ENDS

CODE SEGMENT

ASSUME CS:CODE,DS:DATA START: MOV AX,DATA MOV DS,AX MOV AX,ADRX MOV DX,O DIV ADRY CMP DX,O JZ NEXT MOV DL,'1’ JMP EXIT

NEXT: MOV DL,'0' EXIT: MOV AH,02H INT 21H

MOV AH,4CH INT 21H CODE ENDS END START

联系客服:779662525#qq.com(#替换为@) 苏ICP备20003344号-4