assembly - Push constant directly or Mov Eax and Push Eax -


there difference in push constant value directly call function, instead of mov value eax , push eax.

for example in c: getstdhandle(std_output_handle);

many compilers generate this:

;b8 f5 ff ff ff mov eax,-11  ;50 push eax  call getstdhandle 

and manually i'm using;

;6a f5 push -11  call getstdhandle 

there wrong pushing value directly instead load on eax , push eax ?

what have should ok, assuming code in 32 bit mode.

you explicitly specify 32 bit immediate, in case of visual studio (2005) assembler (ml.exe), used full 32 bit operand size instead of sign extended byte value:

; 68 f5 ff ff ff ;         push    dword ptr -11 

even specifying byte ptr visual studio's assembler (ml.exe) works:

; 6a f5 ;         push    byte ptr -11 

however, using word ptr results in 66 prefix , 16 bit push (esp subtracted 2 instead of 4):

; 66 68 f5 ff ;         push    word ptr -11 

in case 66 prefix changes operand size (the value pushed onto stack) 16 bits.


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -