Keil c51 interprets &Array as Array. Is that normal?
- From: "Bill Davy" <Bill@xxxxxxxxxxxxxxx>
- Date: Thu, 10 Apr 2008 14:59:03 +0100
If I compile:
void Foo(void)
{
{ char Array[10]; char *p; p = &Array; }// Silly
{ char Array[10]; char *p; p = Array; } // Better
{ char Array[10]; char *p; p = &Array[0]; }// Some find this clearer
}
I get:
; .\Foo.SRC generated from: Foo.c
; COMPILER INVOKED BY:
; C:\Keil\C51\BIN\C51.EXE Foo.c LARGE OMF2 BROWSE
INCDIR(H:\Husky\HostPC\V1\) DEBUG TABS(3) SRC(.\Foo.SRC)
NAME FOO
?PR?Foo?FOO SEGMENT CODE
?XD?Foo?FOO SEGMENT XDATA OVERLAYABLE
PUBLIC Foo
RSEG ?XD?Foo?FOO
?Foo?BYTE:
Array?040: DS 10
ORG 10
p?041: DS 3
ORG 0
Array?042: DS 10
ORG 10
p?043: DS 3
ORG 0
Array?044: DS 10
ORG 10
p?045: DS 3
; void Foo(void)
RSEG ?PR?Foo?FOO
Foo:
USING 0
; SOURCE LINE # 1
; {
; SOURCE LINE # 2
; { char Array[10]; char *p; p = &Array; }// Silly
; SOURCE LINE # 3
MOV DPTR,#p?041
MOV A,#01H
MOVX @DPTR,A
INC DPTR
MOV A,#HIGH (Array?040)
MOVX @DPTR,A
INC DPTR
MOV A,#LOW (Array?040)
MOVX @DPTR,A
; { char Array[10]; char *p; p = Array; } // Better
; SOURCE LINE # 4
MOV R1,A
MOV DPTR,#p?043
MOV A,#01H
MOVX @DPTR,A
INC DPTR
MOV A,#HIGH (Array?042)
MOVX @DPTR,A
INC DPTR
MOV A,R1
MOVX @DPTR,A
; { char Array[10]; char *p; p = &Array[0]; }// Some find this clearer
; SOURCE LINE # 5
MOV DPTR,#p?045
MOV A,#01H
MOVX @DPTR,A
INC DPTR
MOV A,#HIGH (Array?044)
MOVX @DPTR,A
INC DPTR
MOV A,R1
MOVX @DPTR,A
; } ; SOURCE LINE # 6
RET
; END OF Foo
END
-------------------
IDE-Version:
µVision3 V3.60
Copyright (c) Keil Elektronik GmbH / Keil Software, Inc. 1995 - 2008
Tool Version Numbers:
Toolchain: PK51 Prof. Developers Kit Version: 8.12
Toolchain Path: C:\Keil\C51\BIN\
C Compiler: C51.Exe V8.12
-----------------
Is this normal?
MSVC 6 issues a warning (C4047).
.
- Follow-Ups:
- Re: Keil c51 interprets &Array as Array. Is that normal?
- From: Jack Klein
- Re: Keil c51 interprets &Array as Array. Is that normal?
- From: Andrey Tarasevich
- Re: Keil c51 interprets &Array as Array. Is that normal?
- From: Robert Adsett
- Re: Keil c51 interprets &Array as Array. Is that normal?
- From: Hans-Bernhard Bröker
- Re: Keil c51 interprets &Array as Array. Is that normal?
- From: Tim Wescott
- Re: Keil c51 interprets &Array as Array. Is that normal?
- Prev by Date: Grow your professional network
- Next by Date: non-cacheable and non-bufferable
- Previous by thread: Grow your professional network
- Next by thread: Re: Keil c51 interprets &Array as Array. Is that normal?
- Index(es):
Relevant Pages
|