NASM - The Netwide Assembler

NASM Forum => Using NASM => Topic started by: ReturnInfinity on November 26, 2024, 01:10:16 AM

Title: Conditional Assembly question
Post by: ReturnInfinity on November 26, 2024, 01:10:16 AM
Hello everyone,

I'm starting to make use of the Conditional Assembly to check for environmental variables at build time. Currently I have some boot code that contains functions for BIOS and UEFI systems and am building two separate binaries with the same source:

Code: [Select]
export BIOS=1
nasm pure64.asm -o ../bin/pure64-bios.sys -l ../bin/pure64-bios-debug.txt
unset BIOS
export UEFI=1
nasm pure64.asm -o ../bin/pure64-uefi.sys -l ../bin/pure64-uefi-debug.txt
unset UEFI

This works but is it the expected method for using environmental variables? Not sure if there is a cleaner way to accomplish this.

Thanks,
-Ian
Title: Re: Conditional Assembly question
Post by: fredericopissarra on November 28, 2024, 11:46:55 AM
Try this:
Code: [Select]
$ nasm -DBIOS=1 pure64.asm -o ../bin/pure64-bios.sys -l ../bin/pure64-bios-debug.txt
$ nasm -DUEFI=1 pure64.asm -o ../bin/pure64-uefi.sys -l ../bin/pure64-uefi-debug.txt
Title: Re: Conditional Assembly question
Post by: ReturnInfinity on December 05, 2024, 02:55:12 AM
That works! I just had to change all instances of %ifenv to %ifdef in my code.

Thank you!