Download this book

Transcript
send_byte(tx_byte) ;
char_received_fl = 0 ;
}
real_time_count = 0 ;
while(real_time_count < 200)
{ ; }
i = ((unsigned char (code*)(void)) 0xFFFD) () ;
// Jump to absolute address.
}
^^^^^^^^^^^^^^^^^^^^^^^ End of Module
;
NAME
;
; Cause
;
P4
;
CSEG
;
MOV
;
END
SWITCH
PC to roll-over at FFFFH to simulate reset
DATA 0E8H
AT 0FFFDH
P4,#02Fh
;
^^^^^^^^^^^^^^^^^^^^^^^ End of Module “MAPCON”
There are other ways of doing this. For instance the code for the MAPCON module could be
located at link time thus: CODE(SWITCH(0FFFDH)), so dispensing with the “CSEG AT”.
12.4 Simulating A Software Reset
In a similar vein to the above, the 8051 does not possess a software reset instruction, unlike
the 80C166 etc.. This method uses abstract pointers to create a call to address zero, thus
simulating a software reset.
However it should be remembered that all internal locations must be cleared before the CPU
can be considered properly reset! The return address must be reset as the stack still contains
the return address from the call.
;
;
; void main(void) {
RSEG ?PR?main?T1
USING
0
main:
;
;
; ((void (code*) (void))
;
LCALL
00H
;
; }
;
RET
; END OF main
www.hitex.co.uk
SOURCE LINE # 9
0x0000) () ;
SOURCE LINE # 11
; Jump to address ZERO!
SOURCE LINE # 13
page 109 of 190
Version 3.6 (draft)