I have some problem understanding how the casting from double to integer happens in DLX. hopefully an assembly geek can help me out!
Having the data below:
.data 0
.global a
a: .double 3.14159265358979
.global x
x: .double 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16
.double 17,18,19,20,21,22,23,24,25,26,27
.global xtop
xtop: .double 28
The assembly DLX code follows:
ld f2,a
add r1,r0,xtop
; how does r1 get the value of 224 instead of 28???!!!
loop: ld f0,0(r1)
; load stall occurs here
multd f4,f0,f2
; 4 FP stalls
sd 0(r1),f4
sub r1,r1,#8
bnez r1,loop
nop ; branch delay slot
trap #0 ; terminate simulation
I know that double
is 64 bit divided in 8 bytes. A r
or general purpose register can only have integer/fixed points number of 32 bit in group of 4 bytes.
In binary, 28 is 11100
and 224 is 11100000
.
I suspect since both of them have 11100
in common, so I guess when trying to fit a double into a R
register, it takes the 11100000
and put it somehow in the 32bit register as 11100
...
really confusing stuff....any help would be appreciated!
r1
is loaded with the address ofxtop
. It's just an accident that it starts with11100
. There is no "double to integer cast" in that code. It's 224 because you have 28 doubles defined beforextop
, each taking 8 bytes (the pi followed by the numbers 1-27).