2013-01-08 32 views
1

我需要添加两个浮点在8086大会8086:两个浮点[32位]增加,撒哈拉等

12.3 ---> 4144 CCCDh 
    (AX,BX) = (4144h, CCCDh) 

我需要添加任何数量的这种浮点样子:

(AX,BX) = (AX,BX) + 10h 

如果我这样做的答案是错误的。

 (AX,BX) + 10h == 4144 CCECh 

但23.3 didnt等于4144 CCECh

你能帮助我吗?我如何添加这两个数字?

+0

你真的有8086吗?如果是这样,一个8087呢?这会做更好的浮点。无论如何,请向我们展示一些您的代码。 –

+0

我是新手,我使用emu 8086进行编码。这是我的测验问题,我不知道如何添加这两个数字。 – user1958191

回答

0

还没有验证过这个(尤其是bp的偏移量),但它应该给一些观点。 它使用古代8087 floating point instruction set

所有操作发生在协处理器堆栈和/或内存之间。可以使用指令FILD mem从2的补码表示转换整数,并且在某些情况下,还有一个内置的附加指令,用于将整数(从存储器)添加到FP寄存器。

push bp 
mov bp, sp 
push bx 
push ax 
push word ptr 10 ; // decimal, not hex 
fld dword ptr [bp] ; load float (just pushed from bx,ax) 
fiadd word ptr [bp-4] ; add the integer in stack 
fst dword ptr [bp] ; store result 
pop ax    
pop ax    ; restore the high word of result 
pop bx    ; restore low word 
pop bp    ; restore frame pointer 
+0

谢谢你的观点我需要做更多的研究8086 – user1958191

0

不能像这样在IEEE-754浮点值(12.3f = 0x4144cccd)上添加整数(10)。您需要以IEEE-754格式(10.0f = 0x41200000)表示10,然后使用浮点加法指令。

0x4144cccd  12.3 
+ 0x41200000 + 10.0 
    ----------  ---- 
    0x41B26666  22.3 
+0

谢谢,但我如何给这个值在8086注册可以帮助吗? – user1958191

+0

如果它真的是一个古老的8086,那么你需要一个8087协处理器或一个软件FPU仿真。无论是那个,还是你必须自己编写一些浮点例程。 –

+0

okey非常感谢你 – user1958191