flat assembler
Message board for the users of flat assembler.

Index > Compiler Internals > Is it bug?

Author
Thread Post new topic Reply to topic
CandyMan



Joined: 04 Sep 2009
Posts: 414
Location: film "CandyMan" directed through Bernard Rose OR Candy Shop
CandyMan 18 Nov 2011, 22:01
format ELF
use16
Dest: jnz Dest

error: address sizes do not agree
Post 18 Nov 2011, 22:01
View user's profile Send private message Reply with quote
DOS386



Joined: 08 Dec 2006
Posts: 1903
DOS386 19 Nov 2011, 08:07
Your BUG and bad error message from FASM. There is no 16-bit ELF, only 32-bit and 64-bit Wink It should break already at "use16" Shocked

Try also:

Code:
  use16
  mov [cx], ax
    


PS: please fix (CandyMan) the subject (I can't edit other people's posts in this subforum)

PPSS: probably "use16" should be explicitly prohibited in any format except binary and MZ ... see FORMATS.INC line 686 and fix (Tomasz) this one too Wink
Post 19 Nov 2011, 08:07
View user's profile Send private message Reply with quote
ouadji



Joined: 24 Dec 2008
Posts: 1081
Location: Belgium
ouadji 19 Nov 2011, 09:20
Image

How to do this Tomasz ? (where is my error ?)

Image

_________________
I am not young enough to know everything (Oscar Wilde)- Image
Post 19 Nov 2011, 09:20
View user's profile Send private message Send e-mail Reply with quote
DOS386



Joined: 08 Dec 2006
Posts: 1903
DOS386 19 Nov 2011, 09:25
RTFF Smile
Post 19 Nov 2011, 09:25
View user's profile Send private message Reply with quote
Fanael



Joined: 03 Jul 2009
Posts: 168
Fanael 19 Nov 2011, 23:49
DOS386 wrote:
Your BUG and bad error message from FASM. There is no 16-bit ELF, only 32-bit and 64-bit Wink
But this doesn't prevent me from having 16-bit code in the file, maybe I want a 32-bit program to write another, 16-bit one, to a disk? In this case, using 16-bit code is perfectly legitimate, so it's a bug in FASM.
Post 19 Nov 2011, 23:49
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8357
Location: Kraków, Poland
Tomasz Grysztar 20 Nov 2011, 00:47
Neither allowing 16-bit code inside ELF object is a bug (as you may want to have 16-bit code inside 32-bit file, as Fanael wrote), and neither is an error signalized when it is not possible to generate relocation to 32-bit address for a 16-bit instruction, which can contain only 16-bit one (and that's why you get the "address sizes do not agree" message).
Code:
format ELF 
use16; this changes code generation, but not ORG
Dest: ; so we still use 32-bit relocatable ORG, and "Dest" address
jnz Dest ; needs 32-bit relocation and thus can not be used in such instruction    

Code:
format ELF
use16
org 100h ; now we state that this piece of 16-bit code will get loaded at address 100h
Dest:
jnz Dest ; and it works    
Post 20 Nov 2011, 00:47
View user's profile Send private message Visit poster's website Reply with quote
ouadji



Joined: 24 Dec 2008
Posts: 1081
Location: Belgium
ouadji 20 Nov 2011, 01:06

and about this, i don't understand why it does not compile.
where is my error Tomasz ? Thank you.
Code:
use16
mov [cx],ax ;reserved word used as symbol (??)
    


_________________
I am not young enough to know everything (Oscar Wilde)- Image
Post 20 Nov 2011, 01:06
View user's profile Send private message Send e-mail Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8357
Location: Kraków, Poland
Tomasz Grysztar 20 Nov 2011, 01:14
"cx" is not one of registers that can be used for addressing in 16-bit mode. This strange message comes from the fact that after not finding any addressing register of that name, fasm tries to use it as a label name, but fails because it is a reserved word - it is like if you tried to assemble "mov [mov],ax" for example.
Post 20 Nov 2011, 01:14
View user's profile Send private message Visit poster's website Reply with quote
ouadji



Joined: 24 Dec 2008
Posts: 1081
Location: Belgium
ouadji 20 Nov 2011, 01:53
Quote:
"cx" is not one of registers that can be used for addressing in 16-bit mode.

of course! ... on this one, I'm an half-wit. Embarassed
Code:
use16
mov [bx],ax
    


_________________
I am not young enough to know everything (Oscar Wilde)- Image
Post 20 Nov 2011, 01:53
View user's profile Send private message Send e-mail 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.