;当数据段定义过长时候就出现了这种情况
;这个程序的功能是显示一种期的正弦曲线
SETSCREEN MACRO
MOV AH,0
MOV AL,12H
INT 10H
ENDM
WRITEDOT MACRO
MOV AH,0CH
MOV AL,02H
MOV CX,ANGLE
ADD CX,140
MOV DX,TEMP
INT 10H
ENDM
DATA SEGMENT
SINE DB 00,03,07,10,14,17,21,24,28,31 ;本来我只是在一行中定义所有的数据,汇编时候出错后我就用了现在的定义
DB 35,38,42,45,48,52,55,58,62,65 ;本来的定义是:SINE DB 00,03,07,10,14,17,21,24,28,31,35,…
DB 68,72,75,78,81,85,88,91,94,97 ; 但是先的定义方式就提示cup 遇到无效的指令
DB 100,103,106,109,112,115,118,120
DB 123,126,129,131,134,136,139,141
DB 144,146,149,151,153,155,158,160
DB 162,164,166,168,170,171,173,175
DB 177,178,180,181,183,184,185,187
DB 188,189,190,191,192,193,194,195
DB 196,196,197,198,198,199,199,199
DB 200,200,200,200
ANGLE DW 0
TEMP DW 0
DATA ENDS
STACK SEGMENT
DB 64 DUP(?)
STACK ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA,SS:STACK
MAIN PROC FAR
START:
PUSH DS
PUSH AX
PUSH BX
MOV AX,DATA
MOV DS,AX
MOV AX,STACK
MOV SS,AX
SETSCREEN
AGAIN:
LEA BX,SINE
MOV AX,ANGLE
CMP AX,180
JLE QUAD1
SUB AX,180
QUAD1:
CMP AX,90
JLE QUAD2
NEG AX
ADD AX,180
QUAD2:
ADD BX,AX
MOV AL,SINE[BX]
PUSH AX
MOV AH,0
CMP ANGLE,180
JGE BIGDIS
NEG AL
ADD AL,240
JMP READY
BIGDIS:
ADD AX,240
READY:
MOV TEMP,AX
POP AX
WRITEDOT
ADD ANGLE,1
CMP ANGLE,360
JLE AGAIN
MOV AH,07
INT 21H
MOV AH,0
MOV AL,3
INT 10H
POP BX
POP AX
POP DS
RET
MAIN ENDP
CODE ENDS
END START
------解决方案--------------------------------------------------------
------解决方案--------------------------------------------------------
没有退出指令,程序末尾加上:
mov ax,4c00h
int 21h
------解决方案--------------------------------------------------------
如果你要用ret退出也可以,后面改为retf,前面加上:
push ds
xor ax,ax
push ax
------解决方案--------------------------------------------------------
;
;不要那么多数据。我写个例子,用MASM6.11编译。
;显示一个周期的正弦曲线
CODE SEGMENT
ASSUME CS:CODE,DS:CODE
.386
org 100h
START:
push cs
pop ds
mov ax,12h
int 10h
call draw
mov ah,7
int 21h
mov ax,3
int 10h
mov ah,4ch
int 21h
draw:
mov cx,360
next:
push cx
fldPI
fidiv rrr
fimul rot
fsin
fimul m
fistp y
add y,200
mov cx,x
mov dx,y
xor bx,bx
mov ax,0c02h
int 10h
inc rot
inc x
pop cx
loop next
ret
rot dw 0
rrr dw 180
x dw (640-360)/2
y dw ?
m dw 100
CODE ENDS
END START