Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Multiplication using fractions or decimal points on HCS12?

plindplind Member Posts: 1
Hello there,

I'm just wondering if anyone could help me figure out how to multiply by decimal points. For instance, let's say I want to multiply 100 by 0.165. Here is what I thought I could do:


jsr capture ; Capture data
jsr astd ; Convert captured ASCII data to hex
; Data stored in "result" variable

; Multiply result by 0.165 (Moon's constant)
ldd result
ldy #!165
emul ; emul works as such (D) x (Y) => (Y:D)
ldy #$0
ldx #!1000
ediv ; ediv works as such (Y:D) / (X) => (Y)
; remainder is sent to (D)
tfr y,d
std result
jsr print

So basically capture takes in values from a scale and stores them. astd uses those values and combines them into a hex number and stores that number in the variable result, which has been declared as so:

result rmb 2

Then basically I multiply that number by 165 and then divide it by 1000. I figured this would work, but I am not getting any correct data. Any ideas on how to do this would be greatly appreciated.

Thanks
Sign In or Register to comment.