trillek-team / trillek-computer

Trillek Virtual Computer specs
http://trillek-team.github.io/trillek-computer/
Other
51 stars 8 forks source link

Provide a 64 bit division instruction #33

Closed catageek closed 9 years ago

catageek commented 9 years ago

64 bit multiplication already exists, but we can't divide the result obtained.

The proposal is to define a division instruction that takes 3 registers in input and performs: Rd = Rd:Rs / Rn Y = Rd:Rs % Rn

Where Rd:Rs is the 64 bit value, using Rd for the upper 32 bits and Rs for the lower 32 bits.

Zardoz89 commented 9 years ago

I'm seeing that on x86 the division instruction accepts the same input wide as the output wide of multiplication. In other words, on 32 bit x86 :

I see ok the new two instructions (signed version), even we could remove/replace the old division for this way, and make it symmetrical.

WDIV (Wide DIVision) and SWDIV (Signed Wide DIVision) ???

milesrout commented 9 years ago

You can do 64-bit multiplication with 32-bit multiplication, and 64-bit division with 32-bit division, if I'm not mistaken.

Zardoz89 commented 9 years ago

Funny... I take a look of how does this ARM :

Zardoz89 commented 9 years ago

Look : http://www.phatcode.net/res/260/files/html/AdvancedArithmetica2.html

Seeing that, I think that isn't necessary a wide division. Also, think that 64 bit output would be rarely used on the multiplication. Is there because a 32 bit multiplication would generate 64 bit wide output very easy.