Question

I got a couple strokes of code here. And I need to know what will be the final value of AX. In code segment:

MOV AX, 0FF05H
DB 80H
DW E411H
DB 30H,C4H
XCHG AH,AL

And what are the commands dw and db doing (I know about declaring byte and word, but probably it's not the same here).

Was it helpful?

Solution

When you write a an assembler program the instructions are converted to byte sequences by the assembler. So when you know the opcode for an instruction, you can just as well declare bytes with that sequence.

Sometimes it can be useful if the assembler doesn't know the instruction mnemonic or if you want to use invalid opcodes which you know will work on your target but are not supported by the assembler.

Or you can use it to force a particular encoding of an instruction, because the assembler may choose a different one. Some assemblers have syntax to request a specific encoding, like NASM add eax, strict dword 1 will use an imm32 instead of imm8.

But without manual encoding, you don't get a choice between add r/m32, imm32 and add eax, imm32 (special short-form encoding with no ModRM byte)

OTHER TIPS

Yep, they work the same there. Declare byte and word values. Presumably the processor will hit and run those though since it's in a code stream. You need to look at the processor manual and map those values to the proper opcodes to find out what it's doing.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top