icedland / iced

Blazing fast and correct x86/x64 disassembler, assembler, decoder, encoder for Rust, .NET, Java, Python, Lua
MIT License
2.83k stars 232 forks source link

Register BPL is not between AL and BH (inclusive) #559

Closed Symbai closed 2 months ago

Symbai commented 2 months ago

I get an exception Register BPL is not between AL and BH (inclusive) when I try to assemble mov bpl,27. It works fine using a different assembler. (Same with SPL, SIL and DIL). Is this a bug or am I doing something wrong?

var assembler = new Iced.Intel.Assembler(32);
assembler.mov(bpl, 0x27);
var ms = new MemoryStream();
var codeWriter = new Iced.Intel.StreamCodeWriter(ms);
assembler.Assemble(codeWriter, (ulong)0x40000);
Console.WriteLine(BitConverter.ToString(ms.ToArray()));

image

wtfsck commented 2 months ago

You need to change bitness to 64, it's currently 32.

Symbai commented 2 months ago

Isnt bpl the 8bit register of EBP? Why would that need 64bit? The other assembler I've used is also 32bit. You are right, but I dunno why.

wtfsck commented 2 months ago

In 16 and 32-bit modes you can only access 8-bit regs: AL, CL, DL, BL, AH, CH, DH, BH.