Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

Integer storage in ERAM

 
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
KenHorse

Bascom Member



Joined: 16 Jul 2004
Posts: 523

blank.gif
PostPosted: Tue Oct 28, 2014 9:44 pm    Post subject: Integer storage in ERAM Reply with quote

So how is it done? For example, I know if I store "-3" in ERAM, it is stored as 2 bytes of 253 and 255 decimal.

My problem is I'm trying to convert those 2 bytes back to an integer in a VB program but it only seems to work for positive numbers. If a negative (as above) is stored, my VB code isn't happy at all.

I know this is a VB issue but knowing what to look for in ERAM would certainly help!

(BASCOM-AVR version : 2.0.7.7 )
Back to top
View user's profile
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5920
Location: Holland

blank.gif
PostPosted: Tue Oct 28, 2014 9:58 pm    Post subject: Reply with quote

your VB is probably using longs and not integers ?
make a simple program, then watch the values in the Simulator. eram data is stored the same as sram data. LSB first.

you can do the same for your VB code. But you need to use something like peek() to get the memory position. My guess is that your VB code is storing integers as longs.
In such a case you need to check the sign bit (bit 15). and when it is set, make all leading bytes 255.

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

Bascom Expert



Joined: 16 Jan 2006
Posts: 2483
Location: Queensland

australia.gif
PostPosted: Wed Oct 29, 2014 6:56 am    Post subject: Reply with quote

Integer storage in VB is the same as in Bascom. So if you declare a variable as integer in VB, it will be rendered correctly, ie bytes stored as 253, 255 will render as "-3".

How are you actually storing the bytes you read from eram so VB can see them ?

_________________
Adrian Jansen
Computer language is a framework for creativity
Back to top
View user's profile Visit poster's website
KenHorse

Bascom Member



Joined: 16 Jul 2004
Posts: 523

blank.gif
PostPosted: Wed Oct 29, 2014 3:53 pm    Post subject: Reply with quote

The integer is dimensioned as an eram integer and assigned a value.

I have since received a suggestion from a VB forum on how to fix my VB code, which I did. And all seems ok now. Thanks you guys for your inputs![/code]
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