cancel
Showing results for 
Search instead for 
Did you mean: 

indirect address help

engenharia23
Associate II
Posted on July 07, 2009 at 12:59

indirect address help

4 REPLIES 4
engenharia23
Associate II
Posted on May 17, 2011 at 15:03

Hi all!

My name is Fabio Fortes, I have found very difficult to write a code in assembler for stm8s105k4.

I am working with the IDE STVD, and would appreciate some help, I believe, simple ...

I am working on a routine lcd, and must have access to so indirectly, using the x register, however, I have not managed to write the code.

could someone help me?

grateful,

fabio

:-?

fggnrc
Associate II
Posted on May 17, 2011 at 15:03

Hello Fabio.

LCD control may be an easy or a difficult task according to the driving method.

On this site there are some examples which show how a microcontroller can generate the waveforms to directly drive the electrodes (a difficult task).

I however suppose that you have to accomplish an easier task, i.e. to drive a LCD controller such as a HD44780.

If such is the case, you have to:

- link the microcontroller with the LCD controller;

- send the right command sequence.

If you need some help, please, give more details since they make the difference when it's time to write any assembler code.

Regards

EtaPhi

engenharia23
Associate II
Posted on May 17, 2011 at 15:03

Hello, thank you very much for your attention!

I already work in assembler codes with st7foxk1 and lcd.

I usualy reserve 32 bytes of ram to data lcd.

for to send data to ram, with st7, I use:

;*************************************************************

;SUB-ROTINE to clean the LCD

clean:

LD A,#020H ; set a ...

LD RPOS,A ; ... counter

LD X,#RLCD ; first address of lcd ram in X

LD A,#020H ; acc = ' '

VOLT2:

LD (X),A ; (X) = acc

INC X ;

DEC RPOS ; dec counter

JRNE VOLT2 ;

RET ; RETURN

;*************************************************************

this code working very well with st7foxk1, but,

when I try to load X in stm8s, I receive the message:

Error 54: Can't match Addressing mode ' LD X,#RLCD'

So, I would like to know,

what I need to do to work with indirect address in stm8s.

I'm trying to work with stm8s105k4.

Grateful,

Fábio Fortes, Caxias do Sul, Rio Grande do Sul, Brazil.

fggnrc
Associate II
Posted on May 17, 2011 at 15:03

Fabio,

I had your same error when I moved from the ST7 to the STM8S core...

The X register is now 16 bits wide, so the instruction to load the X register with the RLCD constant is

LDW X,#RLCD

As a rule of thumb, all instructions that involve X or Y have now to be followed by a ''W''.

8 bit data can be still exchanged between X and A, but you have to say which half is involved.

This means that you have to write

LD A,XL

to transfer the lower byte of X to A.

The STM8S core and its 16 bit index registers are a big evolution of the ST7 assembler programming model: what you did (or you was forced to do) is now not necessary because there are new efficient ways to achieve the same result.

For instance, you can set a variable initial value with:

MOV RLCD,#$1E

The corresponding ST7 assembler instructions are:

LD A,#$1E

LD RLCD,A

but they need 6 (if the destination is in the zero page) or 7 clock cycles instead of one clock cycle!

Regards,

EtaPhi