2014-03-06 45 views
8

我期待通過英特爾指令集手工,它看起來像有2種不同形式的ADC將匹配/編碼ADC EAX, ECX如下:編碼ADC EAX,ECX - 兩種不同的方式來編碼? (拱86)

ADC r/m32, r32 (11 /r , which encodes to 11C8) 

ADC r32, r/m32 (13 /r, which encodes to 13C1) 

我的問題是(給予我正確地做數學),是11C813C1等同?彙編程序在選擇一種編碼時會考慮哪些因素?問題是從實現一個彙編程序的角度來看,所以這個問題總的來說並不是關於這個特定的假設性指令。

如果它是一個漫長的回答,請點我在正確的方向我在Google上搜尋它失敗的嘗試。

+2

是的,他們是等價的。 –

回答

11

這是指令編碼的redundancy。任何在指令中使用多個參數的體系結構都有這個。

想想RISC架構有add rx, ry, rz將ry和rz的總和分配到rx中,那麼您可以編碼add rx, ry, rzadd rx, rz, ry,它們都是等效的。

在86我們(通常)僅具有2爲每個指令參數,但可以選擇它們之間的方向,因爲你可以存儲或從存儲器中讀取。如果你不使用的內存,那麼你可以選擇2個寄存器之間的方向,所以有2種編碼方式

您可以用它來找出一些編譯器/彙編。對於某些彙編程序,您可以選擇使用哪種編碼。在GAS可以使用.s suffix,迫使它發射替代編碼

10 de adcb %bl,%dh 
12 f3 adcb.s %bl,%dh 
+0

一些表格參考http://pdos.csail.mit.edu/6.828/2005/readings/i386/ADC.htm,有時你必須使用一些小花招/ s,而使用谷歌https://www.google.com /#q = allintext:+ ADC + EAX + R32 – user2485710

+1

氣體具有用於編碼覆蓋,如'{負載}'前綴用Ar /米源的編碼新的語法。 https://sourceware.org/binutils/docs/as/i386_002dMnemonics.html。或者是一個'{disp32}'前綴來強制一個更長的尋址模式。 –

2

ADC的二進制enconding是(assumming REG-REG操作):當指令用於具有兩個

000100dw Mod Reg Ind 
d= destination, 1 if Reg is the destination register, 0 if not 
w= word operation, =0 if byte operation, =1 32 bit operation 
Reg= is the register to use as a destination Register 
Mod/Ind fields are used to specify the other Register involved, Mod=11, Ind= the other register 

像ADC EAX寄存器ECX有兩種可能的編碼:涉及REG-REG或REG-MEM的操作數

a) EAX= EAX + ECX, COP= 13h, the "normal" case 
00010011 11|000|001 where d=1 meaning 000 (EAX) is the destination register and 001 (ECX) is the other register. 

b) EAX= ECX + EAX, COP= 11h, 
00010001 11|001|000 d=0 meaning 001 (ECX) is not the destination register so 000(EAX) must be the destination register. 

的d位參與了幾乎兩個操作數的指令。

相關問題