Karl explained this the best. SFRs are NOT addressable indirectly and thus
you need an instruction for each one. You can't do something like
mov r0, #80
mov a, @r0
because this would access indirect memory not SFRs.
If you wrote an SDCC assembler program to access SFRs it would look
something like this:
unsigned char getSFR ()
; Return value of SFR
; B in SFR index (0..128)
; A out SFR value
mov a, #SFRoffset$ ; Size of each SFR instruction in table
mul ab ; Make into offset
add a, #<SFRdispatch$ ; Add offset to dispatch table
push acc ; Place SFR distpatch address on stack
mov a, b
addc a, #>SFRdispatch$
ret ; "call" into dispatch table will return to our caller
; Each entry is 3 bytes times 128 entries = 384 bytes total
mov a, 0x80
mov a, 0x81
mov a, 0x82
; rest of mov a, 0x... instructions go here
Hope this helps.
On Sunday, March 17, 2002, at 05:00 PM, Murray Lang wrote:
> Are the SFRs not memory mapped as well?
> I've used assemblers that don't know about many SFRs and have accessed
> them simply through their memory locations specified in the MCU
> documentation. If space wasn't a problem you could define the SFR
> addresses in a table and step through that table, addressing the SFRs
> indirectly. Just a thought. I haven't actually tried it.
> At 10:16 16/03/02 -0600, Karl Bongers wrote:
>> So probably a big case statement is your best
>> bet, or the equivalent optimized in asm.
>> Lanius wrote:
>>> i want to display all *SFR-Register in a loop like:
>>> for(FSR=firstSFR;SFR<=lastFSR; FSR++)
>>> x= *FSR;
>>> how to?