Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what does movsbl instruction do? [duplicate]

Tags:

I have searched on the net, but i couldn't find a clear example to understand what does this instruction do. So, if someone can give an example about this, it will be very helpful to me.

like image 504
sarslanhan Avatar asked Oct 22 '11 16:10

sarslanhan


People also ask

What does MOVSbl do?

Assuming you are talking about x86, the MOVSBL instruction extends a byte (8 bits) representing a signed number to 32-bit signed number. The remaining 24 bits are zeros or ones depending on the sign so that the two's complement value remains.

What does Movzbl do in assembly?

For MOVZBL, the low 8 bits of the destination are replaced by the source operand. the top 24 bits are set to 0. The source operand is unaffected. For MOVZBW, the low 16 bits of the destination are replaced by the source operand.

How does CMP work Assembly?

The CMP instruction compares two operands. It is generally used in conditional execution. This instruction basically subtracts one operand from the other for comparing whether the operands are equal or not. It does not disturb the destination or source operands.

What is the AL register?

The least significant byte of AX can be used as a single 8-bit register called AL, while the most significant byte of AX can be used as a single 8-bit register called AH. These names refer to the same physical register. When a two-byte quantity is placed into DX, the update affects the value of DH, DL, and EDX.

What is the movs instruction used for?

The MOVS instruction is used to copy a data item (byte, word or doubleword) from the source string to the destination string.

What is the difference between MOVSB and MOVSW instruction?

The MOVSB (move string, byte) instruction fetches the byte at address SI, stores it at address DI and then increments or decrements the SI and DI registers by one. The MOVSW (move string, word) instruction fetches the word at address SI, stores it at address DI and then increments or decrements SI and DI by two.

How many zeros are there in movsbl instruction?

Assuming you are talking about x86, the MOVSBL instruction extends a byte (8 bits) representing a signed number to 32-bit signed number. The remaining 24 bits are zeros or ones depending on the sign so that the two's complement value remains. Meaning, if you had a negative number, the upper 24 bits will be 1s, otherwise they will be zeroes.

What is Assembly assembly movs instruction?

Assembly - MOVS Instruction. The MOVS instruction is used to copy a data item (byte, word or doubleword) from the source string to the destination string.


1 Answers

Move with sign extend from byte to longword. In Intel syntax, the mnemonic of this instruction is MOVSX.

A C compiler may use this instruction when a variable of type int8_t needs to be converted to int, which happens automatically on arithmetic and a few other operations (integer promotion).

Because this instruction writes to all 32 (or 64) bits of the destination register, it avoids performance penalties that may result from writing to only the low 8 (or 16) bits of a register. A similar set of instructions allows extending with zero bits (MOVZX in Intel syntax, MOVZst in AT&T syntax (from size s to size t)).

like image 83
jilles Avatar answered Dec 10 '22 04:12

jilles