Ian Collins said:
On 05/27/11 11:15 AM, Paul wrote:
On 05/27/11 08:10 AM, Paul wrote:
Man you really don't have a clue, do you? I'll ask again, How much
x86
assembly programming have you actually done?
It doesn't matter how much I claim to have done or how much you
claim to
have done. The fact of the matter is, apparently I know what a
pointer
is
and you don't.
I'll take that as "none".
A variable whose value is an address(or an offset) to another memory
location is a pointer in assembly language.
The *number* -20 isn't a variable any more than arr in "#define arr
20"
is.
Correct -20 is not a variable , it is the value of the variable.
It is the value of a constant. By your definition, if I write
#define arr -20
arr is a variable.
_arr$ = -20 ; size = 20
is the MASM equivalent of
#define arr = -20 // is arr a pointer?
It is declared in the text segment, it is not an offset into the text
segment.
_arr$ is a variable that stores the value -20.
No, for the last time it is a constant. Please study a topic before
posting about it. From the link I posted earlier:
"A manifest constant is a symbol name that represents some fixed
quantity during the assembly process. That is it is a symbolic name
that represents some value. Equates are the mechanism MASM uses to
declare symbolic constants."
This is now way off topic. I suggest you find an assembly programming
group and see how far you get there.
Its you that brought it up. And now you seem to be ruinning away from
the argument because you are maybe starting to realise that _arr$ is a
pointer.
Look at the following code:
int main(){
int arr[3]={0};
int* px= arr;
px[1] = 7;
}
; Listing generated by Microsoft (R) Optimizing Compiler Version
14.00.50727.762
TITLE C:\cpp\public.cpp
.686P
.XMM
include listing.inc
.model flat
INCLUDELIB LIBCMT
INCLUDELIB OLDNAMES
PUBLIC _main
; Function compile flags: /Odtp
_TEXT SEGMENT
_px$ = -16 ; size = 4
_arr$ = -12 ; size = 12
_main PROC
; File c:\cpp\public.cpp
; Line 5
push ebp
mov ebp, esp
sub esp, 16 ; 00000010H
; Line 6
mov DWORD PTR _arr$[ebp], 0
xor eax, eax
mov DWORD PTR _arr$[ebp+4], eax
mov DWORD PTR _arr$[ebp+8], eax
; Line 7
lea ecx, DWORD PTR _arr$[ebp]
mov DWORD PTR _px$[ebp], ecx
; Line 8
mov edx, DWORD PTR _px$[ebp]
mov DWORD PTR [edx+4], 7
; Line 9
xor eax, eax
mov esp, ebp
pop ebp
ret 0
_main ENDP
_TEXT ENDS
END
Line 5-6 Creates a stack frame similar to below. It preserves ebp on the
stack, then assgins the esp value to ebp and then decrements esp by 16
bytes.
Line 6-7 Initialises the 3 integer objects , of the array, to 0.
Line 7-8 Stores the address of the first element at the location _px$
points to.
Line 8-9 Moves the literal value of 7 into the 2nd element of the array.
00001C [-------------]
000018 [--orig ebp---]<- orig esp
000014 [------0------] <-ebp
000010 [------7------]
00000C [------0------]
000008 [---00000C---] <- esp
000004 [-------------]
000000 [-------------]
After that ebp is popped and esp is back to its original value.
Face the facts about what a pointer is in assembly programming.
If you still do not accept these facts then I urge you to refer to the
link I posted about pointer data types by Randy Hyde.