| View previous topic :: View next topic |
| Author |
Message |
justa_dude Grandmaster Cheater
Reputation: 23
Joined: 29 Jun 2010 Posts: 893
|
Posted: Thu Jul 15, 2010 3:43 pm Post subject: Is CE's autoassembler interpolating variables in strings? |
|
|
Hi folks,
I was wondering why the following auto-assembler snippet stores the address of title into the memory pointed at by the symbol instead of the string title. If I change the "db 'title',0" line to "db 'titl e',0" or any other misspelling, it works as expected. Does the assembler interpolate into strings? Are there other variables that can be inserted in this way, like in Perl or Ruby?
| Code: |
[ENABLE]
registersymbol(title)
alloc(title,40)
title:
db 'title',0
[DISABLE]
dealloc(title)
unregistersymbol(title)
|
Thanks,
adude |
|
| Back to top |
|
 |
Slugsnack Grandmaster Cheater Supreme
Reputation: 71
Joined: 24 Jan 2007 Posts: 1857
|
Posted: Thu Jul 15, 2010 5:27 pm Post subject: |
|
|
| I don't understand what you're trying to say. That code above defines a label 'title:'. You also register a symbol 'title' which is a pointer to an allocated block of 40 bytes. It just so happens at the label 'title:' you have defined a buffer with a zero terminated string called 'title'. You have 2 separate things there, do you realise that ? |
|
| Back to top |
|
 |
justa_dude Grandmaster Cheater
Reputation: 23
Joined: 29 Jun 2010 Posts: 893
|
Posted: Thu Jul 15, 2010 7:10 pm Post subject: |
|
|
Thanks for replying, Slug, but I don't understand what you're trying to explain.
Looking at the code, you would expect the memory pointed to by the title symbol to hold the string, "title", yes? When you execute the script, however, you're left with the ADDRESS of the allocated memory, instead. If you change the string to be, "this is a title string", you'll end up with a string in memory like, "this is a 123abc string" You see? That's what I mean by interpolation. |
|
| Back to top |
|
 |
Dark Byte Site Admin
Reputation: 471
Joined: 09 May 2003 Posts: 25831 Location: The netherlands
|
Posted: Thu Jul 15, 2010 9:33 pm Post subject: |
|
|
this is a bug, it shouldn't replace the text in strings with the name of a symbol (which is a good reason to use longer symbolnames for better readability and prevent bugs like this from causing a problem) _________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping |
|
| Back to top |
|
 |
justa_dude Grandmaster Cheater
Reputation: 23
Joined: 29 Jun 2010 Posts: 893
|
Posted: Thu Jul 15, 2010 9:40 pm Post subject: |
|
|
Ah, I see. Sorry for posting in the wrong place, then. I thought it might be a feature! I can see how it would be useful to be able to automagically replace text with variables. Thanks for looking at it, and sorry for being unable to phrase my question more succinctly.
Cheers,
adude |
|
| Back to top |
|
 |
|