flat assembler
Message board for the users of flat assembler.
![]() Goto page 1, 2 Next |
Author |
|
idle
edit: download is always located here
hi tomasz, add include's modifier please: Code:
include once 'please.ok?'
Last edited by idle on 15 Dec 2015, 17:37; edited 2 times in total |
|||
![]() |
|
revolution
|
|||
![]() |
|
Tyler
revolution wrote: There are already some macros for that here on this board. ![]() |
|||
![]() |
|
revolution
Tyler wrote: I think your link is broken. It doesn't take me to and example... |
|||
![]() |
|
idle
Quote:
that's what i need |
|||
![]() |
|
Tyler
What exactly do you want once to do?
|
|||
![]() |
|
revolution
Tyler wrote: ... revolution's too lazy to teach you. |
|||
![]() |
|
idle
how that's seen in my mind:
having met include, fasm fetches full path of the file then fasm inspects list of files it has included if no such file included, fasm includes it regardless once presence if a file had been included and once present, fasm does nothing |
|||
![]() |
|
Tyler
Sounds like you're having the multiple declaration problem that C headers solve with condition preprocessor macros. Doesn't Fasm have those?
|
|||
![]() |
|
idle
Done.
version.inc controls if the facility should be included.
Last edited by idle on 17 Feb 2019, 21:30; edited 5 times in total |
|||||||||||
![]() |
|
revolution
Good job. I like to see small modifications like this.
Can you post just the differences (a patch type file) only? Also, I didn't try it, but can the first instance of a file also use the "once" syntax? That is: do users need to worry about which include statement is the first, or can they just make everything "include once"? |
|||
![]() |
|
idle
>>Good job. I like to see small modifications like this.
:) >>Can they just make everything "include once"? They can. >>Can you post just the differences (a patch type file) only? version.inc Code: ... ;; INCLUDEONCE=1 display 13,10,'INCLUDEONCE=',INCLUDEONCE+'0' ;; ... variable.inc Code: ... if INCLUDEONCE=1 ;; change with care align 4 includes: .flags rd 1 .count rd 1 .files rd $ff .limit rd 1 ;; end if ... preproce.inc Code: ... if INCLUDEONCE=1 ;; mov [includes.count],eax mov [includes.files],eax ;last include is none yet ;; end if ... if INCLUDEONCE=1 ;; mov byte[includes.flags],al ;remember include form cmp al,1Ah jne common_include ;no once key lodsb cmp al,4 jne invalid_argument ;length('once') must be 4 :) lodsd or eax,' ' ;case ignorant cmp eax,'once' jne invalid_argument ;no once key lodsb ;resume common include :) common_include: ;; end if ... if INCLUDEONCE=1 ;; movzx eax,al mov al,[upper_case_table+eax] ;; end if ... if INCLUDEONCE=1 ;; mov [esp-8],edi ;[esp-4] =FullName ;[esp-8] =beyond FullName0 ;[FullName-4]=length(FullName) cmp byte[includes.flags],1Ah jne .include_file mov edx,includes.files-4 .match_next_include: add edx,4 mov edi,[edx] test edi,edi jz .include_file mov esi,[esp-4] ;sub esp,8 ;push edx ;invoke MessageBox,0,edi,esi,0 ;pop edx ;add esp,8 mov ecx,[esi-4] cmp ecx,[edi-4] jne .match_next_include repe cmpsb jne .match_next_include .!include_file: call close mov edi,[current_line] mov byte[edi],0 jmp line_preprocessed .include_file: mov edi,[includes.count] lea edi,[includes.files+edi*4] cmp edi,includes.limit je out_of_memory inc [includes.count] mov esi,[esp-4] mov [edi],esi mov [edi+4],dword 0 mov edi,[esp-8] ;; end if ... |
|||
![]() |
|
revolution
Just some things I think people should be aware of before they decide to use it:
There is a limit of 254 files plus one pointer that must be kept as zero to terminate the search. Also the path and case must be specified exactly the same else it won't match. Code: include once 'abc.inc' ;... include once 'ABC.INC' ;<--- on Windows this is the same file. ;... include once '.\abc.inc' ;<--- the same file again but not matched. |
|||
![]() |
|
l_inc
revolution wrote: Also the path and case must be specified exactly the same else it won't match. Well, then the patch is no-go. It's quite controversial by itself, whether it is a responsibility of the includer or the includee to ensure unique inclusion, or how "include once" should behave in relation to the normal include. And if it doesn't even make use of smth. like GetFileInformationByHandle, it's no better than the existing macros doing the same. In the current implementation it's actually worse. _________________ Faith is a superposition of knowledge and fallacy |
|||
![]() |
|
revolution
I don't see why it is worse. But anyhow, knowing the limitations should be enough. Users can then decide if it is fit for their purpose(s). Having some sort of coding standard documentation for specifying file paths could help to avoid problems in one's code.
|
|||
![]() |
|
l_inc
revolution
Quote: I don't see why it is worse. There's at least one technical reason (you mentioned) for that: the limit of 254 files. And the conceptual reason is that macros give more flexibility. E.g., if you have a (say "legacy") project using only include, then you can use my includecheck (it can be improved using irpv) to avoid include duplication without having to refactor the project. Quote: Having some sort of coding standard documentation for specifying file paths could help to avoid problems in one's code. And why should one introduce such a limitation for a native solution, if it is (contrary to macros) possible to avoid it? _________________ Faith is a superposition of knowledge and fallacy |
|||
![]() |
|
revolution
l_inc wrote: And why should one introduce such a limitation for a native solution, if it is (contrary to macros) possible to avoid it? |
|||
![]() |
|
l_inc
revolution
Quote: Because Linux, Unix and Windows would break the code in different ways due to case and path differences. Provide an example. Without it it seems you are just ignoring what I say. _________________ Faith is a superposition of knowledge and fallacy |
|||
![]() |
|
idle
Files limit can migrate from $ff=255 -> $ffff=65535 :)
Code: include OnCe 'abc.inc' include oNcE 'ABC.INC' ;<--- on Windows this is the same file. ; and once knows that ;to see how full paths are operated on, open 1.71.39 preproce.inc and uncomment as follows ; sub esp,8 ; push edx ; invoke MessageBox,0,edi,esi,0 ; pop edx ; add esp,8 ;recompile fasm and run your sources again include once '.\abc.inc' ;<--- the same file again but not matched.
|
|||||||||||
![]() |
|
Goto page 1, 2 Next < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.
Website powered by rwasa.