This is an old revision of the document!


Math

The Math Routines manipulate BCD and decimal numbers and store/transfer data.

Note: Most of the Math routines are undocumented in the Nutting Manual. Their definitions and usage are largely found in the system ROM source listing and Bally On-Board ROM Subroutines.

Math System Routines

Undocumented routines are marked with an asterisk (*)

Need documentation for most math routines

Name Description
BCDADD* BCD add
BCDCHS* BCD change sign
BCDDIV* BCD divide
BCDMUL* BCD multiply
BCDNEG* BCD negate
BCDSUB* BCD subtract
DABS* Decimal absolute value
DADD* Decimal add
DSMG* Decimal convert to sign magnitude
INDEXB Returns byte at address + displacement
INDEXN Look up a given nibble in a linear list
INDEXW Look up a given word in a linear list
MOVE Block transfer, copies bytes from source to destination
NEGT* Decimal negate
RANGED Generate ranged random number
SETB Store byte at a specified address
SETW Store 16-bit word at specified address
SHIFTU* Shift up digit in A
STOREN Store 4-bit nibble in a linear list

Math System Routine Descriptions

BCDADD

BCD ADDITION

Calling Sequence:
SYSTEM    BCDADD

or

SYSSUK    BCDADD
DW       (arg 1)
DB       (size/2 + 1)
DW       (arg 2)
Arguments: B = SIZE/2 + 1
DE = Argument 1
HL = Argument 2
Output: DE = Answer
Notes: None
Description:

BCDCHS

BCD CHANGE SIGN

Calling Sequence:
SYSTEM    BCDCHS

or

SYSSUK    BCDCHS
DB       ()
DW       ()
Arguments: