I have a problem with assembly procedure called from VC++.
If I pass LPSTR to my ASM proc and then try to edit a byte in it with
mov al, BYTE PTR
inc al
mov BYTE PTR , al
if MyPointer points to "first byte" it just erases firt letter but if it points to any other byte in the string it causes error. How can I make this work? I would also like the same code to work with space allocated with GlobalAlloc.
If I pass LPSTR to my ASM proc and then try to edit a byte in it with
mov al, BYTE PTR
inc al
mov BYTE PTR , al
if MyPointer points to "first byte" it just erases firt letter but if it points to any other byte in the string it causes error. How can I make this work? I would also like the same code to work with space allocated with GlobalAlloc.
load the pointer and then modify the data:
mov eax, ; load address
inc BYTE PTR ; change data
If MyPointer contains the address of the string then you are just changing the pointer value, not the string itself.
mov eax, ; load address
inc BYTE PTR ; change data
If MyPointer contains the address of the string then you are just changing the pointer value, not the string itself.
Ok, thanks....
By the way, why does this thing work fine from "pure asm" ? If My pointer is address of some data from both .data block and allocated space??
By the way, why does this thing work fine from "pure asm" ? If My pointer is address of some data from both .data block and allocated space??
It doesn't. :grin:
How strange.... i wonder what in the world I did so this works to me ... i use it all the time. :) I must be schizophrenic or something. :)
SomeData db "Oh, happy day!",0,0
MyPointer dd offset SomeData
Bad Code:
mov al, BYTE PTR
inc al
mov BYTE PTR , al
...do you see why this doesn't work?
Good Code:
mov eax,MyPointer
inc BYTE PTR ; change O to P
MyPointer dd offset SomeData
Bad Code:
mov al, BYTE PTR
inc al
mov BYTE PTR , al
...do you see why this doesn't work?
Good Code:
mov eax,MyPointer
inc BYTE PTR ; change O to P
Does not this work?:
I think it should...
inc BYTE PTR MyPointer
I think it should...
Does not this work?:
inc BYTE PTR MyPointer
I think it should...
So, like this?:
inc BYTE PTR
That should increment it. I think the goal here is to increment the string. Does not this work?
inc BYTE PTR
That should increment it. I think the goal here is to increment the string. Does not this work?
Maybe I missunderstood the goal?
Surely, 'DWORD PTR' would be more logical.
What if the byte overflowed?
I don't know what Milos is trying to do? :rolleyes:
Surely, 'DWORD PTR' would be more logical.
What if the byte overflowed?
I don't know what Milos is trying to do? :rolleyes:
Yes, maybe.
The problem is that i always, when incrementing a value stored in memory, i use a simple inc DWORD PTR ValueMemoryAddress. In this case, as MyPointer points to the string, i thought that maybe a simple inc BYTE PTR should do the work. (or inc dword ptr
Just asking...
The problem is that i always, when incrementing a value stored in memory, i use a simple inc DWORD PTR ValueMemoryAddress. In this case, as MyPointer points to the string, i thought that maybe a simple inc BYTE PTR should do the work. (or inc dword ptr
Just asking...
I have put the questio wrong way...
if there is
.data
MyString db "WASSUP?!", 0
.code
lea ebx, MyString
mov al, BYTE PTR Should return me the first byte, shouldn't it?
I assume when passing address of this string to a function by ADDR it gives the same result if we loaded effective address of it.
While ago I coded a function that excepts address of a buffer passed with ADDR (or lea to a register first).
I want to link this function with my C++ program now and I thoght that LPSTR is data type I should use- I used a string as a buffer just for testing but it didnt work....
I hope my problem it's much clear now. What should I use?
if there is
.data
MyString db "WASSUP?!", 0
.code
lea ebx, MyString
mov al, BYTE PTR Should return me the first byte, shouldn't it?
I assume when passing address of this string to a function by ADDR it gives the same result if we loaded effective address of it.
While ago I coded a function that excepts address of a buffer passed with ADDR (or lea to a register first).
I want to link this function with my C++ program now and I thoght that LPSTR is data type I should use- I used a string as a buffer just for testing but it didnt work....
I hope my problem it's much clear now. What should I use?
So, like this?:
inc BYTE PTR
That should increment it. I think the goal here is to increment the string. Does not this work?
It does not work. BYTE PTR is a type cast, not an addressing mode. The x86 does not do data indirection via memory. You must load the address (pointer) into a register to affect the referenced memory.