用汇编语言 统计带符号数
发布网友
发布时间:2022-05-18 16:28
我来回答
共5个回答
热心网友
时间:2023-10-19 22:04
DATA SEGMENT
MESSAGE DB 'Welcome to the system!',13,10,13,10,'$'
MESSAGE1 DB '10~20:','$'
MESSAGE2 DB '0~10:','$'
MESSAGE3 DB '-10~-0:','$'
MESSAGE4 DB '-20~-10:','$'
MESSAGE5 DB 'MAX:','$'
MESSAGE6 DB 'MIN:','$'
CR DB 13,10,'$'
BUF1 DB 05,-17,-11,19,15,11,-09,06,01,-05
BUF2 DB 08,-16,-14,11,13,-11,-07,04,03,-04
CUNT1 DB 0 ;计数初值
CUNT2 DB 0
CUNT3 DB 0
CUNT4 DB 0
MAX DB -20
MIN DB 20
DATA ENDS
STACKS SEGMENT
DB 200 DUP(?)
STACKS ENDS
CODE SEGMENT
ASSUME DS:DATA,CS:CODE
START: MOV AX,DATA
MOV DS,AX
MOV AX,0
MOV SI,0
MOV CX,20 ;置循环值
LOP0: MOV AL,BUF1[SI]
CMP AL,-10D ;测试
JL LK1
CMP AL,0
JL LK2
CMP AL,10
JL LK3
INC CUNT1
JMP NEXT
LK1: INC CUNT4
JMP NEXT
LK2: INC CUNT3
JMP NEXT
LK3: INC CUNT2
NEXT:
INC SI
LOOP LOP0
LEA SI,BUF1
MOV CX,20
LOP2:
MOV AL,[SI]
CMP AL,MAX
JNG BDY
MOV MAX,AL
BDY:
CMP AL,MIN
JNL BXY
MOV MIN,AL
BXY:
INC SI
LOOP LOP2
IOUT: LEA DX,MESSAGE
MOV AH,09H
INT 21H
MES1: LEA DX,MESSAGE1
MOV AH,09H
INT 21H
LEA DX,CR
MOV AH,09H
INT 21H
ADD CUNT1,30H
MOV DL,CUNT1
MOV AH,02H
INT 21H
LEA DX,CR
MOV AH,09H
INT 21H
MES2: LEA DX,MESSAGE2
MOV AH,09H
INT 21H
LEA DX,CR
MOV AH,09H
INT 21H
ADD CUNT2,30H
MOV DL,CUNT2
MOV AH,02H
INT 21H
LEA DX,CR
MOV AH,09H
INT 21H
MES3: LEA DX,MESSAGE3
MOV AH,09H
INT 21H
LEA DX,CR
MOV AH,09H
INT 21H
ADD CUNT3,30H
MOV DL,CUNT3
MOV AH,02H
INT 21H
LEA DX,CR
MOV AH,09H
INT 21H
MES4: LEA DX,MESSAGE4
MOV AH,09H
INT 21H
LEA DX,CR
MOV AH,09H
INT 21H
ADD CUNT4,30H
MOV DL,CUNT4
MOV AH,02H
INT 21H
LEA DX,CR
MOV AH,09H
INT 21H
MES5: LEA DX,MESSAGE5
MOV AH,09H
INT 21H
LEA DX,CR
MOV AH,09H
INT 21H
MOV AL,MAX
XOR AH,AH
MOV CL,10D
DIV CL
MOV DX,AX
MOV AH,2
ADD DL,30H
INT 21h
MOV DL,DH
ADD DL,30H
INT 21H
LEA DX,CR
MOV AH,09H
INT 21H
MES6: LEA DX,MESSAGE6
MOV AH,09H
INT 21H
LEA DX,CR
MOV AH,09H
INT 21H
MOV AL,MIN
XOR AH,AH
NEG AL
PUSH AX
MOV AH,02H
MOV DL,'-'
INT 21H
POP AX
MOV CL,10D
DIV CL
MOV DX,AX
MOV AH,2
ADD DL,30H
INT 21h
MOV DL,DH
ADD DL,30H
INT 21H
MOV AH,4CH
INT 21H
CODE ENDS
END START
自己手写的阿,一定要给分阿,已验证了
热心网友
时间:2023-10-19 22:04
额````分数那么高 可惜偶不知道诶 路过~~~~~
热心网友
时间:2023-10-19 22:05
题目在清楚点,有很多疑惑,是求2个数据区一起的个数和最大最小,还是分别求呢?
热心网友
时间:2023-10-19 22:05
DATA SEGMENT
BUF1 DB 05,-17,-11,19,15,11,-09,06,01,-05
BUF2 DB 08,-16,-14,11,13,-11,-07,04,03,-04
CUNT0 EQU $-BUF2
CUNT1 DB 0 ;计数初值
CUNT2 DB 0
CUNT3 DB 0
CUNT4 DB 0
BUFFER DB 20H DUP(0)
DATA ENDS
CODE SEGMENT
ASSUME DS:DATA,CS:CODE
START: MOV AX,DATA
MOV DS,AX
MOV AX,0
MOV SI,0
MOV CX,CUNT0 ;置循环值
LOP0: MOV AL,BUF1[SI]
CMP AL,10D ;测试
JL LK1
JG LK2
LK1: CMP AL,0
JG LK3
JL LK4
LK2: INC CUNT1 ;10~20计数加一
MOV BUFFER[SI],AL
JMP LP1
LK3: INC CUNT2 ;0~10 计数加一
JMP LP1
LK4: CMP AL,-10
JG LK5
JL LK6
LK5: INC CUNT3 ; -10~0计数加一
JMP LP1
LK6: INC CUNT4 ;-20~-10计数加一
ADD SI,10H
MOV BUFFER[SI],AL
SUB SI,10H
LP1: INC SI ;指向下一个数据
LOOP LOP0
MOV SI,0
LP2: MOV AL,BUFFER ;数据比较大小
INC SI
MOV DL,BUFFER[SI]
CMP AL,DL
JG LP3
MOV BUFFER,DL
JMP LOP1
LP3: MOV BUFFER,AL
LOP1: LOOP LP2
MOV SI,10H
LP4: MOV AL,BUFFER[SI] ;数据比较大小
INC SI
MOV DL,BUFFER[SI]
CMP AL,DL
JG LP5
MOV BUFFER+10H,DL
JMP LOP2
LP5: MOV BUFFER+10H,AL
LOP2: LOOP LP4
CODE ENDS
END START
求buf2的话,把前面的buf1换成buf2 就可以了,或者复制一下,改数据就可以把两个部分全部统计了。
热心网友
时间:2023-10-19 22:06
DATA SEGMENT
BUF1 DB 05,-17,-11,19,15,11,-09,06,01,-05
BUF2 DB 08,-16,-14,11,13,-11,-07,04,03,-04
CUNT0 EQU $-BUF1
CUNT1 DB 0 ;计数初值
CUNT2 DB 0
CUNT3 DB 0
CUNT4 DB 0
MAX DB -20
MIN DB 20
DATA ENDS
CODE SEGMENT
ASSUME DS:DATA,CS:CODE
START: MOV AX,DATA
MOV DS,AX
MOV AX,0
MOV SI,0
MOV CX,CUNT0 ;置循环值
LOP0: MOV AL,BUF1[SI]
CMP AL,-10D ;测试
JL LK1
CMP AL,0
JL LK2
CMP AL,10
JL LK3
INC CUNT1
JMP NEXT
LK1: INC CUNT4
JMP NEXT
LK2:INC CUNT3
JMP NEXT
LK3:INC CUNT2
NEXT:
INC SI
LOOP LOP0
LEA SI,BUF1
MOV CX,CUNT0
LOP2:
MOV AL,[SI]
CMP AL,MAX
JNG BDY
MOV MAX,AL
BDY:
CMP AL,MIN
JNL BXY
MOV MIN,AL
BXY:
INC SI
LOOP LOP2
MOV AX,4C00H
INT 21H
CODE ENDS
END START
CODE ENDS
END START