微机原理编写完整汇编程序,将内存中10个有符号数求和,结果放入SUM单元(类型DW)。有符号数类型DB.
2个回答
展开全部
DATA SEGMENT
TABLE1 DB 0FFH,0FFH,0FFH,0FFH,0FFH
DB 0FFH,0FFH,0FFH,0FFH,0FFH ;这个你自己改吧。
SUM DW ?
ASCC DB 10 DUP (20h) ,'$'
COUNT DW 10
DATA ENDS
;
CODE SEGMENT
ASSUME CS:CODE ,DS:DATA,ES:DATA
START: MOV AX,DATA
MOV DS,AX
MOV ES,AX
LEA SI,TABLE1
MOV CX,10
XOR AX,AX
XOR BX,BX
CBW
NEXT: MOV AL,[SI]
CBW
ADD BX,AX
INC SI
LOOP NEXT
MOV SUM,BX
;以下是显示部分
LEA SI,sum
MOV BX,10 ;除数
LEA DI,ASCC+9 ;放入要转换的数
MOV AX,[SI]
AGAIN: XOR DX,DX
AND Ax,AX
JNS NEXT4
NEG AX
NEXT4: DIV BX
ADD DL,30H
MOV [DI],DL
XOR DX,DX
DEC DI
INC COUNT
AND AX,AX
JZ NEXT5
JMP NEXT4
NEXT5:
MOV AX,[SI]
CMP AX,8000H
JNC NEXT6
MOV AL,2BH
MOV [DI],AL
JMP NEXT7
NEXT6: MOV AL,'-'
MOV [DI],AL
NEXT7: LEA DX,ASCC
MOV AH,09H
INT 21H
MOV AH,4CH
INT 21H
CODE ENDS
END START
TABLE1 DB 0FFH,0FFH,0FFH,0FFH,0FFH
DB 0FFH,0FFH,0FFH,0FFH,0FFH ;这个你自己改吧。
SUM DW ?
ASCC DB 10 DUP (20h) ,'$'
COUNT DW 10
DATA ENDS
;
CODE SEGMENT
ASSUME CS:CODE ,DS:DATA,ES:DATA
START: MOV AX,DATA
MOV DS,AX
MOV ES,AX
LEA SI,TABLE1
MOV CX,10
XOR AX,AX
XOR BX,BX
CBW
NEXT: MOV AL,[SI]
CBW
ADD BX,AX
INC SI
LOOP NEXT
MOV SUM,BX
;以下是显示部分
LEA SI,sum
MOV BX,10 ;除数
LEA DI,ASCC+9 ;放入要转换的数
MOV AX,[SI]
AGAIN: XOR DX,DX
AND Ax,AX
JNS NEXT4
NEG AX
NEXT4: DIV BX
ADD DL,30H
MOV [DI],DL
XOR DX,DX
DEC DI
INC COUNT
AND AX,AX
JZ NEXT5
JMP NEXT4
NEXT5:
MOV AX,[SI]
CMP AX,8000H
JNC NEXT6
MOV AL,2BH
MOV [DI],AL
JMP NEXT7
NEXT6: MOV AL,'-'
MOV [DI],AL
NEXT7: LEA DX,ASCC
MOV AH,09H
INT 21H
MOV AH,4CH
INT 21H
CODE ENDS
END START
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询