nasm/test/numtest.asm
H. Peter Anvin 36cd305ade preproc: add %abs(), modify %num(), refactor
Add the %abs() function, to produce the absolute value as an
always-positive decimal constant.

Change the order of the arguments for %num().

Refactor the handling of optional arguments, to reduce the amount of
redundant code. This is currently only used for builtin functions, but
might be extended in the future.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2022-11-17 15:29:10 -08:00

48 lines
972 B
NASM

%define a 64
%define b -30
dq a*b
db %num(a*b,,16), `\n`
db %num(a*b,16,16), `\n`
db %num(a*b), `\n`
db %num(a*b,10), `\n`
db %num(a*b,3), `\n`
db %num(a*b,-3), `\n`
db %num(a*b,10,2), `\n`
db %num(a*b,-10,2), `\n`
db %num(a*b,,2), `\n`
dq -a*b
db %num(-a*b,,16), `\n`
db %num(-a*b,16,16), `\n`
db %num(-a*b), `\n`
db %num(-a*b,10), `\n`
db %num(-a*b,3), `\n`
db %num(-a*b,-3), `\n`
db %num(-a*b,10,2), `\n`
db %num(-a*b,-10,2), `\n`
dq %abs(a*b)
db %num(%abs(a*b),,16), `\n`
db %num(%abs(a*b),16,16), `\n`
db %num(%abs(a*b)), `\n`
db %num(%abs(a*b),10), `\n`
db %num(%abs(a*b),3), `\n`
db %num(%abs(a*b),-3), `\n`
db %num(%abs(a*b),10,2), `\n`
db %num(%abs(a*b),-10,2), `\n`
dq %abs(-a*b)
db %num(%abs(-a*b),,16), `\n`
db %num(%abs(-a*b),16,16), `\n`
db %num(%abs(-a*b)), `\n`
db %num(%abs(-a*b),10), `\n`
db %num(%abs(-a*b),3), `\n`
db %num(%abs(-a*b),-3), `\n`
db %num(%abs(-a*b),10,2), `\n`
db %num(%abs(-a*b),-10,2), `\n`