 |
Cheat Engine The Official Site of Cheat Engine
|
| View previous topic :: View next topic |
| Author |
Message |
Dr.Disrespect Grandmaster Cheater
Reputation: 3
Joined: 17 Feb 2016 Posts: 526
|
Posted: Tue Jun 07, 2016 5:32 pm Post subject: Python and assembly language. |
|
|
I want to make a dictionary(Python) in assembly code.
For example, a game has three characters with the names of: David, Michael and Jane. I want to save a unique value for each of the three characters. In Python, I can use a dictionary like the following, by using the names as the keys:
| Code: |
data = {'David': '1', 'Michael': '2', 'Jane': '3'}
|
How to implement this in assembly code?
|
|
| Back to top |
|
 |
ParkourPenguin I post too much
Reputation: 152
Joined: 06 Jul 2014 Posts: 4706
|
Posted: Tue Jun 07, 2016 7:03 pm Post subject: |
|
|
If you can find appropriate library functions for it, use those. Otherwise, you'll have to make your own way of doing it.
You could have an array or a linked list to store all the data. The array would probably need to store a pointer to some structure containing information on the element (e.g. key, value, and the types of both). The linked list would need to contain the same information.
To add or assign a key/value pair, see if the element already exists using msvcrt.strcmp (or build your own strcmp). If the key doesn't exist, create it, and assign the value to that key. It's assumed you're passing the information to the subroutine either directly as arguments or through a pointer to some other structure.
To look up a key, look through the dictionary and test to see if the key types match up ("1" is different from 1). If they do, check to see if the keys match. If they do, then return that value. If they don't match up, then move onto the next element in the dictionary. Continue until you either find it or run out of elements.
_________________
I don't know where I'm going, but I'll figure it out when I get there. |
|
| Back to top |
|
 |
Dr.Disrespect Grandmaster Cheater
Reputation: 3
Joined: 17 Feb 2016 Posts: 526
|
Posted: Tue Jun 07, 2016 10:46 pm Post subject: |
|
|
| ParkourPenguin wrote: | If you can find appropriate library functions for it, use those. Otherwise, you'll have to make your own way of doing it.
You could have an array or a linked list to store all the data. The array would probably need to store a pointer to some structure containing information on the element (e.g. key, value, and the types of both). The linked list would need to contain the same information.
To add or assign a key/value pair, see if the element already exists using msvcrt.strcmp (or build your own strcmp). If the key doesn't exist, create it, and assign the value to that key. It's assumed you're passing the information to the subroutine either directly as arguments or through a pointer to some other structure.
To look up a key, look through the dictionary and test to see if the key types match up ("1" is different from 1). If they do, check to see if the keys match. If they do, then return that value. If they don't match up, then move onto the next element in the dictionary. Continue until you either find it or run out of elements. |
Thanks, Penguin.
But how do I store a key? and a value associated with a key?
|
|
| Back to top |
|
 |
|
|
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 can download files in this forum
|
|