Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

Currect handling og RAMPZ in ISR

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    www.mcselec.com Forum Index -> BASCOM-AVR Archive
View previous topic :: View next topic  
Author Message
i.dobson

Bascom Expert



Joined: 05 Jan 2006
Posts: 1534
Location: Basel, Switzerland

switzerland.gif
PostPosted: Mon Sep 22, 2014 3:19 pm    Post subject: Currect handling og RAMPZ in ISR Reply with quote

Hi All,

I'm currently working a a Project and I have the Feeling that the code will end up > 64Kb (using a atmega1284). Up until now I've never really worried about the RAMPZ Register as most of my Projects are small'ish (<32Kb).

I've created a small program with an ISR/PUSHALL-POPALL to just look at what code bascom creates and using objdump I'm seeing this for pushall:-
1460: Pushall
Code:
0000280C: 920F     PUSH      R0                  Push Register on Stack
0000280E: 921F     PUSH      R1                  Push Register on Stack
--snip
00002836: 93CF     PUSH      R28                 Push Register on Stack
00002838: 93DF     PUSH      R29                 Push Register on Stack
0000283A: 93EF     PUSH      R30                 Push Register on Stack
0000283C: 93FF     PUSH      R31                 Push Register on Stack
0000283E: B78F     IN        R24, $3F            Load an I/O Location to Register
00002840: 938F     PUSH      R24                 Push Register on Stack
00002842: B78B     IN        R24, $3B            Load an I/O Location to Register
00002844: 938F     PUSH      R24                 Push Register on Stack
00002846: 2788     EOR       R24, R24            Exclusive OR
00002848: BF8B     OUT       $3B, R24            Store Register to I/O Location
 


popall Looks normal:
Code:

1487:     Popall
00002930: 918F     POP       R24                 Pop Register from Stack
00002932: BF8B     OUT       $3B, R24            Store Register to I/O Location
00002934: 918F     POP       R24                 Pop Register from Stack
00002936: BF8F     OUT       $3F, R24            Store Register to I/O Location
00002938: 91FF     POP       R31                 Pop Register from Stack
0000293A: 91EF     POP       R30                 Pop Register from Stack
0000293C: 91DF     POP       R29                 Pop Register from Stack
0000293E: 91CF     POP       R28                 Pop Register from Stack
 



$3f Looks like SREG, and $3B is RAMPZ. So whats Bascom doing with the RAMPZ register (copy to R24, push to stack, Exclusive OR r24 with r24, copy r24 to RAMPZ).

So simply put what the hell is bascom doing with RAMPZ, the EOR Looks totally unnecessary, unless it's doing something clever that I don't understand.

Regards
Ian Dobson



(BASCOM-AVR version : 2.0.7.7 )

_________________
Home of AVRTimer, the Bascom timer value calculator.
http://www.planet-ian.com

Walking on water and writing software to specification is easy if they're frozen.
Back to top
View user's profile Visit poster's website
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5071
Location: Holland

blank.gif
PostPosted: Mon Sep 22, 2014 3:41 pm    Post subject: Reply with quote

i am not going to make a habit of explaining code from objdump so this is the first and last time.
If you want to know you can write to support since you have an SLA.
Second it has nothing to do with hell.

The problem of these dump tools: they have multiple choices. what actually happens is CLR r24. and eor reg,reg is the same.
the rampz is cleared. this way it points to the default assumed page.
depending on the platform, rampz has multiple usage. normally is it only for elpm, spm , but it also form an extended 24 bit address for sram access on xmega.

if you write your own lib/isr you should save/restore rampz when the processor >64KB.

_________________
Mark
Back to top
View user's profile Visit poster's website
MWS

Bascom Member



Joined: 22 Aug 2009
Posts: 1827

blank.gif
PostPosted: Mon Sep 22, 2014 3:56 pm    Post subject: Re: Currect handling og RAMPZ in ISR Reply with quote

i.dobson wrote:
Code:
00002842: B78B     IN        R24, $3B
00002844: 938F     PUSH      R24
00002846: 2788     EOR       R24, R24
00002848: BF8B     OUT       $3B, R24


An EOR on the same register clears it, an equivalent to a CLR.
The shown code sets RAMPZ to zero for the ISR, the first page for LPM, or whatever intended use it will have.
Back to top
View user's profile
i.dobson

Bascom Expert



Joined: 05 Jan 2006
Posts: 1534
Location: Basel, Switzerland

switzerland.gif
PostPosted: Mon Sep 22, 2014 4:49 pm    Post subject: Reply with quote

Hi Mark,

I didn't what to tread on any toes, sorry. "What the hell" ist just an english saying for "I don't understand whats going on here".

I need to spend as little time as possible in the ISR, so just pushing/poping the required registers is the only way to go, and using objdump is the easiest way to see what registers are required.

so
EOR AA,AA = CLR AA (Clear register AA - Makes sense to me)

Regards
Ian Dobson

_________________
Home of AVRTimer, the Bascom timer value calculator.
http://www.planet-ian.com

Walking on water and writing software to specification is easy if they're frozen.
Back to top
View user's profile Visit poster's website
MWS

Bascom Member



Joined: 22 Aug 2009
Posts: 1827

blank.gif
PostPosted: Mon Sep 22, 2014 8:49 pm    Post subject: Reply with quote

i.dobson wrote:
"What the hell" ist just an english saying for "I don't understand whats going on here".

It can be used in different ways, but in a context like this, I'd say "what the hell" is more an expression like: "what is this f...g thing doing"
"I don't understand whats going on here" is more a: "I have no clue".

Maybe you have to work a bit on your English slang vocabulary.
Here in the forum it's uncritical, but if you meet the real world, you may experience interesting results.
Quote:
I need to spend as little time as possible in the ISR, so just pushing/poping the required registers is the only way to go, and using objdump is the easiest way to see what registers are required.

An option would be to write the whole ISR in assembler, but as you didn't know the purpose of EOR, I'd say you'd still have some way to go.
And it would help, if you download the AVR Instruction Set manual, under EOR you'll find then:
Quote:
Example:
eor r4,r4 ; Clear r4
Back to top
View user's profile
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    www.mcselec.com Forum Index -> BASCOM-AVR Archive All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum