仪隆单片机高手: 不好意思刚用仪隆的片子,有许多地方不明白,日前自己写了一个跑马灯的程序,在单步执行时据然发现不对,请参考程序: ;*************************************** ;*************************************** ;Ver. : A.0 ;CPU : EM78156 ;============================================================== ;Special Registers Define INDI == 0x0 ; RTCC == 0x1 ; PC == 0x2 ; STATUS == 0x3 ; FSR == 0x4 ; PORT5 == 0x5 ; PORT6 == 0x6 ; INTF == 0xF ; ;Control Registers Define定义控制寄存器 IO_P5 == 0x5 ; IO_P6 == 0x6 ; IO_PD == 0xB ; IO_OC == 0xC ; IO_PU == 0xD ; IO_WDT == 0xE ; IO_IE == 0xF ; ;------------------------------------------------------------------- ;Bits define ;STATUS Register bits define C == 0 DC == 1 Z == 2 P == 3 T == 4 PS0 == 5 PS1 == 6 ;Interrupt status bits define TCIF == 0 ICIF == 1 EXIF == 2 ;Interrupt mask register bits define TCIE == 0 ICIE == 1 EXIE == 2 ;------------------------------------------------------------------- accback == 0x10 STATUSback == 0x11 temp1 == 0x12 temp2 == 0x13 flag1 == 0x14 temp3 == 0x15 flag == 0x16 tmcount1 == 0x17 tmcount2 == 0x18 tcc_count == 0x19 temp4 == 0x1a temp5 == 0x1b ;-------------------------------------------------------------- ;============================================================== ORG 0 JMP MAIN ;============================================================== ORG 8 jmp tcc_int ;150us中断一次 nop RETI ;--------------------------------------------------------------- ;*************************************************************** ;================================================= MAIN: MOV A,@0 IOW IO_WDT IOW IO_P5 IOW IO_P6 clr port5 CLR PORT6 contr and a,@0b11010000 or a,@0b00000001 ;1:4 contw mov a,@0x01 iow INTF eni mov a,@0x10 mov fsr,a clrram: inc fsr clr INDI jbc fsr,5 jbs fsr,4 jmp clrram loop: wdtc ;call led1 nop call led2 nop ; call led3 wdtc ; call led4 nop ; call led5 nop ; call led6 jmp loop ;***************************************** led1: jbc flag,0 ret jbc flag,1 jmp led1a bs port6,4 bs flag,1 jbc flag,2 jmp led1b ret ;***************************************** led1a: bc port6,4 bc flag,1 bs flag,2 ret led1b: bs flag,3 bs flag,0 ret ;**************************************** led2: ; jbs flag,3 call led2out jbs flag1,0 call led2_1 jbc flag1,1 call led2_2 jbc flag1,2 call led2_3 jbc flag1,3 call led2_4 jbc flag1,4 call led2_5 jbc flag1,5 call led2_6 ret led2_1: nop wdtc bs port6,5 mov a,tmcount1 xor a,temp3 jbs STATUS,z jmp $-5 nop wdtc bc port6,5 mov a,tmcount2 xor a,temp4 jbs STATUS,z jmp $-5 bs flag1,0 bs flag1,1 clr tmcount1 clr tmcount2 ret led2_2: nop wdtc bs port6,5 mov a,tmcount1 xor a,temp3 jbs STATUS,z jmp $-5 nop wdtc bc port6,5 mov a,tmcount2 xor a,temp4 jbs STATUS,z jmp $-5 bc flag1,1 bs flag1,2 clr tmcount1 clr tmcount2 ret led2_3: nop wdtc bs port6,5 mov a,tmcount1 xor a,temp3 jbs STATUS,z jmp $-5 nop wdtc bc port6,5 mov a,tmcount2 xor a,temp4 jbs STATUS,z jmp $-5 bc flag1,2 bs flag1,3 clr tmcount1 clr tmcount2 ret led2_4: nop wdtc bs port6,5 mov a,tmcount1 xor a,temp3 jbs STATUS,z jmp $-5 nop wdtc bc port6,5 mov a,tmcount2 xor a,temp4 jbs STATUS,z jmp $-5 bc flag1,3 bs flag1,4 clr tmcount1 clr tmcount2 ret led2_5: nop wdtc bs port6,5 mov a,tmcount1 xor a,temp3 jbs STATUS,z jmp $-5 nop wdtc bc port6,5 mov a,tmcount2 xor a,temp4 jbs STATUS,z jmp $-5 inc temp3 djz temp4 jmp led2_5a bs flag1,5 clr tmcount1 clr tmcount2 ret led2_5a: bc flag1,4 bc flag1,0 clr tmcount1 clr tmcount2 ret led2_6: bs port6,5 bc flag,3 bs flag,4 clr flag1 ret led2out: mov a,@0X01 mov temp3,a mov a,@0x3b mov temp4,a bs flag,3 ;暂时的 clr tmcount1 clr tmcount2 ret ;**************************************** tcc_int: mov accback,a mov a,STATUS mov STATUSback,a mov a,@0x0B8 mov rtcc,a and a,@0xfe mov IO_IE,a inc tcc_count inc tmcount1 inc tmcount2 mov a,@0X0c8 xor a,tcc_count jbs STATUS,z jmp int_out clr tcc_count inc temp1 mov a,@0X22 xor a,temp1 jbs STATUS,z jmp int_out inc temp2 clr temp1 int_out: mov a,STATUSback mov STATUS,a mov a,accback reti 我的程序目的是控制一个LED灯慢慢的点亮,我的思路是这样的,在9MS的一个脉冲周期内改变其占空比来实现,相同的占空比运行5次,可是现在问题出现在,我单步执行时CALL完一个子程序退回时没有退到下一个子程序上,而是其它的子程序中间位置上去?例如:我CALL完LED2_1后,应该退回到LED2程序下的JBC FLAG1,1这条指令吧,但是现在不是退回到这里?是什么原因,请帮忙分析一下吧,谢谢! |