在 DLX 处理器中从双精度转换为整数

Casting from Double to Integer in DLX Processor

我在理解 DLX 中如何从双精度转换为整数时遇到一些问题。希望组装极客可以帮助我!

有以下数据:

    .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 

汇编DLX代码如下:

    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 

我知道double是64位分成8个字节。一个r或通用寄存器只能有integer/fixed个4字节组中32位的点数。

在二进制中,28是11100,224是11100000

我怀疑因为它们都有 11100 的共同点,所以我想当试图将双精度数放入 R 寄存器时,它需要 11100000 并以某种方式放置它在 32 位寄存器中为 11100...

真是令人困惑的东西....任何帮助将不胜感激!

r1加载了xtop的地址。 11100开头纯属意外。该代码中没有 "double to integer cast" 。它是 224,因为您在 xtop 之前定义了 28 个双精度数,每个占用 8 个字节(圆周率后跟数字 1-27)。