Message board for the users of flat assembler.
> Compiler Internals > Suggestions on 'strict-ness' of FASM
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.
So, I have two warning suggestions.
First is about the 'virtual' directive.
Say, I have the following statement:
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:
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:
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
|29 Dec 2011, 13:43||
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.
|29 Dec 2011, 13:52||
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.
|29 Dec 2011, 14:35||
< Last Thread | Next Thread >
Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.
Website powered by rwasa.