
关于用masm5汇编的问题
这段8086汇编程序在用masm5debug的时候,执行-g后就死了,原因是因为我设置了org0300h吗,这是题目要求的,原题是:在偏移地址0300h开始放置n个数据,...
这段8086汇编程序在用masm5 debug的时候,执行-g后就死了,原因是因为我设置了org 0300h吗,这是题目要求的,原题是:在偏移地址0300h开始放置n个数据,要求将其中正数转到0500h出依次存放。我用什么方法才能让这段代码运行的符合题意?
DATA SEGMENT
ORG 0300H
BUFF DW 1200H,8000H,1300H,9000H
STR equ $-BUFF
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START: MOV CX,STR
MOV DI,OFFSET BUFF
MOV SI,0500H
LOOP1: MOV AX,[DI]
CMP AX,0
JS MINUS
MOV [SI],AX
INC SI
INC SI
MINUS: INC DI
INC DI
LOOP LOOP1
CODE ENDS
END START 展开
DATA SEGMENT
ORG 0300H
BUFF DW 1200H,8000H,1300H,9000H
STR equ $-BUFF
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START: MOV CX,STR
MOV DI,OFFSET BUFF
MOV SI,0500H
LOOP1: MOV AX,[DI]
CMP AX,0
JS MINUS
MOV [SI],AX
INC SI
INC SI
MINUS: INC DI
INC DI
LOOP LOOP1
CODE ENDS
END START 展开
1个回答
展开全部
试试看:
DATA SEGMENT
ORG 0300H
BUFF DW 1200H, 8000H, 1300H, 9000H
STR equ $ - BUFF
ORG 0500H
BUF2 DW 0,0,0,0
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE, DS:DATA
START:
MOV AX, DATA
MOV DS, AX
MOV CX, STR
SHR CX, 1 ;除以2,得到“字”数
MOV DI, OFFSET BUFF
MOV SI, OFFSET BUF2
LOOP1:
MOV AX, [DI]
CMP AX, 0
JS MINUS
MOV [SI], AX
INC SI
INC SI
MINUS:
INC DI
INC DI
LOOP LOOP1
HLT
CODE ENDS
END START
此程序,必须用DEBUG来查看结果。
DATA SEGMENT
ORG 0300H
BUFF DW 1200H, 8000H, 1300H, 9000H
STR equ $ - BUFF
ORG 0500H
BUF2 DW 0,0,0,0
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE, DS:DATA
START:
MOV AX, DATA
MOV DS, AX
MOV CX, STR
SHR CX, 1 ;除以2,得到“字”数
MOV DI, OFFSET BUFF
MOV SI, OFFSET BUF2
LOOP1:
MOV AX, [DI]
CMP AX, 0
JS MINUS
MOV [SI], AX
INC SI
INC SI
MINUS:
INC DI
INC DI
LOOP LOOP1
HLT
CODE ENDS
END START
此程序,必须用DEBUG来查看结果。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询