mirror of
https://github.com/stid/woz64.git
synced 2024-11-22 11:32:29 +00:00
88 lines
2.0 KiB
NASM
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"
|
|
|