This might seem like a simple question, but I'm starting to get a little nutty always doing this:


mov ebx,[edx.SSTRING.tus]
add ebx, 4
mov [edx.SSTRING.tus],ebx


There is no add to memory(as far as I know). I messed with lea, but that just advances the address, not the value.

Or is this as easy as it gets???
Posted on 2002-07-25 11:34:43 by ThoughtCriminal
What is wrong with?:

add ,4

You can add an immediate or register value to a memory location.
Posted on 2002-07-25 12:14:40 by bitRAKE
Most instructions will work in every case except with two memory operands.
Posted on 2002-07-25 12:20:31 by comrade
Yeah lea just calculates a relative address but why can't you do it directly?



_st1 struct
_val1 dd 5
_val2 dd 6
_st1 ends

st1 _st1 <5, 6>

mov edx, offset st1
add [edx._st1._val1], 2
add [edx._st1._val2], 3
Posted on 2002-07-25 12:26:10 by grv575
Yup, I'm getting a little nutty.

add ,4

I thought I tried this and got an invalid operand error, or something....

I'll try again.
Posted on 2002-07-25 21:08:26 by ThoughtCriminal
Since you have an immediate operand, MASM doesn't whether to add a byte, word or a dword. That is why you have to manually specify the type.
add	dword ptr [edx.SSTRING.tus], 4	; adds a dword

add word ptr [edx.SSTRING.tus], 4 ; adds a word
add byte ptr [edx.SSTRING.tus], 4 ; adds a byte
Posted on 2002-07-25 22:47:29 by comrade