没什么想法,就是想记录一下,因为自己关于微机编程方面的知识太薄弱了,借这些基础题来巩固一下。
- 求无符号数组BUF中的最大值存放于MAX中。
DATAS SEGMENT
BUF db 5,1,26,89,14,78 ;BUF是数组名 db是类型
N=$-BUF ;数组的长度
MAX db ?
DATAS ENDS
CODES SEGMENT
ASSUME CS:CODES,DS:DATAS
START:
MOV AX,DATAS
MOV DS,AX
MOV CX,N-1
MOV SI,OFFSET BUF
MOV AL,[SI]
lop: INC SI
CMP AL,[SI]
JAE NEXT
MOV AL,[SI]
next: LOOP LOP
MOV MAX,AL
MOV AH,4CH
INT 21H
CODES ENDS
END START
2、求无符号数组BUF中的最小值存放于MIN中。
DATAS SEGMENT
BUF db 5,1,26,89,14,78
N=$-BUF
MIN db ?
DATAS ENDS
CODES SEGMENT
ASSUME CS:CODES,DS:DATAS
START:
MOV AX,DATAS
MOV DS,AX
MOV CX,N-1
MOV SI,OFFSET BUF
MOV AL,[SI]
lop: INC SI
CMP AL,[SI]
JBE NEXT
MOV AL,[SI]
next: LOOP LOP
MOV MIN,AL
MOV AH,4CH
INT 21H
CODES ENDS
END START
3、求有符号数组BUF中的最大值存放于MAX中。
DATAS SEGMENT
BUF db 5,1,26,-89,14,-78
N=$-BUF
MAX db ?
DATAS ENDS
CODES SEGMENT
ASSUME CS:CODES,DS:DATAS
START:
MOV AX,DATAS
MOV DS,AX
MOV CX,N-1
MOV SI,OFFSET BUF
MOV AL,[SI]
lop: INC SI
CMP AL,[SI]
JGE NEXT
MOV AL,[SI]
next: LOOP LOP
MOV MAX,AL
MOV AH,4CH
INT 21H
CODES ENDS
END START
4、求有符号数组BUF中的最小值存放于MIN中。
DATAS SEGMENT
BUF db 5,1,26,-89,14,-78
N=$-BUF
MIN db ?
DATAS ENDS
CODES SEGMENT
ASSUME CS:CODES,DS:DATAS
START:
MOV AX,DATAS
MOV DS,AX
MOV CX,N-1
MOV SI,OFFSET BUF
MOV AL,[SI]
lop: INC SI
CMP AL,[SI]
JLE NEXT
MOV AL,[SI]
next: LOOP LOP
MOV MIN,AL
MOV AH,4CH
INT 21H
CODES ENDS
END START
5、统计数组BUF中正数、负数、0的个数顺序存放在变量NUM中。
DATAS SEGMENT
BUF db 5,1,26,0,-89,14,-78
N=$-BUF
NUM db 3 DUP(?)
DATAS ENDS
CODES SEGMENT
ASSUME CS:CODES,DS:DATAS
START:
MOV AX,DATAS
MOV DS,AX
MOV CX,N
MOV SI,OFFSET BUF
LOP: CMP BYTE PTR [SI],0
JL A1
JZ A2
INC NUM
JMP A3
A1: INC NUM+1
JMP A3
A2: INC NUM+2
A3: INC SI
LOOP LOP
MOV AH,4CH
INT 21H
CODES ENDS
END START