I’m trying to figure out whether the following piece of assembly code is invalid.
movb $0xF, (%bl)
Is it invalid? If so, why? Thanks.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You don’t say what processor.
blis a 8-bit register at least in x86 processors, but it cannot be used for addressing.Why is it invalid instruction? Well, the reason an assembly instruction is invalid is that there’s no such instruction for the given processor. There is no possible way to encode this instruction. In this case (assuming x86), using
blor any other 8-bit register neither for addressing has not been considered necessary. In 16-bit code only 16-bit registersbx,bp,sianddican be used for memory addressing. Wikipedia has a useful list of all possible addressing modes (please do note it’s using Intel syntax, your code is in AT&T syntax).Edit: In AT&T syntax the letter
binmovbdefines it deals with an 8-bit operand.To obtain more or less your goal (to use
blfor addressing), you could do one of these (these are in Intel YASM/NASM syntax, MASM-style assemblers including GNU.intel_syntax noprefixwantbyte ptr):For 16-bit code:
For 32-bit code:
For 64-bit code:
It’s rare that you ever want to store anything to a linear address from 0..255 (one byte). In 64-bit mode where segmentation is mostly disabled so the DS base is fixed at 0, this is definitely what the instruction is doing, but especially in 16-bit mode, the DS base could be non-zero.