flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
macomics 18 May 2024, 19:25
Then it's worth checking all 'magic' in header
It is also worth considering the case of missing values in both ComSpec and SHELL, or an incorrect value in these variables Code: virtual file "%ComSpec%%SHELL%" if $ > 16 load OS_word word from $$ load OS_dword dword from $$ end if end virtual if OS_word = 'MZ' display 'Windows OS' format pe ... else if OS_dword = 0x7f or ( 'ELF' shl 8 ) display 'Linux OS' format elf ... else display 'Unknown OS' err end if Code: $ touch ./zero.txt; env SHELL="./zero.txt" fasm ostype.asm flat assembler version 1.73.32 (16384 kilobytes memory, x64) Unknown OS ostype.asm [16]: err processed: err error: error directive encountered in source file. $ env ComSpec="./x96dbg.exe" env SHELL="" fasm ostype.asm flat assembler version 1.73.32 (16384 kilobytes memory, x64) Windows OS 1 passes, 512 bytes. $ fasm ostype.asm flat assembler version 1.73.32 (16384 kilobytes memory, x64) Linux OS 1 passes, 268 bytes. $ echo M>./test.txt; env SHELL="./test.txt" fasm ostype.asm flat assembler version 1.73.32 (16384 kilobytes memory, x64) Unknown OS ostype.asm [16]: err processed: err error: error directive encountered in source file. |
|||
![]() |
|
revolution 19 May 2024, 04:01
Under WINE it fails because WINE imports the SHELL value, and also sets the ComSpec value for itself. So the end result is both values run together and it gives this mess:
Code: C:\windows\system32\cmd.exe/bin/bash |
|||
![]() |
|
Furs 19 May 2024, 19:55
Well tbh the solution is too much of a hack since you can just export those envs vars yourself, or change them even.
|
|||
![]() |
|
revolution 20 May 2024, 01:57
I think it is also a hack to have to create, maintain and update a separate file for each system.
Code: ; filename OS.inc OS_Unknown = -1 OS_Linux = 0 OS_Windows = 1 OS_Mac = 2 OS_Unix = 3 OS_DOS = 4 OS_QNX = 5 OS_CPM = 6 OS_OS2 = 7 OS_Menuet = 8 ; ======================================================================== ; IMPORTANT !!!!! change the line below to match the system you have !!!!! ; ======================================================================== OS = OS_ ; <--- complete this line before using !!!!! |
|||
![]() |
|
Furs 20 May 2024, 15:34
Usually you pass it as a command line arg or something along those lines to a compilation script. Or an env var, but one explicitly set for this purpose, not having other side-effects.
Note that there's no guarantee you're even assembling for your own platform in the first place. |
|||
![]() |
|
revolution 20 May 2024, 15:57
If that works for you then great.
I find it extremely convenient to just go to a customer's machine (with whatever OS they might have) and type "fasm source.asm" and done. Then there is no need to fiddle with command line options, or have to select the correct script, or make a custom OS dependant file, etc. All those things are easy to make mistakes, or forget to do. |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.