flat assembler
Message board for the users of flat assembler.
Index
> Main > 32bit/64bit Goto page Previous 1, 2, 3 |
Author |
|
Azu 23 Jul 2009, 05:47
nvm sorry
Last edited by Azu on 23 Jul 2009, 08:36; edited 1 time in total |
|||
23 Jul 2009, 05:47 |
|
Madis731 23 Jul 2009, 08:20
Code: push cx use32 push ecx use64 push rcx pop rcx use32 pop ecx use16 pop cx I don't see where the problem is!? |
|||
23 Jul 2009, 08:20 |
|
Azu 05 Aug 2009, 13:39
I need to make it be at a certain spot like using org or virtual or something.. like this;
Code: use32
virtual at spot
use64
end virtual
push eax
push eax
spot:
pop rcx |
|||
05 Aug 2009, 13:39 |
|
Madis731 06 Aug 2009, 06:37
Then you should use:
Code:
use32
use64
virtual at spot
end virtual
push eax
push eax
spot:
pop rcx
and still no problem |
|||
06 Aug 2009, 06:37 |
|
Azu 06 Aug 2009, 06:41
Madis731 wrote: Then you should use: |
|||
06 Aug 2009, 06:41 |
|
Borsuc 06 Aug 2009, 19:38
Madis731 wrote:
Same with org. It only tells FASM the offset, but if the CPU loads it in some other offset, all absolute address instructions will have the wrong offset. for example, if you do this in 16-bit mode: Code: use32 mov eax, 0 Code: mov ax, 0 FASM has been "lied" to, in effect, with the wrong mode. It doesn't know the mode the CPU will use when executing this instruction, and you lie to it. With 64-bit it will probably crash since the encoding is really different. _________________ Previously known as The_Grey_Beast |
|||
06 Aug 2009, 19:38 |
|
Azu 06 Aug 2009, 19:41
Changing the CPU mode is easy, I want to get the useXs into my macros though, so I don't have to clog up my source by placing them all over it..
I want to have my macro do like "go to label X and switch to 64bit mode compile opcodes at label X as 64bit" instead of the macro just doing "go to label X and switch to 64bit mode" and me having to write a useless line "use64" or "use32" under all those labels for when I switch back and forth.. please help.. |
|||
06 Aug 2009, 19:41 |
|
Borsuc 06 Aug 2009, 20:09
Azu wrote: Changing the CPU mode is easy _________________ Previously known as The_Grey_Beast |
|||
06 Aug 2009, 20:09 |
|
Azu 06 Aug 2009, 20:11
Yes in ring 3. Now I just want to get my macro to put the use32/use64 after the label so I don't need all those use32/use64s littering my source. How do I do this?
Last edited by Azu on 06 Aug 2009, 20:14; edited 1 time in total |
|||
06 Aug 2009, 20:11 |
|
r22 06 Aug 2009, 20:14
@Azu
If you post an [*edit* working] example program/snippet that does exactly what you want WITHOUT macros, I think you'll have a better chance of getting help with a more efficient solution. |
|||
06 Aug 2009, 20:14 |
|
Azu 06 Aug 2009, 20:15
Okay
I have it like this push rax ;stuff to switch modes and call SomeAddress goes here, don't feel like posting it all pop rcx jmp Some64bitPlace SomeAddress: use32 pop eax pop ecx push ebx push edx ;stuff to switch modes and return goes here Some64bitPlace: use64 I want it like this macro callerThingy addr{ ;stuff to switch modes and call addr goes here, don't feel like posting it all virtual at addr use32 end virtual} macro returnerThingy{ ;stuff to switch modes and return goes here } macro jmpAlready64 addr{ jmp addr;we are already in 64bit mode so don't need to do anything weird ^^ virtual at addr use64 end virtual} push rax callerThingy SomeAddress pop rcx jmpAlready64 Some64bitPlace SomeAddress: pop eax pop ecx push ebx push edx returnerThingy Some64bitPlace: Please tell me how to make it like that.. Pretty please? P.S. actually my mini condensed example is backwards. My program starts out in 32bit mode and checks if 64bit is supported, and if it's not it gives a little error message and exits gracefully ^^ I don't wanna rewrite the example though, sorry |
|||
06 Aug 2009, 20:15 |
|
r22 06 Aug 2009, 20:56
I don't think there is an efficient way to do what you need. I'm *ALMOST*sure that it's possible but you'd end up having to surround your code in a macro which would be bulkier/messier than what you're doing now.
I think your best bet is to reorganize your source file(s) into use32 and use64 blocks that way it won't be 'littered' with useX's |
|||
06 Aug 2009, 20:56 |
|
Azu 06 Aug 2009, 21:30
Surround it as a whole, or do you mean for each label?
If it's just something like "macrostart" once at the very top and "macroend" once at the very bottom, that would be really good. The only way I can think of needs to be for each label, like this macro label32 label{ label: use32} macro label64 label{ label: use64} |
|||
06 Aug 2009, 21:30 |
|
Madis731 07 Aug 2009, 07:01
What r22 meant was that you don't have to interleave 32/64/32/64, but when you have tens of fragments of these, you can manage with only 2 parts. One for 32 and the other for 64.
Code: use32 ;EVERYTHING 32-bit goes here, all the procs, macros etc. use64 ;EVERYTHING 64-bit goes here... ;If you start executing 32-bit code, you can call the 64_to_32 here and ;jump to the part where use32 is used |
|||
07 Aug 2009, 07:01 |
|
Goto page Previous 1, 2, 3 < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.