flat assembler
Message board for the users of flat assembler.

Index > Compiler Internals > Number of passes : probable bug

Author
Thread Post new topic Reply to topic
Posetf



Joined: 01 Mar 2004
Posts: 35
Location: London
Posetf 03 Mar 2004, 02:48
After a minor edit, I noticed that the number of passes required to compile my program suddenly dropped from 3 to 2, and I could not work out why, so I cropped the file down as much as I could. The actual line I noticed it on is marked with ;! but now even removing a "mov eax,1" or changing a "cmp eax, 0x80000004" to "cmp eax,1" now has this effect(!). I can't make it any smaller than I have (sorry).

It isn't causing me any problem, but behind even the smallest anomaly one suspects there may be a nasty bug lurking. Please don't try to run this program!

format PE
section '.data' data readable writeable
x db 0
virtual at ebx ; exception_pointers
exception_record dd ?
context_record dd ?
end virtual
virtual at eax ; context_record
context_flags dd ?
dr_0 dd ? ; debug register 0
dr_1 dd ?
dr_2 dd ?
dr_3 dd ?
dr_6 dd ?
dr_7 dd ?
fp_cw dd ? ; control word
fp_sw dd ? ; status word
fp_tw dd ? ; tag word
fp_eo dd ? ; error offset
fp_es dd ? ; error selector
fp_do dd ? ; data offset
fp_ds dd ? ; data selector
fp_st0 dt ? ; floating point register 0
fp_st1 dt ?
fp_st2 dt ?
fp_st3 dt ?
fp_st4 dt ?
fp_st5 dt ?
fp_st6 dt ?
fp_st7 dt ?
fp_cron dd ? ; ? Cr0NpxState ?
sr_gs dd ? ; gs register
sr_fs dd ? ; gs register
sr_es dd ? ; gs register
sr_ds dd ? ; gs register
or_edi dd ? ; edi
or_esi dd ? ; esi
or_ebx dd ?
or_edx dd ?
or_ecx dd ?
or_eax dd ?
end virtual
section '.text' code readable executable
_putstr:
ret

handler:
jmp _donewith
cmp eax, 0x80000004 ;1!
jnz @f
mov esi,x
call _putstr
mov eax,[context_record]
mov eax,[dr_6]
and eax,0x0000F00F
cmp eax,1
jnz _unknown
mov esi,x
;!
call _putstr
jmp _donewith
@@:
cmp eax,0xC0000094 ;;1!
jnz @f
mov esi, x
call _putstr
mov eax,[context_record]

mov [or_eax],0
mov [or_edx],0
mov [or_ebx],1
mov [or_ecx],1
jmp _donewith
@@:
_unknown:
mov esi,x
call _putstr
call _donewith
mov eax,1
ret

_donewith:
ret
start:
ret
entry start
Post 03 Mar 2004, 02:48
View user's profile Send private message Visit poster's website Reply with quote
comrade



Joined: 16 Jun 2003
Posts: 1150
Location: Russian Federation
comrade 03 Mar 2004, 03:08
Most probably explanation is reassessment of jumps. "mov eax,1" is a five-byte instruction, and so is "cmp eax, 0x80000004". "cmp eax, 1" is only three bytes. Adding these instructions probably causes some label to go beyond a certain range (say +127/-127), and that is why jumps have to be reassed (so 3 passes). Removing a large instruction like "mov eax,1" or substituting a large cmp with a smaller one will also most likely make some jmp be a short jump (+127/-127 range), and FASM would not need make additional pass. Or could be other way around...

_________________
comrade (comrade64@live.com; http://comrade.ownz.com/)
Post 03 Mar 2004, 03:08
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger ICQ Number 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.