请看看问题出在哪里了 谢谢
我初学汇编,下面是一段打乒乓球的游戏编译的时候报错了,我不知道怎么调,请大家指教一下 多谢
错因:(出错处以在代码中标出)
Jump range out of by 42 bytes
Jump range out of by 16 bytes
代码如下:
;------------------------------------------------------------
DRAW MACRO SX,SY,EX,EY,COLOR
LOCAL DRAWNEXT
PUSH AX
PUSH BX
PUSH CX
PUSH DX
MOV AH,0CH
MOV AL,COLOR
MOV BH,0
MOV CX,SX
MOV DX,SY
DRAWNEXT: INT 10H
INC CX
CMP CX,EX
JNE DRAWNEXT
MOV CX,SX
INC DX
CMP DX,EY
JNE DRAWNEXT
POP DX
POP CX
POP BX
POP AX
ENDM
;------------------------------------------------------------
DATA SEGMENT
BALL_X DW 150
BALL_Y DW 172
E_X DW 0
E_Y DW 0
ORIGINAL_X DW 140
BOARD_X DW 140
SPEED DW 600
GAMEOVER DW 0
DIRECTION DW 2 ;1,2,3,4共4个方向,分别是左上,左下,右上,右下
IMFORMATION DB 'F1 TO START NEW GAME','$'
GAME_OVER DB 'ESC TO CONFIRM QUIT','$'
DATA ENDS
;--------------------------------------------------------------
CODE SEGMENT
ASSUME CS: CODE,DS: DATA
;---------------------------------------------------------------
MAIN PROC FAR
START: SUB AX,AX
PUSH AX
MOV AX,DATA
MOV DS,AX
MOV AH,0
MOV AL,4
INT 10H
MOV GAMEOVER,0
MOV BOARD_X,140
MOV ORIGINAL_X,140
MOV BALL_X,150
MOV BALL_Y,172
MOV SPEED,600
MOV DIRECTION,2
CALL WALL
CALL BOARD
CALL START_GAME
CALL RESTART
EXIT: MOV AH,0
INT 16H
CMP AH,3BH
JE START
CMP AH,1
JNE EXIT
MOV AH,4CH
INT 21H
MAIN ENDP
;---------------------------------------------------------
BOARD PROC NEAR
PUSH AX
MOV AX,ORIGINAL_X
ADD AX,40
MOV E_X,AX
DRAW ORIGINAL_X,176,E_X,180,04H
MOV AX,BOARD_X
ADD AX,40
MOV E_X,AX
DRAW BOARD_X,176,E_X,180,02H
POP AX
RET
BOARD ENDP
WALL PROC NEAR
PUSH CX
PUSH DX
MOV AH,0BH
MOV BH,0
MOV BL,10H
INT 10H
DRAW 9,9,300,12,01H
DRAW 9,9,12,183,01H
DRAW 9,180,300,183,01H
DRAW 300,9,303,183,01H
POP DX
POP CX
RET
WALL ENDP
;---------------------------------------------------------
START_GAME PROC NEAR
PUSH AX
PUSH BX
PUSH CX
PUSH DX
PUSH SI
PUSH DI
LP: CMP GAMEOVER,1
JE QUIT(出错)
CALL DELAY
CALL INI_BALL
MOV AH,01
INT 16H
JZ LP
MOV AH,00
INT 16H
CMP AH,39H
JE PAUSE
CMP AH,1
JE QUIT(出错)
CMP AH,4BH
JE BOARD_LEFT
CMP AH,4DH
JE BOARD_RIGHT
CMP AH,3BH
JE SPEED_1
CMP AH,3CH
JE SPEED_2
CMP AH,3DH
JE SPEED_3
CMP AH,3EH
JE SPEED_4
CMP AH,3FH
JE SPEED_5
JMP LP
PAUSE: MOV AH,00
INT 16H
CMP AH,39H
JNE PAUSE
JMP LP
BOARD_LEFT: CMP BOARD_X,12
JE LP
MOV AX,BOARD_X
MOV ORIGINAL_X,AX
SUB AX,4
MOV BOARD_X,AX
CALL BOARD
JMP LP
BOARD_RIGHT: CMP BOARD_X,260
JE LP
MOV AX,BOARD_X
MOV ORIGINAL_X,AX
ADD AX,4
MOV BOARD_X,AX
CALL BOARD
JMP LP
SPEED_1: MOV SPEED,600
JMP LP
SPEED_2: MOV SPEED,500
JMP LP
SPEED_3: MOV SPEED,400
JMP LP
SPEED_4: MOV SPEED,300
JMP LP
SPEED_5: MOV SPEED,200
JMP LP
QUIT: POP DI
POP SI
POP DX
POP CX
POP BX
POP AX
RET
START_GAME ENDP
;---------------------------------------------------------
INI_BALL PROC NEAR
PUSH AX
PUSH BX
PUSH CX
PUSH DX
PUSH SI
PUSH DI
MOV SI,BALL_X
MOV DI,BALL_Y
MOV AX,BALL_X
ADD AX,4
MOV E_X,AX
MOV AX,BALL_Y
ADD AX,4
MOV E_Y,AX
DRAW SI,DI,E_X,E_Y,04H
CMP SI,13
JE LEFT
CMP SI,296
JE RIGHT
CMP DI,13
JE UP
CMP DI,172
JE DOWN
JMP GO_ON
LEFT: CMP DIRECTION,3
JE CHECK_LEFT
MOV DIRECTION,1
JMP GO_ON
CHECK_LEFT: MOV DIRECTION,2
JMP GO_ON
RIGHT: CMP DIRECTION,1
JE CHECK_RIGHT
MOV DIRECTION,3
JMP GO_ON
CHECK_RIGHT: MOV DIRECTION,4
JMP GO_ON
UP: CMP DIRECTION,1
JE CHECK_UP
MOV DIRECTION,3
JMP GO_ON
CHECK_UP: MOV DIRECTION,2
JMP GO_ON
DOWN: MOV GAMEOVER,1
MOV CX,40
CHECK_DEAD: MOV AX,BOARD_X
ADD AX,CX
CMP AX,BALL_X
JE NOT_DEAD
LOOP CHECK_DEAD
JMP DEAD
NOT_DEAD: MOV GAMEOVER,0
DEAD: CMP DIRECTION,2
JE CHECK_DOWN
MOV DIRECTION,4
JMP GO_ON
CHECK_DOWN: MOV DIRECTION,1
JMP GO_ON
GO_ON: CMP DIRECTION,1
JE RIGHT_UP
CMP DIRECTION,2
JE RIGHT_DOWN
CMP DIRECTION,3
JE LEFT_DOWN
JMP LEFT_UP
RIGHT_UP: INC SI
DEC DI
JMP NEW_BALL
RIGHT_DOWN: INC SI
INC DI
JMP NEW_BALL
LEFT_DOWN: DEC SI
INC DI
JMP NEW_BALL
LEFT_UP: DEC SI
DEC DI
NEW_BALL: MOV BALL_X,SI
MOV BALL_Y,DI
MOV AX,SI
ADD AX,4
MOV E_X,AX
MOV AX,DI
ADD AX,4
MOV E_Y,AX
DRAW SI,DI,E_X,E_Y,03H
POP DI
POP SI
POP DX
POP CX
POP BX
POP AX
RET
INI_BALL ENDP
;------------------------------------------------------------
DELAY PROC NEAR
PUSH CX ;保存寄存器内容
PUSH DX
SUB DX,DX
MOV DX,SPEED
LOOP31: XOR CX,CX ;延时
A1: LOOP A1
DEC DX
JNZ LOOP31
POP DX ;恢复寄存器内容
POP CX
RET
DELAY ENDP
;------------------------------------------------------------
RESTART PROC
PUSH AX
PUSH DX
MOV DL,8
MOV DH,10
MOV AH,02
INT 10H
LEA DX,IMFORMATION
MOV AH,09
INT 21H
MOV DL,8
MOV DH,12
MOV AH,02
INT 10H
LEA DX,GAME_OVER
MOV AH,09
INT 21H
POP DX
POP AX
RET
RESTART ENDP
;------------------------------------------------------------
CODE ENDS
END START
;------------------------------------------------------------