Hello,

I am very new to the 68HC12. I am in a class where we use the 68HC12 along with
an IDE from P&E Microcomputer Systems, Inc. I have only written some basic
if-else and while loops at this point. The latest problem I've had is using the
instruction FDIV. The code I have so far is:

LDD #$04

LDX #$0A

FDIV

STX $0800 ; the answer I get in acc. X is 6666

I know this is the correct answer since 2^-2 + 2^-3 + 2^-6 + 2^-7 + 2^-10 +
2^-11 + 2^-14 + 2^-15 = .4

I am just wondering how I can multiply numbers by the .4 now? How can I
represent .4 in a register?

My goal is to use the number generated by the FDIV, and set it up in a loop to
add to itself 10 times. Each time multiplying the result to the slope of a
line...

something like:

.4(250) = 100 ----> store in memory $5000 and $6000

.8(250) = 200 ----> store in memory $5001 and $6001

1.2(250) = 300 ----> store in memory $5002 and $6002

1.6(250) = 400 ----> store in memory $5003 and $6003

and so on...

Any help would be great. Thanks!

# Instruction Set help

Started by ●February 12, 2010

Posted by ●February 13, 2010

"jason_terhune" wrote:

> Hello,

> I am very new to the 68HC12. I am in a class where we use the 68HC12 along

> with an IDE from P&E Microcomputer Systems, Inc. I have only written some

> basic if-else and while loops at this point. The latest problem I've had

> is using the instruction FDIV. The code I have so far is:

>

> LDD #$04

> LDX #$0A

> FDIV

> STX $0800 ; the answer I get in acc. X is 6666

>

> I know this is the correct answer since 2^-2 + 2^-3 + 2^-6 + 2^-7 + 2^-10

> + 2^-11 + 2^-14 + 2^-15 = .4

FDIV works like this D*$10000 / X . $4000000/$A00=$6666

>

> I am just wondering how I can multiply numbers by the .4 now? How can I

> represent .4 in a register?

LDD #multiplier

LDY #$6666

EMUL ;; 32bit product in Y:D

;; to divide by $10000 just take upper word of

the product:

STY result

Don't know if I understand your question about representing .4 in register.

If you want it to be something like result of 4 FDIV 10, then 4*$10000 / 10

>

> My goal is to use the number generated by the FDIV, and set it up in a

> loop to add to itself 10 times. Each time multiplying the result to the

> slope of a line...

This is also not fully clear.

>

> something like:

> .4(250) = 100 ----> store in memory $5000 and $6000

> .8(250) = 200 ----> store in memory $5001 and $6001

> 1.2(250) = 300 ----> store in memory $5002 and $6002

> 1.6(250) = 400 ----> store in memory $5003 and $6003

> and so on...

>

> Any help would be great. Thanks!

Edward

> Hello,

> I am very new to the 68HC12. I am in a class where we use the 68HC12 along

> with an IDE from P&E Microcomputer Systems, Inc. I have only written some

> basic if-else and while loops at this point. The latest problem I've had

> is using the instruction FDIV. The code I have so far is:

>

> LDD #$04

> LDX #$0A

> FDIV

> STX $0800 ; the answer I get in acc. X is 6666

>

> I know this is the correct answer since 2^-2 + 2^-3 + 2^-6 + 2^-7 + 2^-10

> + 2^-11 + 2^-14 + 2^-15 = .4

FDIV works like this D*$10000 / X . $4000000/$A00=$6666

>

> I am just wondering how I can multiply numbers by the .4 now? How can I

> represent .4 in a register?

LDD #multiplier

LDY #$6666

EMUL ;; 32bit product in Y:D

;; to divide by $10000 just take upper word of

the product:

STY result

Don't know if I understand your question about representing .4 in register.

If you want it to be something like result of 4 FDIV 10, then 4*$10000 / 10

>

> My goal is to use the number generated by the FDIV, and set it up in a

> loop to add to itself 10 times. Each time multiplying the result to the

> slope of a line...

This is also not fully clear.

>

> something like:

> .4(250) = 100 ----> store in memory $5000 and $6000

> .8(250) = 200 ----> store in memory $5001 and $6001

> 1.2(250) = 300 ----> store in memory $5002 and $6002

> 1.6(250) = 400 ----> store in memory $5003 and $6003

> and so on...

>

> Any help would be great. Thanks!

Edward