flat assembler
Message board for the users of flat assembler.

Index > Compiler Internals > Out-of-range load/store doesn't stop assembly pass

Author
Thread Post new topic Reply to topic
baldr



Joined: 19 Mar 2008
Posts: 1651
baldr
Code:
db 1
rept 10 i:0 {
  load b from i
  display '!'+b
}
display "done"    
FASM continues assembly pass after it detects error in load b from 1. Probably this is a feature. What is its purpose, I don't understand (perhaps it's a part of something bigger/unfinished). For now I made the following changes (just to be safe):
Code:
     mov     [error_line],eax
;--- ASSEMBLE.INC [680] Stop assembly on load address error
;    mov     [error],value_out_of_range
;+++
  jmp     value_out_of_range
;===
      value_loaded:

;...

       mov     [error_line],eax
;--- ASSEMBLE.INC [746] Stop assembly on store address error
;   mov     [error],value_out_of_range
; jmp     instruction_assembled
;+++
       jmp     value_out_of_range
;===

display_directive:    
Post 30 May 2010, 15:05
View user's profile Send private message Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 7489
Location: Kraków, Poland
Tomasz Grysztar
baldr wrote:
FASM continues assembly pass after it detects error in load b from 1. Probably this is a feature. What is its purpose, I don't understand (perhaps it's a part of something bigger/unfinished)

It's on of the so-called "recoverable errors". Since there is a possibility that error was caused by the intermediate (not yet resolved) values, assembler tries to ignore errors where it can, and tries to do another pass. Only if the error still occurs even when there's nothing more to resolve, it is accepted that this truly is an error.
This helps fasm to resolve the code (that is: to find a correct "solution" - code that reflects the source in a valid way).

The classical example of "recoverable error" is the "RB -1", which I sometimes recommended to use as a recoverable equivalent of ERR directive (which is not recoverable, just like "illegal instruction" error). For example:
Code:
if $>0FFFFh
  display "ERROR: code segment overflow"
  rb -1
end if    

Using ERR there would not be a good choice, because during the intermediate stages, before fasm finds the final, optimized (hopefully) solution, the code may be larger and with ERR inside such IF you wouldn't get the assemby process completed. However with "recoverable" error caused by "rb -1" you can be sure that only the overflow of final resolved code size will really cause an error.

Also, if you aligned your output size this way:
Code:
rb 0FFFFh-$    
it would be a natural example of how RB with negative number as an argument causes a "recoverable" error.

The intermediate passes don't have to be "correct" (in fact - they never are, because if a pass finishes with a correct solution, it is the final pass). So really, assembler can do a real mess there, as long as it helps it to find the initial values that will help to find the right solution in the end.


Last edited by Tomasz Grysztar on 30 May 2010, 19:11; edited 1 time in total
Post 30 May 2010, 16:49
View user's profile Send private message Visit poster's website Reply with quote
baldr



Joined: 19 Mar 2008
Posts: 1651
baldr
Tomasz Grysztar,

Thank you very much. I've noticed different handling of some errors, now it's clear.
Post 30 May 2010, 18:06
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 16890
Location: In your JS exploiting you and your system
revolution
baldr: In fasmarm I call this a deferrable error. That is, the error is deferred until later. Often when we get to "later" the error has disappeared. If the error persists then you get a message telling you that assembly failed.
Post 30 May 2010, 18:24
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-2019, Tomasz Grysztar.

Powered by rwasa.