flat assembler
Message board for the users of flat assembler.

Index > Compiler Internals > One more byte for lgdt instruction ?

Author
Thread Post new topic Reply to topic
Gilles



Joined: 25 Oct 2004
Posts: 24
Gilles
Until yesterday I was using Fasm 1.56 for my compilation issues it works fine (because programs were running as I expected them to). But something strange appears when I decided to move to Fasm 1.65.17. The compilation was done without error but the program hang.So I ask my self the question WHY ?

1) I though I made some change and forgot about it so I looked into my code and compare it with the one some week before (I use to backup project like that).There were no change.

2) I fired again Fasm 1.65.17 and load my program into a debugger and begin tracing, I came accross this instruction
Code:
 lgdt fword [gdt10]
 ...
 gdt10 dw ?
       dd 0x92000000
       dw ?
    


the code above disassemble like this:
66 0F 01 16 ....

the result was a wrong address in GDT base address

Note:
I did not want data override byte because the code was under a 'use16'

Result 1: Strange byte 0x66

3) I fire this time with fasm 1.56
There was no 0x66 byte and GDT was just as I expected it
I also notice that the result file size after 1.65.17 compilation was one byte more than 1.56 compilation (probably this 0x66).

4) Question 2: Was I wrong since the begining (bug corrected in 1.56 lead to 1.65.17) ?
I wrote this just to be sure
Code:
 use16
 align 1
 org 0
 lgdt fword [gdt10]
 lgdt fword [gdt10]
 db 'G'
 gdt10 dw 0x55
       dd 0x77777777
    


here are the results:
from fasm 1.56 17 bytes
Code:
 0F 01 16 0B 00
 0F 01 1E 0B 00
 47
 55 00
 77 77 77 77 
    


from fasm 1.65.17 19 bytes
Code:
 66 0F 01 16 0B 00
 66 0F 01 1E 0B 00
 47
 55 00
 77 77 77 77 
    


My question now is What is the correct version ?
Bug or not ?
Code:
    
Post 11 Apr 2006, 07:49
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7725
Location: Kraków, Poland
Tomasz Grysztar
Post 11 Apr 2006, 11:18
View user's profile Send private message Visit poster's website Reply with quote
Gilles



Joined: 25 Oct 2004
Posts: 24
Gilles
Tomasz Grysztar wrote:
Yes, this was a bug fix, see http://board.flatassembler.net/topic.php?t=4827

Sorry if Iseems to insist on this: Is it possible to avoid address overide here ?
Post 11 Apr 2006, 12:02
View user's profile Send private message Visit poster's website Reply with quote
Gilles



Joined: 25 Oct 2004
Posts: 24
Gilles
Oops I decide to do it like this:
Code:

 use16
 mov bx,gdt10  <---
 lgdt [bx]

    


Thanks a lot Guys Smile
Post 11 Apr 2006, 12:10
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7725
Location: Kraków, Poland
Tomasz Grysztar
You can do it this way:
Code:
lgdt [gdt10]
 ...
 gdt10:
       dw ?
       dd 0x92000000
       dw ?    
Post 11 Apr 2006, 14:20
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. Also on YouTube, Twitter.

Website powered by rwasa.