Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / GetMemblockShort's and GetMemblockInt's offset boundary limitation - why?

Author
Message
Ekkr
9
Years of Service
User Offline
Joined: 17th Apr 2015
Location:
Posted: 1st May 2017 18:53
Hello,

the help for GetMemblockInt says:
"offset must be a multiple of 4 as int values cannot be read across 4 byte boundaries"
And GetMemblockShort must have a 2-byte boundary.

Unfortunately I cannot use these functions, because my MemBlock (read from my data file)
contains bytes, short integers, integers etc., so e.g. integers don't necessarily lie on 4-byte boundaries.

Ok, it was not hard to write my own GetMemblockShort and GetMemblockInt replacement functions,
which don't have this limitation, but I wonder, why this limitation exists at all.
Seems to be an internal thing, but I see no real reason for this limitation.
Perhaps, you could remove this limitation in a later AppGameKit version.

Kind regards,
Ekkr
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 1st May 2017 22:12
It's a limitation of ARM processors.
on x86 processors it works but you have to read twice as much data into memory to get the value.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
nz0
AGK Developer
17
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 1st May 2017 22:43
Not just ARM, but all processors?
It's not efficient to read 4 bytes or 8 bytes at odd intervals.

It's good practice to pad out lower values or group them together. I'd not expect any changes to AppGameKit to solve this.
Paul Johnston
TGC Developer
21
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 3rd May 2017 15:40
I did a bit of research and it seems the latest ARM devices (since ARMv6) have added hardware support for unaligned memory access, although it will be slower than aligned access. Since we have dropped ARMv5 on Android I will remove this limitation of memblocks and add a note that aligned access is preferred.
Ekkr
9
Years of Service
User Offline
Joined: 17th Apr 2015
Location:
Posted: 3rd May 2017 23:32
Thanx, Paul.

Login to post a reply

Server time is: 2024-09-30 03:21:43
Your offset time is: 2024-09-30 03:21:43