cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with pointer

tech4
Associate II
Posted on July 25, 2003 at 08:05

Problem with pointer

9 REPLIES 9
tech4
Associate II
Posted on July 17, 2003 at 10:59

...

segment 'rom'

.data DC.W Hello

.Hello DC.B ''Hye'',0

...

.main

ld A,([data.w],X)

Error 54: Can't match Addressing mode

What is wrong, please ?

[ This message was edited by: Padb on 17-07-2003 14:32 ]
simonharrison9
Associate II
Posted on July 17, 2003 at 14:51

Hi

use LD A, (data,X)

The [xx.w] version refers to a 16 bit address location in zero space memory.

The programming manual available from the download section of this site covers this very well.

ensure there is no space between the , and the X on all instructions

regards,

Simon

simonharrison9
Associate II
Posted on July 17, 2003 at 14:56

Hi,

I just read it again. sorry......

declare it in RAM:

segment 'ram0'

.data ds.w Hello

segment 'rom'

.Hello DC.B ''Hye'',0

...

.main

ld A,([data.w],X)

You can then change the ram locations to point to different arrays/strings and scan through the string using X

Simon

tech4
Associate II
Posted on July 18, 2003 at 11:17

''constant.asm''

segment 'ram0'

WORDS

.data DS.W HELLO ;Pointeur sur Hello

segment 'rom'

.HELLO DC.B ''Hye'',0

''Constant.INC''

EXTERN data.w

EXTERN HELLO.w

''Myprogram.ASM''

#INCLUDE ''ST72F324.inc'' ; ST72F324 registers and memory mapping file

#INCLUDE ''constant.inc'' ; Définition des constantes

ld A,([data.w],X)

constant.asm(50): as1 : Fatal 97: DS.n length is extern/relative derived, must be absolute '.data DS.W HELLO

Please, what's the matter ???
sjo
Associate II
Posted on July 18, 2003 at 12:05

Hi there,

You are not setting up your pointer, try this

segment 'ram0'

.data DS.W 1

WORDS

segment 'rom'

.HELLO DC.B ''hello'',0

ld A, #HELLO.h

ld data, A

ld A, #HELLO.l

ld {data+1}, A ; setup pointer to our data

clr X

ld A, ([data.w],X) ; A holds first char of data

do you need tio use a pointer you could do:

clr X

ld A, (HELLO,X) ; without a pointer

Hope this helps

SJO
tech4
Associate II
Posted on July 25, 2003 at 06:02

WORDS

.pointer DS.W 1 ;

segment 'rom'

.HELLO DC.B ''Bonjour'',0

ld A,#HELLO.h

ld pointer,A

ld A,#HELLO.l

ld {pointer+1},A ; setup pointer to our data

clr X

ld A,([pointer.w],X) ; A holds first char of data

as1 : Error 54: Can't match Addressing mode ' ld A,([pointer.w],X)
simonharrison9
Associate II
Posted on July 25, 2003 at 06:38

Hi,

You need to do it this way:

WORDS

segment 'rom'

.HELLO DC.B ''Bonjour'',0

clr X

ld A,(HELLO,X) ; A holds first char of data

Simon

Anglia
sjo
Associate II
Posted on July 25, 2003 at 07:22

You have received that warning because you used WORDS rather than BYTES eg.

BYTES

.pointer DS.W 1 ;

WORDS

segment 'rom'

.HELLO DC.B ''Bonjour'',0

ld A,#HELLO.h

ld pointer,A

ld A,#HELLO.l

ld {pointer+1},A ; setup pointer to our data

clr X

ld A,([pointer.w],X) ; A holds first char of data

Regards

SJO
tech4
Associate II
Posted on July 25, 2003 at 08:05

You are a champion !!!