c128lib Common
Various common functionalities.
Loading...
Searching...
No Matches
math.asm File Reference

Math module. More...

Functions

macro add16 (value, dest)
 
macro sub16 (value, dest)
 
macro addMem16 (source, destination)
 
macro subMem16 (source, destination)
 
macro asl16 (value)
 
macro inc16 (address)
 
macro dec16 (destination)
 
macro mulAndAdd (left, right, targetAddr)
 
macro div16By16 (dividend, divisor, remainder)
 
macro div16By8 (dividend, divisor, remainder)
 

Variables

pseudocommand add16 source
 
pseudocommand asl16 low
 
pseudocommand inc16 address
 
pseudocommand dec16 destination
 

Detailed Description

Math module.

Macros for math.

Date
2022

Function Documentation

◆ add16()

macro add16 ( value ,
dest  )

Adds 16 bit number value to given memory cell specified by dest address and set result to dest.

Parameters
[in]valuefirst addend
[in,out]destmemory location for second addend and result
Remarks
Register .A will be modified. Flags N, Z and C will be affected.
Note
Use c128lib_add16 in math-global.asm
Since
0.6.0

◆ addMem16()

macro addMem16 ( source ,
destination  )

Adds value from "source" memory location to value in "destination" memory location.

Parameters
[in]sourcefirst addend
[in,out]destmemory location for second addend and result
Remarks
Register .A will be modified. Flags N, Z and C will be affected.
Note
Use c128lib_sub16 in math-global.asm
Since
0.6.0

◆ asl16()

macro asl16 ( value )

Shifts left 2 byte number specified with address. Carry flag indicates last bit that has been "shifted out".

Parameters
[in,out]valueaddress to shift
Remarks
Register .A will be modified. Flag C will be affected.
Note
Use c128lib_asl16 in math-global.asm
Since
0.6.0

◆ dec16()

macro dec16 ( destination )

Decrements 16 bit number located in memory address starting from "destination".

Parameters
[in,out]addressaddress to shift
Remarks
Register .A will be modified. Flags N and Z will be affected.
Note
Use c128lib_dec16 in math-global
Since
0.6.0

◆ div16By16()

macro div16By16 ( dividend ,
divisor ,
remainder  )

Divides the two-byte number dividend by the two-byte number divisor, leaving the quotient in dividend and the remainder in remainder. Addressing mode of 16-bit numbers uses little endian.

Parameters
[in,out]dividenddividend and also quotient
[in]divisordivisor
[out]remainderremainder (wide as divisor)
Remarks
Registers .A, .X and .Y will be modified. Flags N, Z and C will be affected.
Note
Use c128lib_div16By16 in math-global
Since
0.6.0

◆ div16By8()

macro div16By8 ( dividend ,
divisor ,
remainder  )

Divides the two-byte number dividend by the one-byte number divisor, leaving the quotient in dividend and the remainder in remainder. Addressing mode of 16-bit numbers uses little endian.

Parameters
[in,out]dividenddividend and also quotient
[in]divisordivisor
[out]remainderremainder (wide as divisor)
Remarks
Registers .A, .X and .Y will be modified. Flags N, Z and C will be affected.
Note
Use c128lib_div16By8 in math-global
Since
0.6.0

◆ inc16()

macro inc16 ( address )

Increments 16 bit number located in memory address starting from "destination".

Parameters
[in,out]addressaddress to shift
Remarks
Register .A will be modified. Flags N and Z will be affected.
Note
Use c128lib_asl16 in math-global.asm
Since
0.6.0

◆ mulAndAdd()

macro mulAndAdd ( left ,
right ,
targetAddr  )

Multiplies left times right. Target value will be added to the value stored in targetAddr.

Parameters
[in]leftfirst factor
[in]destsecond factor
[in,out]targetAddradding value and result
Remarks
Registers .A and .X will be modified. Flags N, Z and C will be affected.
Note
Use c128lib_mulAndAdd in math-global.asm
Since
0.6.0

◆ sub16()

macro sub16 ( value ,
dest  )

Subtracts 16 bit number value from given memory cell specified by dest address and set result to dest.

Parameters
[in]valuesubtracting
[in,out]destmemory location for minuend and result
Remarks
Register .A will be modified. Flags N, Z and C will be affected.
Note
Use c128lib_sub16 in math-global.asm
Since
0.6.0

◆ subMem16()

macro subMem16 ( source ,
destination  )

Subtracts value from "source" memory location from value in "destination" memory location.

Parameters
[in]sourcesubtracting
[in,out]destmemory location for minuend and result
Remarks
Register .A will be modified. Flags N, Z and C will be affected.
Since
0.6.0

Variable Documentation

◆ address

pseudocommand inc16 address

Increments 16 bit number located in memory address starting from "destination".

Parameters
[in,out]addressaddress to shift
Remarks
Register .A will be modified. Flags N and Z will be affected.
Since
0.6.0

◆ destination

pseudocommand dec16 destination

Decrements 16 bit number located in memory address starting from "destination".

Parameters
[in,out]addressaddress to shift
Remarks
Register .A will be modified. Flags N and Z will be affected.
Since
0.6.0

◆ low

pseudocommand asl16 low

Shifts left 2 byte number specified with "low" address. Carry flag indicates last bit that has been "shifted out".

MOD: A, C

◆ source

pseudocommand sub16 source

Subtracts value from "source" memory location from value in "destination" memory location.

MOD: A, C