Assembly x86 – “leave” Instruction

LEAVE is the counterpart to ENTER. The ENTER instruction sets up a stack frame by first pushing EBP onto the stack and then copies ESP into EBP, so LEAVE has to do the opposite, i.e. copy EBP to ESP and then restore the old EBP from the stack. See the section named PROCEDURE CALLS FOR BLOCK-STRUCTURED LANGUAGES in Intel’s Software Developer’s Manual Vol 1 if you want to read more about how ENTER and LEAVE work. enter n,0 is exactly equivalent … Read more

Which variable size to use (db, dw, dd) with x86 assembly?

Quick review, DB – Define Byte. 8 bits DW – Define Word. Generally 2 bytes on a typical x86 32-bit system DD – Define double word. Generally 4 bytes on a typical x86 32-bit system From x86 assembly tutorial, The pop instruction removes the 4-byte data element from the top of the hardware-supported stack into the specified operand (i.e. register or … Read more

Assembly addq clarification

The addq a,b instruction adds the contents of a to b. So if rcx = 0x1, rax = 0x100 and we have 0xff at address 0x100, then add %rcx,(%rax) adds 0x1 in rcx to 0xff at address 0x100, yielding 0x100 at address 0x100 as the worksheet correctly indicates. Your intuition would be correct if the instruction was movq instead of addq as movq just overwrites a memory location or register instead of adding to it.

When and why do we sign extend and use cdq with mul/div?

Use cdq / idiv for signed 32-bit / 32-bit => 32 bit division,xor edx,edx / div for unsigned. With the dividend in EAX to start with, and the divisor specified as an operand to DIV or IDIV. If you zero EDX/RDX instead of sign-extending into EDX:EAX before idiv, you can get a large positive result for -5 / 2, for example. Using the “full … Read more

Greater than, less than equal, greater than equal in MIPS

I’m assuming that the pseudocode executes sequentially, so an earlier condition being true means you go there and never reach the later if statements. This makes the last branch guaranteed taken if it’s reached at all, so it doesn’t even need to be conditional. (Also assuming that this is a MIPS without a branch-delay slot.) … Read more

Difference between “move” and “li” in MIPS assembly language

The move instruction copies a value from one register to another. The li instruction loads a specific numeric value into that register. For the specific case of zero, you can use either the constant zero or the zero register to get that: There’s no register that generates a value other than zero, though, so you’d have to use li if you wanted some … Read more

MIPS Assembly – lui $t0, 4097?

4097 = 1001 hex so, the first instruction puts 0x10010000 into register t0. lui is “load upper immediate”, with “upper” meaning the upper 16 bits, and “immediate” meaning that you are giving it a literal value (4097). 4097 as an “upper” value becomes 0x10010000. ori is “or immediate”, with 8 being the immediate value, so … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)