FASM include по двум возможным адресам?

Assembler programming questions
  • The closest to what you are trying to achieve is done via 'include' environment variable, see the corresponding fasm programmer's manual section.
  • If 'include' does not find the file, it interrupts compilation and there is no way to skip error. I think solution is not exist.
  • The trick (a documented one though) is to provide several paths to look for the included file.

    Code: Select all

    $ 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
  • 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 5325 times
  • 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.
  • 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: Select all

    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.
  • Try this:

    Code: Select all

    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
  • Same approach but a bit cleaner:

    Code: Select all

    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.
  • I think this is will be work...

    Code: Select all

    match =NOTHING,AUTOBUILD {
      include ''/sys/lang.inc'
      include ''/sys/macros.inc'
    }
    
    match =YES, AUTOBUILD {
      include 'lang.inc'
      include '../../../macros.inc'
    }
  • : [quote]is will be[/quote]
    такого я ещё не видел)
  • Who is online

    Users browsing this forum: No registered users and 1 guest