Board.KolibriOS.org

Official KolibriOS board
It is currently Mon Nov 29, 2021 3:14 am

All times are UTC+03:00




Post new topic  Reply to topic  [ 11 posts ] 
Author Message
PostPosted: Tue Oct 05, 2021 8:36 pm 
Offline

Joined: Wed Sep 22, 2021 9:36 pm
Posts: 26
Возможно ли в FASM загрузить inc файл если он не найден по одному пути, загрузить его по другому пути.

что-то вроде этого:

Code:
include '../../../macros.inc'
if varible from macros not exist
   include 'rd1/macros.inc'
endif


Top
   
PostPosted: Tue Oct 05, 2021 9:00 pm 
Offline
Mentor
User avatar

Joined: Mon Oct 19, 2009 10:58 am
Posts: 703
The closest to what you are trying to achieve is done via 'include' environment variable, see the corresponding fasm programmer's manual section.


Top
   
PostPosted: Wed Oct 06, 2021 9:22 pm 
Offline

Joined: Wed Sep 22, 2021 9:36 pm
Posts: 26
If 'include' does not find the file, it interrupts compilation and there is no way to skip error. I think solution is not exist.


Top
   
PostPosted: Wed Oct 06, 2021 10:14 pm 
Offline
Mentor
User avatar

Joined: Mon Oct 19, 2009 10:58 am
Posts: 703
The trick (a documented one though) is to provide several paths to look for the included file.

Code:
$ cat main.asm
include 'blah.inc'
display 'hi, ', NAME
db NAME

$ cat one/blah.inc
NAME equ 'Alice'

$ cat two/blah.inc
NAME equ 'Bob'

$ INCLUDE='one;two' fasm main.asm main
flat assembler  version 1.73.28  (16384 kilobytes memory, x64)
hi, Alice
1 passes, 5 bytes.

$ hexdump -C main
00000000  41 6c 69 63 65                                    |Alice|
00000005

$ INCLUDE='two;one' fasm main.asm main
flat assembler  version 1.73.28  (16384 kilobytes memory, x64)
hi, Bob
1 passes, 3 bytes.

$ hexdump -C main
00000000  42 6f 62                                          |Bob|
00000003


Top
   
PostPosted: Thu Oct 07, 2021 6:37 pm 
Offline

Joined: Wed Sep 22, 2021 9:36 pm
Posts: 26
i try in asm file use include:

include "../../../macros.inc;/sys/macros.inc"

but FASM shows error:


Attachments:
include.png
include.png [ 3.25 KiB | Viewed 1061 times ]
Top
   
PostPosted: Thu Oct 07, 2021 7:11 pm 
Offline
Mentor
User avatar

Joined: Mon Oct 19, 2009 10:58 am
Posts: 703
In my example INCLUDE='one;two' is an environment variable, and the file is included as include 'blah.inc'. Fasm can handle several paths only when they are provided in an environment variable, not after include keyword.

I see that you are using an absolute path /sys/lang.inc, i.e. you are trying to compile from KolibriOS. Well, KolibriOS doesn't support environment variables. If your aim is to be able to compile your program from both KolibriOS and Windows/Linux, then you can do as follows:
  1. Copy all the standard includes (like macros.inc and lang.inc) to the directory of the main *.asm file of your program.
  2. Include these standard includes without specifying any path, just include 'macros.inc'.
  3. Compile from KolibriOS as usual.
  4. Compile from Windows/Linux specifying INCLUDE environment variable with paths to standard includes.


Top
   
PostPosted: Thu Oct 07, 2021 9:57 pm 
Offline

Joined: Wed Sep 22, 2021 9:36 pm
Posts: 26
This is way is possible but it not comfortable when it need to use environment variable.

Are there any ways to get operating system type in FASM code? Or version of FASM? Any variable?
That can able to do something like:

Code:
if FASM_OS = 'Kolibri'
    include '/sys/macros.inc'     ; path for build in KOS   
else
    include '../../../macros.inc'  ; path for build in SVN
endif


But im look documentation and FASM source code on SVN, and not find varibles for detect OS.


Top
   
PostPosted: Thu Oct 07, 2021 11:30 pm 
Offline
Mentor
User avatar

Joined: Mon Oct 19, 2009 10:58 am
Posts: 703
Try this:
Code:
FASM_OS equ KOLIBRIOS

match =KOLIBRIOS, FASM_OS {
  include 'one/blah.inc'
}

match =LINUX, FASM_OS {
  include 'two/blah.inc'
}

https://board.flatassembler.net/topic.php?t=21883


Top
   
PostPosted: Sat Oct 09, 2021 10:33 pm 
Offline
Mentor
User avatar

Joined: Mon Oct 19, 2009 10:58 am
Posts: 703
Same approach but a bit cleaner:
Code:
match =AUTOBUILD,AUTOBUILD {
  include 'one/blah.inc'
}

match =YES, AUTOBUILD {
  include 'two/blah.inc'
}

Compile from KolibriOS as usual, from Linux/Windows with -dAUTOBUILD=YES.


Top
   
PostPosted: Mon Oct 18, 2021 10:01 pm 
Offline

Joined: Wed Sep 22, 2021 9:36 pm
Posts: 26
I think this is will be work...

Code:
match =NOTHING,AUTOBUILD {
  include ''/sys/lang.inc'
  include ''/sys/macros.inc'
}

match =YES, AUTOBUILD {
  include 'lang.inc'
  include '../../../macros.inc'
}


Top
   
PostPosted: Thu Oct 21, 2021 8:27 pm 
Offline

Joined: Sun Aug 09, 2015 3:41 pm
Posts: 125
Offtopic:
Quote:
is will be

такого я ещё не видел)


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 11 posts ] 

All times are UTC+03:00


Who is online

Users browsing this forum: No registered users and 1 guest


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 post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Limited