快疯了!
我做期末作业时,用宏做功能模块,可是jmp\je\ja\jb指令出错"jump out of range by xx bytes",我都要疯了!help
;final.asm
include macro.lib
student struc
sno db 8 dup(' ')
sname db 6 dup(' ')
asm db 3 dup(' ')
cm db 3 dup(' ')
os db 3 dup(' ')
total db 3 dup(' ')
range db 3 dup(' ')
student ends
stsg segment stack 's'
dw 32 dup(?)
stsg ends
data segment
titl db ' Mini-Database System',0DH,0AH,' copyright by HK,91994,BIT',0DH,0AH,0DH,0AH
menu1 db '1-----display',0DH,0AH ;menu
menu2 db '2-----edit',0DH,0AH
menu3 db '3-----sort',0DH,0AH
menu4 db '4-----find',0DH,0AH
menu5 db '5-----save',0DH,0AH
menu6 db '6-----exit',0DH,0AH,'$'
menu2_1 db 0DH,0AH,'1-----insert',0DH,0AH
menu2_2 db '2-----modify',0DH,0AH
menu2_3 db '3-----delete',0DH,0AH,'$'
menu3_1 db 0DH,0AH,'1-----by asm',0DH,0AH
menu3_2 db '2-----by cmp',0DH,0AH
menu3_3 db '3-----by os',0DH,0AH
menu3_4 db '4-----by total',0dh,0ah,'$'
promp db 'choose a number from the menu above:',0DH,0AH,'$'
item db 0DH,0AH,0DH,0AH,'--sno-----sname---asm--cm---os--total-range----',0DH,0AH,'$'
gap db ' $'
studentx student 30 dup(<>)
filename db 'studentx.dat',0
filehandle dw ?
data ends
code segment
assume cs:code,ds:data,ss:stsg,es:nothing
main proc far
mov ax,data
mov ds,ax
lea dx,filename ;open file
mov al,2
mov ah,3dh
int 21h
mov filehandle,ax
lea dx,studentx ;read data from file
mov bx,filehandle
mov cx,870
mov ah,3fh
int 21h
repeat:
mov AX,0600H ;clear screen
mov CX,0
mov DX,184FH
mov BH,07
int 10H
mov AH,02 ;set cursor
mov BH,0
mov DX,0400H
int 10H
lea DX,titl ;display menu
mov AH,9
int 21H
lea DX,promp
mov AH,9
int 21H
rdkb: ;wait for selection from menu
mov AH,1
int 21H
cmp AL,31H
jb beep
cmp AL,36H
ja beep
cmp AL,31H
je display_in
cmp AL,32H
je far ptr edit_in
cmp AL,33H
je far ptr sort_in
cmp AL,34H
je far ptr find_in
cmp AL,35H
je far ptr save_in
jmp quit
beep: ;beep for error
mov AH,14
mov AL,7
mov BH,0
int 10H
jmp repeat
quit: ;quit program
mov ah,3eh
mov bx,filehandle
int 21h
mov ax,4c00h
int 21h
display_in:
display
jmp repeat
edit_in:
edit
jmp repeat
sort_in:
sort
jmp repeat
find_in:
find
jmp repeat
save_in:
save
jmp repeat
insert_in:
insert
jmp repeat
modify_in:
modify
jmp repeat
delete_in:
delete
jmp repeat
sort_by_asm_in:
sort_by asm
jmp repeat
sort_by_cmp_in:
sort_by cm
jmp repeat
sort_by_os_in:
sort_by os
jmp repeat
sort_by_total_in:
sort_by total
jmp repeat
main endp
code ends
end main
;======================
;macro.lib
display macro
local lop1,lop2,lop3,lop4,lop5,out
lea dx,item
mov ah,9
int 21h
lea si,studentx
mov bh,30
lop5: mov cl,8
lop1: mov dl,[si]
mov ah,2
int 21h
inc si
loop lop1
lea dx,gap
mov ah,9
int 21h
mov cl,6
lop2: mov dl,[si]
mov ah,2
int 21h
inc si
loop lop2
lea dx,gap
mov ah,9
int 21h
mov bl,5
lop4: mov cl,3
lop3: mov dl,[si]
mov ah,2
int 21h
inc si
loop lop3
lea dx,gap
mov ah,9
int 21h
dec bl
jnz lop4
mov dl,0dh
mov ah,2
int 21h
mov dl,0ah
mov ah,2
int 21h
cmp bh,8
jne out
mov ah,1
int 21h
out: dec bh
jnz lop5
mov ah,1
int 21h
endm
edit macro
lea dx,menu2_1
mov ah,9
int 21h
lea dx,promp
mov ah,9
int 21h
mov ah,1
int 21h
cmp al,31h
jb beep
cmp al,33h
ja beep
cmp al,31h
je insert_in
cmp al,32h
je modify_in
jmp delete_in
mov ah,1
int 21h
endm
sort macro
lea dx,menu3_1
mov ah,9
int 21h
lea dx,promp
mov ah,9
int 21h
mov ah,1
int 21h
cmp al,31h
jb beep
cmp al,33h
ja beep
cmp al,31h
je sort_by_asm_in
cmp al,32h
je sort_by_cmp_in
cmp al,33h
je sort_by_os_in
jmp sort_by_total_in
mov ah,1
int 21h
endm
find macro
mov ah,1
int 21h
endm
save macro
mov ah,42h ;put file pointer to head
mov bx,filehandle
xor cx,cx
xor dx,dx
mov ah,40h ;write data to file
mov bx,filehandle
mov cx,870
lea dx,studentx
mov ah,1
int 21h
endm
insert macro
mov ah,1
int 21h
endm
modify macro
mov ah,1
int 21h
endm
delete macro
mov ah,1
int 21h
endm
sort_by macro item
mov ah,1
int 21h
endm