Ultimate Amiga

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1]   Go Down

Author Topic: Variable Name Buffer Size  (Read 6671 times)

0 Members and 2 Guests are viewing this topic.

Umpal

  • A600
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 37
  • Programming and graphic
Variable Name Buffer Size
« on: May 04, 2016, 01:29:27 PM »

Is there a way to make a quick patch (or HEX edit the file) in order to increase the Variable Name Buffer Size setting? It's 31kB max. In most cases it's enough but... in my case it isn't.
Any help will be highly appreciated.

Logged

SamuraiCrow

  • compile-time wierdo
  • Forum Mod
  • A1200
  • *****
  • Karma: 5
  • Offline Offline
  • Gender: Male
  • Posts: 946
  • Compile-time wierdo
Re: Variable Name Buffer Size
« Reply #1 on: May 04, 2016, 06:31:28 PM »

32k is the maximum length of a string.  How can you go higher than that?
Logged

bruceuncle

  • AMOS Dev
  • A500
  • *****
  • Karma: 6
  • Offline Offline
  • Gender: Male
  • Posts: 425
  • WINUAE Amiga User
Re: Variable Name Buffer Size
« Reply #2 on: May 04, 2016, 10:38:48 PM »

Hi Umpal, The variable names table size is restricted to a maximum of 32k by the method AMOS uses to tokenise 'names'.  A 'name' is any variable, label or procedure in your program - they all go in the same table.  When your program references any name, it is tokenised as a 16 bit offset (1 word) into the names table, plus some flags and the name itself in lowercase padded to a word boundary if needed.  Although the pointer is 16 bit, the top bit is used to indicate whether it's a local or global name.  Leaving 15 bits for the offset, hence a maximum 32k size for the table.  We can't increase that without radically changing the way AMOS works - tokenising, verifying, etc.
If you've run into problems with the table size, the only realistic solution is to cut down the length of your names.  Plan it out and use global search and replace.
Bear in mind that all names are padded to word sizes.  So 'X1' takes the same space as 'X', etc.  Also, if you're using a lot of local variables, consider using some globals instead as locals are unique within each procedure and increase the table size accordingly.
Sorry we can't do anything about it, but that's AMOS.  You must have a huge program to hit that limit 😉.
Sent from my Lumia 640 using Tapatalk
Logged
Repeat after me ...  "The AMOS Pro architecture is complex but it is not complicated."

Umpal

  • A600
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 37
  • Programming and graphic
Re: Variable Name Buffer Size
« Reply #3 on: May 06, 2016, 02:03:53 AM »

@SamuraiCrow: I always aim high and seize it! ;D (Not always worth the effort but that's other story  ;))

@bruceuncle: You said 'the only realistic solution is to cut down the length of your names', but then you add: 'So 'X1' takes the same space as 'X''. I'm a bit confused. Is the cutting down the length of my variable names the solution or it takes the same space as the short ones?
Quote
You must have a huge program to hit that limit 😉.
;)
Logged

Hungry Horace

  • Amorphous Blue-Blob Man
  • Site Admin
  • A4000T
  • ******
  • Karma: 307
  • Offline Offline
  • Gender: Male
  • Posts: 3,364
  • Don't forget... Ameboid's need love too!
    • AUW
Re: Variable Name Buffer Size
« Reply #4 on: May 08, 2016, 05:09:58 PM »

basically he is saying if it is an 'even' number in length, it is the same space used as one character less.

i.e. 

NAMEVAR1  (8 characters long)  uses the same space in memory as NAMEVAR (7 characters)

NAMEVARIABLE01  (14 characters long) uses the same space in memory as NAMEVARIABLE1  (13 characters long)


However, he is *not* saying NAMEVARIABLE1 uses less space than NAMEVAR1
Logged
Quote from: KillerGorilla
because winuae is made of code and your amiga is made of stuff

Umpal

  • A600
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 37
  • Programming and graphic
Re: Variable Name Buffer Size
« Reply #5 on: May 10, 2016, 12:22:21 AM »

Thanks Horace, I got it now. So how do I know if my variable's name is still in 'one word' or it passed to occupy 'two words'? Is it like multiplied by 8 characters always? If so that would be clear to me. I need confirmation or more clarification  ;D
Logged

SamuraiCrow

  • compile-time wierdo
  • Forum Mod
  • A1200
  • *****
  • Karma: 5
  • Offline Offline
  • Gender: Male
  • Posts: 946
  • Compile-time wierdo
Re: Variable Name Buffer Size
« Reply #6 on: May 10, 2016, 01:00:46 AM »

It is a multiple of two characters.
Logged

Umpal

  • A600
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 37
  • Programming and graphic
Re: Variable Name Buffer Size
« Reply #7 on: May 10, 2016, 04:06:27 AM »

Oh, that's a surprise to me. Thanks Samurai.
Logged

bruceuncle

  • AMOS Dev
  • A500
  • *****
  • Karma: 6
  • Offline Offline
  • Gender: Male
  • Posts: 425
  • WINUAE Amiga User
Re: Variable Name Buffer Size
« Reply #8 on: May 10, 2016, 06:10:15 AM »

Sorry to have caused such confusion.
Perhaps I should just have said the names are stored 'word aligned' in the names table.
Your last reply worries me a little Umpal.  Where did you get the idea that they're stored in 'multiples of eight'?  A text string is just a series of bytes - one byte per character.  So if a string is 5 characters, that's just a group of 5 bytes.  This 'word aligned' thing comes from the way the 68000 cpu retrieves word-length data (1 word = 2 bytes) from memory.  It can only do this if the word-length data is at an even address, otherwise it will throw an address error.  The 68000 can retrieve byte-length data at any address.  As the entries in the names table contain both the name (bytes) and some data (both words and bytes) each name 'record' has to be aligned to an even address.
The result is that any name that is an odd number of characters long has a 'pad' byte added at the end to bring it up to an even length - i.e. word-aligned.
So, if you're cutting your variable names down in size, you will make the most efficient use of the available space if your names are an even number of characters in length.
Does that all make sense or have I confused things more?  :)
Sent from my Lumia 640 using Tapatalk
Logged
Repeat after me ...  "The AMOS Pro architecture is complex but it is not complicated."

Umpal

  • A600
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 37
  • Programming and graphic
Re: Variable Name Buffer Size
« Reply #9 on: May 10, 2016, 03:00:16 PM »

Clear as a sky! (I guess  ;D)
Logged
Pages: [1]   Go Up
 

TinyPortal 2.2.2 © 2005-2022