Wierd Behavior of compiled assembled program.
RS_Jim
Posts: 1,771
In trying to chase down my problem with WKPND_B, I made some slight changes to the interupt program. 1 to set a bit in the timer routine every 1/100 of a second to use as a run bit for the tac and the second to the motor drive progarm to set the individual port bit instead of sending a whold byte to the port.· The first time I run the new version the program immediately goes to sleep.· When I run it under sxsim, I get a RETURNIW without an interupt error.· In backsteping the program, I get to a step where it is supposed to be·doing a jmp to A13. Instead it jmps to 13 which is in the middle of the ISR. Here is the listing of the Subroutine:
· 1151· =000001EB······ TAC_RESULT:····················· ;FUNC TAC_RESULT
· 1152·················
· 1153·················
· 1154·················································· ;····························· 'this measurement.
· 1155· 01EB· 0068······ ·CLR __WPARAM12_LSB············ ;····· __wparam12 =0··
· 1156· 01EC· 0069······· CLR __WPARAM12_MSB···········
· 1157·················
· 1158· 01ED· 072E············· SB····· Tdone····················· ;\·· SB····· Tdone
· 1159·················
· 1160 ·01EE· 0A13············· jmp···· txit····················· ;\··· jmp···· txit·· THIS JMP instruction is where it jmps to ISR
· 1161·················
· 1162· 01EF· 056E············· SETB··· TInhib·················· ;\···· SETB··· TInhib········· 'prevent interupt during
· 1163·················
· 1164 ·01F0· 001A······· BANK timing··················· ;····· Bank··· @timing
· 1165·················
· 1166· 01F1· 021C······· MOV __WPARAM34_LSB,Tac2_LSB··· ;····· __wparam34 = Tac2
······· 01F2· 002A
· 1167· 01F3· 021D······· MOV __WPARAM34_MSB,Tac2_MSB··
······· 01F4· 002B
· 1168·················
· 1169· 01F5· 0216······· MOV __WPARAM12_LSB,TacTime_LSB ;····· __wparam12 = TacTime
······· 01F6· 0028
· 1170· 01F7· 0217······· MOV __WPARAM12_MSB,TacTime_MSB
······· 01F8· 0029
· 1171·················
· 1172 ·01F9· 0217······· CJB Tac2_MSB,TacTime_MSB,@__ELSE_2 ;· if Tac2 > TacTime Then
······· 01FA· 009D 0703 0011 0A0D
· 1173· 01FE· 0743······· JNZ @$+8·····················
······· 01FF· 0011 0A06
· 1174· 0201· 021C······· CJBE Tac2_LSB,TacTime_LSB,@__ELSE_2
······· 0202· 0096 0603 0011 0A0D
· 1175·················
· 1176· 0206· 0C00······· ADD __WPARAM12_LSB,#$6000 & 255 ;······ __wparam12 = __wparam12 + $6000
······· 0207· 01E8
· 1177· 0208· 0C00······· MOV W,#$6000 << 8············
****** C:\Documents and Settings\Jim the boss\My Documents\sx documents\Atactest1.SRC(1177) Line 1177, Warning 37, Pass 2: Literal truncated to 8 bits
· 1178· 0209· 0603······· SNC··························
· 1179· 020A· 0C01······· MOV W,#($6000 << 8)+1········
****** C:\Documents and Settings\Jim the boss\My Documents\sx documents\Atactest1.SRC(1179) Line 1179, Warning 37, Pass 2: Literal truncated to 8 bits
· 1180· 020B· 0743······· SZ···························
· 1181· 020C· 01E9······· ADD __WPARAM12_MSB,W·········
· 1182·················
· 1183· =0000020D······ __ELSE_2:······················· ;····· Endif
· 1184· =0000020D······ __ENDIF_2:·····················
· 1185·················
· 1186· 020D· 046E······· clrb TInhib··················· ;····· \clrb TInhib
· 1187·················
· 1188·················
· 1189·················································· ;'···· __wparam12 = tacTime· - Tac2
· 1190· 020E· 0C04······· MOV __PARAMCNT,#4············· ;····· __wparam12 = BCD_WORD_SUB __wparam12,__wparam34
······ ·020F· 002C
· 1191· 0210· 0010······· CALL @__BCD_WORD_SUB·········
······· 0211· 09A4
· 1192·················
· 1193·················································· ;'···· Tac0 = Tac1············ 'handled in isr
· 1194································ ··················;'···· Tac1 = Tac2
· 1195·················································· ;'···· Tac2 = TacTime
· 1196· 0212· 042E······· clrb TDone···················· ;····· \clrb TDone············ 'wait for new info
· 1197·················
· 1198· ················
· 1199· =00000213······ Txit:··························· ;Txit:
· 1200·················
· 1201·················
· 1202·················································· ;'Txit1:
· 1203· 0213· 0018······· BANK 0························ ;Bank 0
· 1204·················
· 1205·················
· 1206· 0214· 0208······· MOV tmpW1_LSB,__WPARAM12_LSB·· ;····· tmpW1 = __wparam12
······· 0215· 0030
· 1207· 0216· 0209······· MOV tmpW1_MSB,__WPARAM12_MSB·
······· 0217· 0031
· 1208··············· ··
· 1209· 0218· 0210······· MOV __PARAM1,tmpW1_LSB········ ;RETURN tmpW1
······· 0219· 0028
· 1210· 021A· 0211······· MOV __PARAM2,tmpW1_MSB·······
······· 021B· 0029
· 1211· 021C· 000D······· RETP·······
I will get rid of the warning by changing the instruction from add $6000 to __wparam12 to ad $60 to __param2.
Obviously I don't want the program to jmp into the 13th line of the ISR, only to move forward a fiew line to the end of the FUNC
here is the SXB code for the TAC
'
'Tac_Result function that returns a word that contains the lapse
'time from the last revolution of the wheel
'
·FUNC TAC_RESULT
· __wparam12 =0
·\ ·SB·Tdone
·\·jmp·txit
·\·SETB·TInhib··'prevent interupt during this measurement.
··Bank·@timing
··__wparam34 = Tac2
··__wparam12 = TacTime
··if Tac2 > TacTime Then
··· __wparam12 = __wparam12 + $6000 'seconds have rolled over
··Endif
··\clrb TInhib
··__wparam12 = BCD_WORD_SUB __wparam12,__wparam34
·'·Tac0 = Tac1··'handled in isr
·'·Tac1 = Tac2
·'·Tac2 = TacTime
·\clrb TDone··'wait for new info
·Txit:
·'Txit1:
·Bank 0
··tmpW1 = __wparam12
·RETURN tmpW1
·ENDFUNC
Any Ideas why the unsual jmp is happening?
· 1151· =000001EB······ TAC_RESULT:····················· ;FUNC TAC_RESULT
· 1152·················
· 1153·················
· 1154·················································· ;····························· 'this measurement.
· 1155· 01EB· 0068······ ·CLR __WPARAM12_LSB············ ;····· __wparam12 =0··
· 1156· 01EC· 0069······· CLR __WPARAM12_MSB···········
· 1157·················
· 1158· 01ED· 072E············· SB····· Tdone····················· ;\·· SB····· Tdone
· 1159·················
· 1160 ·01EE· 0A13············· jmp···· txit····················· ;\··· jmp···· txit·· THIS JMP instruction is where it jmps to ISR
· 1161·················
· 1162· 01EF· 056E············· SETB··· TInhib·················· ;\···· SETB··· TInhib········· 'prevent interupt during
· 1163·················
· 1164 ·01F0· 001A······· BANK timing··················· ;····· Bank··· @timing
· 1165·················
· 1166· 01F1· 021C······· MOV __WPARAM34_LSB,Tac2_LSB··· ;····· __wparam34 = Tac2
······· 01F2· 002A
· 1167· 01F3· 021D······· MOV __WPARAM34_MSB,Tac2_MSB··
······· 01F4· 002B
· 1168·················
· 1169· 01F5· 0216······· MOV __WPARAM12_LSB,TacTime_LSB ;····· __wparam12 = TacTime
······· 01F6· 0028
· 1170· 01F7· 0217······· MOV __WPARAM12_MSB,TacTime_MSB
······· 01F8· 0029
· 1171·················
· 1172 ·01F9· 0217······· CJB Tac2_MSB,TacTime_MSB,@__ELSE_2 ;· if Tac2 > TacTime Then
······· 01FA· 009D 0703 0011 0A0D
· 1173· 01FE· 0743······· JNZ @$+8·····················
······· 01FF· 0011 0A06
· 1174· 0201· 021C······· CJBE Tac2_LSB,TacTime_LSB,@__ELSE_2
······· 0202· 0096 0603 0011 0A0D
· 1175·················
· 1176· 0206· 0C00······· ADD __WPARAM12_LSB,#$6000 & 255 ;······ __wparam12 = __wparam12 + $6000
······· 0207· 01E8
· 1177· 0208· 0C00······· MOV W,#$6000 << 8············
****** C:\Documents and Settings\Jim the boss\My Documents\sx documents\Atactest1.SRC(1177) Line 1177, Warning 37, Pass 2: Literal truncated to 8 bits
· 1178· 0209· 0603······· SNC··························
· 1179· 020A· 0C01······· MOV W,#($6000 << 8)+1········
****** C:\Documents and Settings\Jim the boss\My Documents\sx documents\Atactest1.SRC(1179) Line 1179, Warning 37, Pass 2: Literal truncated to 8 bits
· 1180· 020B· 0743······· SZ···························
· 1181· 020C· 01E9······· ADD __WPARAM12_MSB,W·········
· 1182·················
· 1183· =0000020D······ __ELSE_2:······················· ;····· Endif
· 1184· =0000020D······ __ENDIF_2:·····················
· 1185·················
· 1186· 020D· 046E······· clrb TInhib··················· ;····· \clrb TInhib
· 1187·················
· 1188·················
· 1189·················································· ;'···· __wparam12 = tacTime· - Tac2
· 1190· 020E· 0C04······· MOV __PARAMCNT,#4············· ;····· __wparam12 = BCD_WORD_SUB __wparam12,__wparam34
······ ·020F· 002C
· 1191· 0210· 0010······· CALL @__BCD_WORD_SUB·········
······· 0211· 09A4
· 1192·················
· 1193·················································· ;'···· Tac0 = Tac1············ 'handled in isr
· 1194································ ··················;'···· Tac1 = Tac2
· 1195·················································· ;'···· Tac2 = TacTime
· 1196· 0212· 042E······· clrb TDone···················· ;····· \clrb TDone············ 'wait for new info
· 1197·················
· 1198· ················
· 1199· =00000213······ Txit:··························· ;Txit:
· 1200·················
· 1201·················
· 1202·················································· ;'Txit1:
· 1203· 0213· 0018······· BANK 0························ ;Bank 0
· 1204·················
· 1205·················
· 1206· 0214· 0208······· MOV tmpW1_LSB,__WPARAM12_LSB·· ;····· tmpW1 = __wparam12
······· 0215· 0030
· 1207· 0216· 0209······· MOV tmpW1_MSB,__WPARAM12_MSB·
······· 0217· 0031
· 1208··············· ··
· 1209· 0218· 0210······· MOV __PARAM1,tmpW1_LSB········ ;RETURN tmpW1
······· 0219· 0028
· 1210· 021A· 0211······· MOV __PARAM2,tmpW1_MSB·······
······· 021B· 0029
· 1211· 021C· 000D······· RETP·······
I will get rid of the warning by changing the instruction from add $6000 to __wparam12 to ad $60 to __param2.
Obviously I don't want the program to jmp into the 13th line of the ISR, only to move forward a fiew line to the end of the FUNC
here is the SXB code for the TAC
'
'Tac_Result function that returns a word that contains the lapse
'time from the last revolution of the wheel
'
·FUNC TAC_RESULT
· __wparam12 =0
·\ ·SB·Tdone
·\·jmp·txit
·\·SETB·TInhib··'prevent interupt during this measurement.
··Bank·@timing
··__wparam34 = Tac2
··__wparam12 = TacTime
··if Tac2 > TacTime Then
··· __wparam12 = __wparam12 + $6000 'seconds have rolled over
··Endif
··\clrb TInhib
··__wparam12 = BCD_WORD_SUB __wparam12,__wparam34
·'·Tac0 = Tac1··'handled in isr
·'·Tac1 = Tac2
·'·Tac2 = TacTime
·\clrb TDone··'wait for new info
·Txit:
·'Txit1:
·Bank 0
··tmpW1 = __wparam12
·RETURN tmpW1
·ENDFUNC
Any Ideas why the unsual jmp is happening?
Comments
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Does that byte of memory hold "A", 65, $41 or %01000001 ?
Yes it does...
·
RS_JIM
RS_JIM