2

I am currently familiarizing myself with the possibilities of Turbo Assembler 2.0; I was happy to find out that float constants can be specified as follows.

SomeVariable dd 72.0; corresponds to 042900000h

I was assuming that it is possible to evaluate expressions at assembly-time, like

SomeVariable dd 1.0 / 4.0; does not assemble

however this seems to be impossible. Is there indeed no possiblity to generate constants even from relatively simple expressions at assemble-time?

Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
Codor
  • 17,447
  • 9
  • 29
  • 56

1 Answers1

5

For FP math, I'm not surprised some (most?) assemblers choose not to do assemble-time eval. That would raise questions like what rounding mode, and what intermediate precision if the expression is more than one operator?

Most assemblers do integer constant-expressions just fine, including with equ and equivalent foo = 123 named constants.

Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
  • In a real address mode assembler that I wrote, every numerical expression is evaluated with FP math. The rounding mode is the FPU's default 'round to nearest' and all intermediate results are stored in the 80-bit extended precision. I chose this path to save me from using an external calculator; now I has one built-in! – Sep Roland Jan 23 '22 at 22:53
  • @SepRoland: Interesting choice. Sure you can just define some specific semantics. That wouldn't work for NASM or GAS, though. They're portable and can work as cross-assemblers, written in C. You can compile and run NASM on a PowerPC to create bit-identical x86 machine code to what you'd get from assembling the same file on an x86 machine. Emulating 80-bit x87 evaluation of expressions in portable C would not be a fun time. This is a TASM question it seems; IDK what TASM was written in, perhaps Borland Turbo C++. They *could* have used `long double`, but it had to run on no-FPU machines. – Peter Cordes Jan 23 '22 at 22:58