flat assembler
Message board for the users of flat assembler.

Index > Compiler Internals > Suggestions on 'strict-ness' of FASM

Author
Thread Post new topic Reply to topic
AsmGuru62



Joined: 28 Jan 2004
Posts: 1413
Location: Toronto, Canada
AsmGuru62
Hi everyone,

Lately I was writing a lot of code and I made some 'blunders'.
Now, that I thought about it -- FASM as a compiler could warn me of a code situations, which are probably incorrect.
I wonder if FASM has any warnings right now in its arsenal.
I know that HLLs have quite a bit of warnings -- protecting the programmer, so to speak.
Smile

So, I have two warning suggestions.

First is about the 'virtual' directive.
Say, I have the following statement:
Code:
virtual at 0
TApplication:
    .Field1  dd ?
       .Field2  rd 16
      .Field3  rw 32
      .size = $
end virtual
    

Now, somewhere in my code I want to point my register at TApplication.Field3:
Code:
mov ebx, [glb_pApp]             ; points to instance of TApplication
lea esi, [ebx + TApplication]   ; <-- Here I forgot the ".Field3"
;
; The above is incorrect!
; The below is what I needed.
;
lea       esi, [ebx + TApplication.Field3]
    

Now, the debugger shows that label from a virtual statement evaluates to 0 and that is fine, however it would have been nice if FASM can warn about a situation where the label is used without a field.
===

Second is about the anonymous label ("@@:" <-- this one!).
Usually, these labels are good in short distances. When the distance increases -- there is a possibility of a mistake to be made. The code usually contains procedures and it would be nice if FASM could warn if a target for anonymous JMP (@f,@r) is located in another procedure:
Code:
Procedure1:
  test    eax, eax
    jz      @f
  ...
@@:
      ...
 test    eax, eax
    jz      @f
  ...
 ...     ; <-- Somewhere here is forgotten '@@:'
    ret

Procedure2:
  mov     ecx, 256
@@:             ; <-- Code from Procedure1 will fall here!
       ...
 loop    @r
  ret
    
Post 29 Dec 2011, 13:43
View user's profile Send private message Send e-mail Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17473
Location: In your JS exploiting you and your system
revolution
I have two simple solutions for your two problems:

1. Don't use virtual for structures. Use struc, that is what it is for.

2. Don't use @@ anywhere. It is just a lazy way to create a label and IMO should not be used.

HTH
Post 29 Dec 2011, 13:52
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7752
Location: Kraków, Poland
Tomasz Grysztar
fasm doesn't have any warning system, its directives are quite low-level, a building blocks which can be used to do many different things. So if only assembling the given composition of those pieces is possible, it is correct -simple as that. Warnings may discourage use of fasm's features in a way that was not predicted earlier, thus I do not plan to have any in the fasm's core. However you can have warnings implemented in some high-level macros, like "struct", which would be designed to be used strictly for one purpose, so it would be good to discourage any non-standard usage in their case.
Post 29 Dec 2011, 14:35
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.