flat assembler
Message board for the users of flat assembler.

Index > Compiler Internals > mov sr,r16

Author
Thread Post new topic Reply to topic
NoName_s



Joined: 16 Jan 2006
Posts: 19
NoName_s
If i write:
mov r16,imm16
mov fs,r16
mov gs,r16
fasm nothing generate!

But if i wrote this throught stack its generate instructions.
Help plz.

add:
if
mov fs,ax
mov es,ax
mov gs,ax
res
mov es,ax
mov gs,ax

if
mov es,ax
mov gs,ax
res
mov gs,ax

wtf?
Post 08 Feb 2006, 10:30
View user's profile Send private message Reply with quote
NoName_s



Joined: 16 Jan 2006
Posts: 19
NoName_s
if comment use32 string my code generate ok. fasm 1.64
Post 08 Feb 2006, 12:24
View user's profile Send private message Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 7724
Location: Kraków, Poland
Tomasz Grysztar
Can you post some complete source that shows your problem?
Post 08 Feb 2006, 13:23
View user's profile Send private message Visit poster's website Reply with quote
shoorick



Joined: 25 Feb 2005
Posts: 1605
Location: Ukraine
shoorick
you can not load segment registers with immediate value. only with other registers or via push/pop
===
i was wrong, but here is test:


Description: produced code
Filesize: 1.81 KB
Viewed: 4722 Time(s)

3.gif


Description: if there is use32 instead of use 16
Filesize: 4.16 KB
Viewed: 4723 Time(s)

2.gif



_________________
UNICODE forever!


Last edited by shoorick on 08 Feb 2006, 14:44; edited 1 time in total
Post 08 Feb 2006, 13:25
View user's profile Send private message Visit poster's website Reply with quote
shoorick



Joined: 25 Feb 2005
Posts: 1605
Location: Ukraine
shoorick
i think shown in debugger window is because debugger treat code as 16-bit while it is 32-bit, thus shows wrong. in real, it is exacltly "mov ax" for 32-bit code, and next command is included into continued immediate because of wrong disassembly
Post 08 Feb 2006, 14:11
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 7724
Location: Kraków, Poland
Tomasz Grysztar
Yes, the problem lies in using the right mode for disassembly. With HIEW or BIEW it's very easy to switch between 16- and 32-bit mode, you should always adjust it accordingly.
Post 08 Feb 2006, 14:18
View user's profile Send private message Visit poster's website Reply with quote
NoName_s



Joined: 16 Jan 2006
Posts: 19
NoName_s
imm = const
rxx = reg
sr = segment register
this error in this code:

Code:
use32 ; <---
jump selector:offset
mov ax,imm16
mov sg,ax    


And i found some problem before;
fasm generate wrong code on this ~

Code:
;far call
call [sr:offset]    

i don't know now how of sr's not correct try to brute it, one not generated as must

add:
And one problem. if i not write use32 all r32 assembled as r32, but if i use rep movsd i must write prefix db 67, why?
Post 08 Feb 2006, 19:16
View user's profile Send private message Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 7724
Location: Kraków, Poland
Tomasz Grysztar
This source:
Code:
use32
jmp 0:0
mov ax,4
mov fs,ax    

Generates the following (disassembly made using HIEW, after switching to 32-bit mode):
Code:
00000000: EA000000000000               jmp         00000:000000000
00000007: 66B80400                     mov         ax,00004
0000000B: 8EE0                         mov         fs,ax    

Everything seems to be correct.

As for the second one, like in this sample:
Code:
call far [fs:offset]    

This the indirect jump, thus the address it jumps to is taken from the memory location, and the FS applies to the address of this location. The selector/segment of the target of jump is stored in the first 16 bits of PWORD at that location. I explain this here, because I'm under impression you're expecting this instruction to work differently than it does.
Post 08 Feb 2006, 19:43
View user's profile Send private message Visit poster's website Reply with quote
NoName_s



Joined: 16 Jan 2006
Posts: 19
NoName_s
what about movsd?
Post 09 Feb 2006, 09:21
View user's profile Send private message Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 7724
Location: Kraków, Poland
Tomasz Grysztar
See section 2.1.8 of manual for the complete information on the MOVS syntax.
manual wrote:
Every string operation instruction has short forms which have no operands and use SI and/or DI when the code type is 16-bit, and ESI and/or EDI when the code type is 32-bit.
Post 09 Feb 2006, 09:30
View user's profile Send private message Visit poster's website 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.

Powered by rwasa.