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

88 lines
2.0 KiB
NASM
Raw Normal View History

2020-01-12 08:10:01 +00:00
2019-11-06 04:31:17 +00:00
#importonce
2020-01-19 06:48:59 +00:00
#import "../core/module.asm"
2020-01-12 08:10:01 +00:00
2019-11-06 04:31:17 +00:00
.filenamespace Math
2020-01-19 06:48:59 +00:00
* = * "Math Lib"
2019-11-06 04:31:17 +00:00
2020-01-13 00:52:10 +00:00
// ========================================================
// ////// METHODS /////////////////////////////////////////
// ========================================================
2019-11-10 03:10:52 +00:00
2020-01-13 00:52:10 +00:00
// --------------------------------------------------------
// init -
// Module Init.
// --------------------------------------------------------
2020-01-12 08:10:01 +00:00
init: {
rts
}
2020-01-13 00:52:10 +00:00
// --------------------------------------------------------
// toDebug -
// Print debug info.
// --------------------------------------------------------
2020-01-12 08:10:01 +00:00
toDebug: {
2020-01-13 01:24:10 +00:00
ModuleToDebug(module_type, module_name, version)
rts
2020-01-12 08:10:01 +00:00
}
2019-11-21 06:18:23 +00:00
2020-01-13 00:52:10 +00:00
// --------------------------------------------------------
// 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
// --------------------------------------------------------
2019-11-06 04:31:17 +00:00
multiply: {
2019-11-21 06:18:23 +00:00
sei
pha
txa
2019-11-06 04:31:17 +00:00
pha
2019-11-21 06:18:23 +00:00
2020-01-13 01:24:10 +00:00
lda #$00
ldx #$08
2019-11-06 04:31:17 +00:00
clc
2020-01-20 07:32:37 +00:00
m0: bcc m1
2019-11-06 04:31:17 +00:00
clc
2020-01-13 01:24:10 +00:00
adc MemMap.MATH.factor2
m1: ror
ror MemMap.MATH.factor1
2019-11-06 04:31:17 +00:00
dex
2020-01-20 07:32:37 +00:00
bpl m0
2020-01-13 01:24:10 +00:00
ldx MemMap.MATH.factor1
2019-11-06 04:31:17 +00:00
2020-01-13 01:24:10 +00:00
sta MemMap.MATH.result
stx MemMap.MATH.result+1
2019-11-06 04:31:17 +00:00
pla
2019-11-21 06:18:23 +00:00
tax
pla
cli
2019-11-06 04:31:17 +00:00
rts
2019-11-23 02:50:25 +00:00
}
2020-01-12 08:10:01 +00:00
2020-01-13 00:52:10 +00:00
// ========================================================
// ////// DATA ////////////////////////////////////////////
// ========================================================
2020-01-12 08:10:01 +00:00
* = * "Math Lib Data"
2020-01-13 01:24:10 +00:00
module_type: .byte Module.TYPES.LIB
version: .byte 1, 1, 0
2020-01-13 00:52:10 +00:00
2020-01-12 08:10:01 +00:00
.encoding "screencode_mixed"
module_name:
2020-01-13 01:24:10 +00:00
.text "math"
.byte 0
2020-01-12 08:10:01 +00:00
2020-01-20 07:38:20 +00:00
#import "../hardware/mem_map.asm"
2020-01-12 08:10:01 +00:00