1
0
mirror of https://github.com/stid/woz64.git synced 2024-11-26 08:50:11 +00:00
woz64/libs/math.asm
2020-01-19 23:38:20 -08:00

88 lines
2.0 KiB
NASM

#importonce
#import "../core/module.asm"
.filenamespace Math
* = * "Math Lib"
// ========================================================
// ////// METHODS /////////////////////////////////////////
// ========================================================
// --------------------------------------------------------
// init -
// Module Init.
// --------------------------------------------------------
init: {
rts
}
// --------------------------------------------------------
// toDebug -
// Print debug info.
// --------------------------------------------------------
toDebug: {
ModuleToDebug(module_type, module_name, version)
rts
}
// --------------------------------------------------------
// multiply -
// 8 Bit in to 16 Bit out Multiplier
//
// Parameters:
// MemMap.MATH.factor1 = 8 Bit Factor 1
// MemMap.MATH.factor2 = 8 Bit Factor 2
//
// Result
// MemMap.MATH.result = 16 bit result
// --------------------------------------------------------
multiply: {
sei
pha
txa
pha
lda #$00
ldx #$08
clc
m0: bcc m1
clc
adc MemMap.MATH.factor2
m1: ror
ror MemMap.MATH.factor1
dex
bpl m0
ldx MemMap.MATH.factor1
sta MemMap.MATH.result
stx MemMap.MATH.result+1
pla
tax
pla
cli
rts
}
// ========================================================
// ////// DATA ////////////////////////////////////////////
// ========================================================
* = * "Math Lib Data"
module_type: .byte Module.TYPES.LIB
version: .byte 1, 1, 0
.encoding "screencode_mixed"
module_name:
.text "math"
.byte 0
#import "../hardware/mem_map.asm"