Author Topic: Conditional Assembly question  (Read 2974 times)

Offline ReturnInfinity

  • Jr. Member
  • *
  • Posts: 5
Conditional Assembly question
« 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

Offline fredericopissarra

  • Full Member
  • **
  • Posts: 374
  • Country: br
Re: Conditional Assembly question
« Reply #1 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
« Last Edit: November 28, 2024, 11:53:01 AM by fredericopissarra »

Offline ReturnInfinity

  • Jr. Member
  • *
  • Posts: 5
Re: Conditional Assembly question
« Reply #2 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!