flat assembler
Message board for the users of flat assembler.

Index > Linux > unwanted Operand-Size Prefix 0x66 (fasmg)

Author
Thread Post new topic Reply to topic
Werner Drasche



Joined: 27 Sep 2022
Posts: 2
Werner Drasche 27 Sep 2022, 12:28
main.asm
Code:
include "80386.inc"
include "format/elf32.inc"

public _start

section ".text" executable
_start:
mov eax, 1
xor ebx, ebx
int 0x80
    

was compiled with
Code:
#!/bin/bash
export INCLUDE=/usr/local/lib/fasmg/x86/include
fasmg main.asm main.o
ld -m elf_i386 main.o -o main
./main
    

and immediately leads to segfault. This is caused by an unwanted operand size override to 16 bit which transforms 1 instruction into 2 (the rest of the immediate is interpreted separately). I am a total beginner in assembly programming, so help would be greatly appreciated.

Extra info:
nasm doesn't use the prefix and the code runs fine without segfaulting.
Post 27 Sep 2022, 12:28
View user's profile Send private message Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 3515
Location: vpcmipstrm
bitRAKE 27 Sep 2022, 15:40
Looks like "80386.inc" defaults to use16 - just adding use32 should be sufficient.
Code:
include "80386.inc"
include "format/elf32.inc"
use32

public _start

section ".text" executable
_start:
mov eax, 1
xor ebx, ebx
int 0x80    
... untested.

It might be better to use the \format\format.inc, or look at how it uses the other files you are including.
Post 27 Sep 2022, 15:40
View user's profile Send private message Visit poster's website Reply with quote
Werner Drasche



Joined: 27 Sep 2022
Posts: 2
Werner Drasche 27 Sep 2022, 18:19
Thank you for the quick reply. Your suggested solution works perfectly and from now on I'll be using format.inc as it sets use32 anyway.
Post 27 Sep 2022, 18:19
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-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.