- #1
EvLer
- 458
- 0
I need to read-in two 16-bit numbers from memory and divide one by the other. Well, i think i need to use FDIV instruction which would divide what's in D-register by what's in X-register, but i am stumped when it comes loading the data. Here's code we were given (commented is my solution)
what bothers me is that rmb (reserve memory byte) is 4 which makes sense for 2 16-bit numbers but how do i load 2 separate 16-bit registers, so that first 2-bytes are loaded into D and second 2-bytes go into X?
D register will load 16 bits fine, but wouldn't X be loaded with the same 2 bytes? Technically i can figure out the address and load X with that address, but is there a "cleaner" way to do it?
thanks.
Code:
org 0800h
;ldd ops
;ldx ops (?)
;fdiv
;std remain
;stx quot
stop
ops rmb 4
quot rmb 2
remain rmb 2
D register will load 16 bits fine, but wouldn't X be loaded with the same 2 bytes? Technically i can figure out the address and load X with that address, but is there a "cleaner" way to do it?
thanks.