Difference between revisions of "Help File:old flash (div 8)"
Jump to navigation
Jump to search
(Created page with '<hr><div align="left"><font face="Arial" color="#010101" class="Arial2"> This is just the money type adjusted to 8 (in case you didn't get it in the previous example)</font></d…') |
|||
(One intermediate revision by the same user not shown) | |||
Line 1: | Line 1: | ||
− | + | [[Category:Help]] | |
− | This is just the money type adjusted to 8 (in case you didn't get it in the previous example) | + | == Divide by 8 (old flash) == |
− | alloc(TypeName,256) | + | |
− | alloc(ByteSize,4) | + | |
− | alloc(ConvertRoutine,1024) | + | This is just the money type adjusted to 8 (in case you didn't get it in the previous example). |
− | alloc(ConvertBackRoutine,1024) | + | |
− | TypeName: | + | |
− | db 'Civ 5 Float',0 | + | alloc(TypeName,256) |
− | ByteSize: | + | alloc(ByteSize,4) |
− | dd 4 | + | alloc(ConvertRoutine,1024) |
− | //The convert routine should hold a routine that converts the data to an | + | alloc(ConvertBackRoutine,1024) |
− | nteger (in eax) | + | |
− | //function declared as: stdcall int ConvertRoutine(unsigned char | + | |
− | *input); | + | TypeName: |
− | //Note: Keep in mind that this routine can be called by multiple threads | + | db 'Civ 5 Float',0 |
− | at the same time. | + | |
− | ConvertRoutine: | + | |
− | [32-bit] | + | ByteSize: |
− | push ebp | + | dd 4 |
− | mov ebp,esp | + | |
− | push ecx | + | |
− | mov ecx,[ebp+8] | + | //The convert routine should hold a routine that converts the data to an nteger (in eax) |
− | [/32-bit] | + | //function declared as: stdcall int ConvertRoutine(unsigned char *input); |
− | //at this point ecx contains the address where the bytes are stored | + | |
− | //save the used registers | + | |
− | push edx //fun fact about ce's assembler, because push ebx does not | + | //Note: Keep in mind that this routine can be called by multiple threads at the same time. |
− | exist in 64-bit it becomes the 64-bit push rdx automatically | + | |
− | push ebx | + | |
− | //put the bytes into the eax register | + | ConvertRoutine: |
− | mov eax,[ecx] //second fun fact, addressing with 32-bit registers | + | [32-bit] |
− | doesn't work in 64-bit, it becomes a 64-bit automatically (most of the | + | push ebp |
− | time) | + | mov ebp,esp |
− | xor edx,edx | + | push ecx |
− | mov ebx,#8 | + | mov ecx,[ebp+8] |
− | div ebx //divide eax by 8and put the result in eax (and leftover in edx) | + | [/32-bit] |
− | pop ebx | + | |
− | pop edx | + | |
− | //and now exit the routine | + | //at this point ecx contains the address where the bytes are stored |
− | [64-bit] | + | //save the used registers |
− | ret | + | push edx //fun fact about ce's assembler, because push ebx does not exist in 64-bit it becomes the 64-bit push rdx automatically |
− | [/64-bit] | + | push ebx |
− | [32-bit] | + | |
− | pop ecx | + | |
− | pop ebp | + | //put the bytes into the eax register |
− | ret 4 | + | mov eax,[ecx] //second fun fact, addressing with 32-bit registers doesn't work in 64-bit, it becomes a 64-bit automatically (most of the time) |
− | [/32-bit] | + | |
− | //The convert back routine should hold a routine that converts the given | + | |
− | integer back to a row of bytes (e.g when the user wats to write a new | + | xor edx,edx |
− | value) | + | mov ebx,#8 |
− | //function declared as: stdcall void ConvertBackRoutine(int i, unsigned | + | div ebx //divide eax by 8and put the result in eax (and leftover in edx) |
− | char *output); | + | |
− | ConvertBackRoutine: | + | |
− | [32-bit] | + | pop ebx |
− | push ebp | + | pop edx |
− | mov ebp,esp | + | //and now exit the routine |
− | push edx //save the registers | + | [64-bit] |
− | push ecx | + | ret |
− | mov edx,[ebp+0c] | + | [/64-bit] |
− | mov ecx,[ebp+08] | + | [32-bit] |
− | [/32-bit] | + | pop ecx |
− | //at this point edx contains the address to write the value to | + | pop ebp |
− | //and ecx contains the value | + | ret 4 |
− | push eax | + | [/32-bit] |
− | push edx | + | |
− | push ecx | + | |
− | mov eax,ecx //eax gets the given value | + | //The convert back routine should hold a routine that converts the given integer back to a row of bytes (e.g when the user wats to write a new value) |
− | xor edx,edx //clear edx | + | //function declared as: stdcall void ConvertBackRoutine(int i, unsigned char *output); |
− | mov ecx,#8 | + | ConvertBackRoutine: |
− | mul ecx //multiply eax and put the results into edx:eax (edx is ignored | + | [32-bit] |
− | for this routine) | + | push ebp |
− | pop ecx | + | mov ebp,esp |
− | pop edx | + | push edx //save the registers |
− | mov [edx],eax | + | push ecx |
− | pop eax | + | mov edx,[ebp+0c] |
− | [64-bit] | + | mov ecx,[ebp+08] |
− | //everything is back to what it was, so exit | + | [/32-bit] |
− | ret | + | |
− | [/64-bit] | + | |
− | [32-bit] | + | //at this point edx contains the address to write the value to |
− | //cleanup first | + | //and ecx contains the value |
− | pop ecx | + | push eax |
− | pop edx | + | push edx |
− | pop ebp | + | push ecx |
− | ret 8 | + | |
− | [ | + | |
+ | mov eax,ecx //eax gets the given value | ||
+ | xor edx,edx //clear edx | ||
+ | mov ecx,#8 | ||
+ | mul ecx //multiply eax and put the results into edx:eax (edx is ignored for this routine) | ||
+ | | ||
+ | | ||
+ | pop ecx | ||
+ | pop edx | ||
+ | mov [edx],eax | ||
+ | pop eax | ||
+ | | ||
+ | | ||
+ | [64-bit] | ||
+ | //everything is back to what it was, so exit | ||
+ | ret | ||
+ | [/64-bit] | ||
+ | | ||
+ | | ||
+ | [32-bit] | ||
+ | //cleanup first | ||
+ | pop ecx | ||
+ | pop edx | ||
+ | pop ebp | ||
+ | ret 8 | ||
+ | [/32-bit] | ||
+ | |||
+ | |||
+ | == Links == | ||
+ | * [[Cheat Engine:Help File|Help File]] | ||
+ | |||
+ | * [[Help_File:Money_type|Back]] | ||
+ | |||
+ | * [[Help_File:Big_endian_2_byte|Next]] |
Latest revision as of 12:15, 19 March 2017
Divide by 8 (old flash)[edit]
This is just the money type adjusted to 8 (in case you didn't get it in the previous example).
alloc(TypeName,256) alloc(ByteSize,4) alloc(ConvertRoutine,1024) alloc(ConvertBackRoutine,1024) TypeName: db 'Civ 5 Float',0 ByteSize: dd 4 //The convert routine should hold a routine that converts the data to an nteger (in eax) //function declared as: stdcall int ConvertRoutine(unsigned char *input); //Note: Keep in mind that this routine can be called by multiple threads at the same time. ConvertRoutine: [32-bit] push ebp mov ebp,esp push ecx mov ecx,[ebp+8] [/32-bit] //at this point ecx contains the address where the bytes are stored //save the used registers push edx //fun fact about ce's assembler, because push ebx does not exist in 64-bit it becomes the 64-bit push rdx automatically push ebx //put the bytes into the eax register mov eax,[ecx] //second fun fact, addressing with 32-bit registers doesn't work in 64-bit, it becomes a 64-bit automatically (most of the time) xor edx,edx mov ebx,#8 div ebx //divide eax by 8and put the result in eax (and leftover in edx) pop ebx pop edx //and now exit the routine [64-bit] ret [/64-bit] [32-bit] pop ecx pop ebp ret 4 [/32-bit] //The convert back routine should hold a routine that converts the given integer back to a row of bytes (e.g when the user wats to write a new value) //function declared as: stdcall void ConvertBackRoutine(int i, unsigned char *output); ConvertBackRoutine: [32-bit] push ebp mov ebp,esp push edx //save the registers push ecx mov edx,[ebp+0c] mov ecx,[ebp+08] [/32-bit] //at this point edx contains the address to write the value to //and ecx contains the value push eax push edx push ecx mov eax,ecx //eax gets the given value xor edx,edx //clear edx mov ecx,#8 mul ecx //multiply eax and put the results into edx:eax (edx is ignored for this routine) pop ecx pop edx mov [edx],eax pop eax [64-bit] //everything is back to what it was, so exit ret [/64-bit] [32-bit] //cleanup first pop ecx pop edx pop ebp ret 8 [/32-bit]