mirror of
https://github.com/netwide-assembler/nasm.git
synced 2024-11-21 03:14:19 +08:00
36cd305ade
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>
48 lines
972 B
NASM
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`
|