flat assembler
Message board for the users of flat assembler.

Index > Main > 32bit/64bit

Goto page Previous  1, 2, 3
Author
Thread Post new topic Reply to topic
sleepsleep



Joined: 05 Oct 2006
Posts: 13045
Location: ˛                             ⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣Posts: 0010456
sleepsleep 26 Apr 2009, 16:15
Quote:

Umm... to make sure I fully understand, would you kindly attach your website address so I can pay a visit?

you should had seen his bart simpson's website? below his nick, there is a [www] button.
Post 26 Apr 2009, 16:15
View user's profile Send private message Reply with quote
Azu



Joined: 16 Dec 2008
Posts: 1159
Azu 23 Jul 2009, 05:47
nvm sorry


Last edited by Azu on 23 Jul 2009, 08:36; edited 1 time in total
Post 23 Jul 2009, 05:47
View user's profile Send private message Send e-mail AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
Madis731



Joined: 25 Sep 2003
Posts: 2139
Location: Estonia
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!?
Post 23 Jul 2009, 08:20
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger Reply with quote
Azu



Joined: 16 Dec 2008
Posts: 1159
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    
Post 05 Aug 2009, 13:39
View user's profile Send private message Send e-mail AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
Madis731



Joined: 25 Sep 2003
Posts: 2139
Location: Estonia
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
Post 06 Aug 2009, 06:37
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger Reply with quote
Azu



Joined: 16 Dec 2008
Posts: 1159
Azu 06 Aug 2009, 06:41
Madis731 wrote:
Then you should use:
Code:
use32
use64
virtual at spot
end     virtual
push    eax
push    eax
spot:
pop     rcx
    

and still no problem
Illegal instruction "push eax" Confused
Post 06 Aug 2009, 06:41
View user's profile Send private message Send e-mail AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
Borsuc



Joined: 29 Dec 2005
Posts: 2465
Location: Bucharest, Romania
Borsuc 06 Aug 2009, 19:38
Madis731 wrote:
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!?
it doesn't work that way. The "use32" and "use64" and "use16" only signal it to the assembler how to encode the instructions, but the CPU is still in the original mode, reading wrong encodings.

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    
the CPU will actually do this since it's in 16-bit mode:
Code:
mov ax, 0    
because it has the same encoding.

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. Razz

With 64-bit it will probably crash since the encoding is really different.

_________________
Previously known as The_Grey_Beast
Post 06 Aug 2009, 19:38
View user's profile Send private message Reply with quote
Azu



Joined: 16 Dec 2008
Posts: 1159
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..
Post 06 Aug 2009, 19:41
View user's profile Send private message Send e-mail AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
Borsuc



Joined: 29 Dec 2005
Posts: 2465
Location: Bucharest, Romania
Borsuc 06 Aug 2009, 20:09
Azu wrote:
Changing the CPU mode is easy
Not in ring 3.

_________________
Previously known as The_Grey_Beast
Post 06 Aug 2009, 20:09
View user's profile Send private message Reply with quote
Azu



Joined: 16 Dec 2008
Posts: 1159
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
Post 06 Aug 2009, 20:11
View user's profile Send private message Send e-mail AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
r22



Joined: 27 Dec 2004
Posts: 805
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.
Post 06 Aug 2009, 20:14
View user's profile Send private message AIM Address Yahoo Messenger Reply with quote
Azu



Joined: 16 Dec 2008
Posts: 1159
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?
Image


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
Post 06 Aug 2009, 20:15
View user's profile Send private message Send e-mail AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
r22



Joined: 27 Dec 2004
Posts: 805
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
Post 06 Aug 2009, 20:56
View user's profile Send private message AIM Address Yahoo Messenger Reply with quote
Azu



Joined: 16 Dec 2008
Posts: 1159
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}

Sad
Post 06 Aug 2009, 21:30
View user's profile Send private message Send e-mail AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
Madis731



Joined: 25 Sep 2003
Posts: 2139
Location: Estonia
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
    
Post 07 Aug 2009, 07:01
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page Previous  1, 2, 3

< Last Thread | Next Thread >
Forum Rules:
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


Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.