MCU = 16F1829 (enhanced mid-range, stack is accessible)
Language: MPASM
IDE: MPLAB 8.92
This code works and sets TOSL to the correct return address in FSR1L:
This code does not work. WREG = 0x23. Value entered to TOSLis the current position. Hence, on return, it stalls and resets. The other manipulations of EEADRH/L and EEDATH/L all work as expected.
I have tried strange things, like a movlw to WREG doesn't write to TOSH/L either.
In contrast, at the beginning of the routine, this works just fine to preserve the beginning of the return address:
Any insights as to why the exit is not working as "expected?"
John
Language: MPASM
IDE: MPLAB 8.92
This code works and sets TOSL to the correct return address in FSR1L:
Code:
PutExit
banksel TOSL ;bank31
movf FSR1L,w
movwf TOSL ;return to end of table
movf FSR1H,w
movwf TOSH
clrf FSR1H
movlb 0
return
Code:
PutExit
movf EEADRL,w ; |B3
movlb 31 ; |B31
movwf TOSL ; |B31
movlb 3
movf EEADRH,w
movlb 31
movwf TOSH
movlb 0 ; |B0
return
In contrast, at the beginning of the routine, this works just fine to preserve the beginning of the return address:
Code:
PutText
movlb 31 ; |B31
movf TOSH,w ; |B31
movwf temp ; |B?
movf TOSL,w ; |B31
movlb 3 ; |B3
movwf EEADRL ; |B3
movf temp,w ; |B?
movwf EEADRH ; |B3
John