include"8515def.inc"
.dseg
keyone:.byte1
.cseg
rjmpreset
.org0x10
RESET:
ldir16,low(RAMEND);ram的顶端
ldir17,high(RAMEND)
outspl,r16;设置堆栈指针指向ram顶部
outsph,r17
ldir16,1
stskeyone,r16;变量初始化
L2:
ldsR20,keyone
ldiR24,low(L8);取散转表首地址
ldiR25,high(L8)
clrr21
subir20,1;计算表内偏移量
sbcir21,0
lslr20;注意对FLASH的地址是字寻址
rolr21
addr24,r20;相当于@a+dptr
adcr25,r21
movR30,R24
movR31,R25
ijmp;间接跳转指令,指向z=r30,31
L8:
rcallprog1
rjmpL6
rcallprog2
rjmpL6
rcallprog3
rjmpL6
rcallprog4
rjmpL6
rcallprog5
L6:
NOP
rjmpL2
ret
prog1:
ldiR24,2
stskeyone,R24
ret
prog2:
ldiR24,3
stskeyone,R24
ret
prog3:
ldiR24,4
stskeyone,R24
ret
prog4:
ldiR24,5
stskeyone,R24
ret
prog5:
ldiR24,1
stskeyone,R24
ret