flat assembler
Message board for the users of flat assembler.

Index > Main > Issue with fasmg 32-bit compilation: why '66' inx prefixes ?

Author
Thread Post new topic Reply to topic
fabbel



Joined: 30 Oct 2012
Posts: 83
fabbel 13 Mar 2023, 13:13
Hi all

Maybe someone can help with below very basic issue :
am just starting with switching from FASM to FASMG..
and getting puzzled by result of compilation - pbly some newbie err...

trying some very basic test code as follows
(raw binary output format) :

Code:
use32

include 'cpu\80486.inc'

push ebp
mov ebp, esp


mov esp, ebp
pop ebp
ret
    


i get following binary from FASMG compilation :
66 55 66 89 E5 66 89 EC 66 5D C3


Why am I getting those "66" prefixes in 32-bit mode ?
What am I doing wrong ?

(... exact same code - w/o the include - compiled with FASM does not yield the same...)

Tx 4 help
Post 13 Mar 2023, 13:13
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8346
Location: Kraków, Poland
Tomasz Grysztar 13 Mar 2023, 13:38
The CPU headers set up the default "use16" mode when you include them. You need to switch to "use32" after the CPU headers are set up, not before.

This is similar to how FORMAT directive in fasm 1 sets up default mode for the selected format (and the same happens if you use FORMAT emulation in fasmg) - if you need to switch to a different instruction encoding mode, you should do it after setting up the target architecture, not before.

You could also assemble the same source as with fasm 1 by adding the [include 'cpu/80486.inc'] statement from the command line with the -i switch. The architecture would be set up before proceeding to the actual source (and the "use32" line), and so the result should be the same as with fasm 1.
Post 13 Mar 2023, 13:38
View user's profile Send private message Visit poster's website Reply with quote
fabbel



Joined: 30 Oct 2012
Posts: 83
fabbel 13 Mar 2023, 14:04
OK working now
tx 4 quick reply !
Post 13 Mar 2023, 14:04
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< 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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.