Simba K
Simba K

Reputation: 9

'byte ptr' (Assembly) Return type?

Experienced coder here with no assembly experience, have a problem as follows:

At the four bytes from memory address 0x10000000 onwards, I have the four-byte value X (e.g. 0x10203040), and at the byte from the memory address (X + 40) (e.g. 0x10203068), I have the value '0xAB'. I want to perform an operation on this byte (e.g. 'not').

How is this syntactically done in assembly? I've done a lot of Googling for the compile errors I'm getting. What I have currently is something along the lines of (supposing var1 = 0x10000000):

not byte ptr[dword ptr[var1] + 12]

I've been playing around with this for two hours trying various combinations but the whole thing doesn't want to compile with any kind of hackery I can come up with. I've tried using an intermediary variable too, but my IDE took exception to the 'dd' keyword.

Be gentle - zero assembly experience here.

Upvotes: 1

Views: 388

Answers (1)

Ross Ridge
Ross Ridge

Reputation: 39591

You can't do this in a a single instruction. The x86 instruction set only supports certain addressing modes, and the memory indirect addressing mode you're trying to use isn't one of them.

You'd have to do something like the following:

mov esi, [var1]
not byte ptr [esi + 12]

Upvotes: 1

Related Questions