Arrays in S08 assembly language

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Arrays in S08 assembly language

3,425 Views
SILKS
Contributor I
Everyone,
 
I am having trouble creating an array in S08 code. Looking for a little help here, this is a snippet of my code;
 
; Wail table. Three bytes per block consisting of adjustment value, interrupt
; divider count, and adjustment count.
; Table is called wailtabl, error occurrs during compile. Using code warrior 6.2 with latest service packs.
; This code used to work when using the HC05C8A, now I am porting over to S08.
; error is; A1055 Error in Expression
 
wailtabl equ   
; Wail up
         fcb     1                   ;adjust value, first interval
         fcb     2                   ;interrupt divider
         fcb     36                  ;adjustment count
         fcb     1                   ;second interval
         fcb     3
         fcb     29
         fcb     2                   ;third interval ETC.
 
 
 
Labels (1)
0 Kudos
12 Replies

1,005 Views
SILKS
Contributor I
Thank you all for your help, Peg, moving the FCB into the whitespace area near the label worked. I really appreciate your help.
0 Kudos

1,005 Views
bigmac
Specialist III
Hello Randall,

I tried some code similar to your original code within an absolute assembly CW project, and once the spurious EQU directive was removed, it assembled without error, and gave the expected result.

For CW, it appears that a label on a separate line is quite OK, and terminating the label with a colon is optional.  Intervening comment lines between the label and the first FCB directive did not affect assembly, and use of the FCB directive did not cause a problem. The directive may be followed by a single value, or multiple values separated by commas.

So I don't quite know what your original problem was (apart from the spurious EQU).  Is it possible that the label originally did not start in the first column - this would cause an error condition.

If your project uses relocatable assembly (the default), and more than one .ASM file is involved, you will need to use XDEF and XREF directives for labels that are to be visible in more than one file.

Regards,
Mac

0 Kudos

1,005 Views
SILKS
Contributor I
Mac,

Thanks for the input, the FCB statements began to work when i moved them up a line closer to the label.

Everything else you said is true as well and I regard it as expert advice, thank you.
0 Kudos

1,005 Views
SILKS
Contributor I
Peg,
 
I used the EZMCU compiler and assembler. Once I drop the EQU nothing assignes to the memory variable wailtabl.
 
0 Kudos

1,005 Views
peg
Senior Contributor IV
Hi,

Sorry you need to drop the comment on the next line (;wail up) and move the(fcb 1  ;xxxxxxx) up onto the same line as the label (wailtabl).

Possibly don't have to move this line up but let's just do it for now.

0 Kudos

1,005 Views
bigmac
Specialist III
Hello Randall,

It would appear that the FCB directive is not valid for CW assembler.  Substitute the directive DC.B instead, assuming that you intend the data to be constant and reside in flash.

waitable:
   DC.B  1, 2, 36 ; First interval
   DC.B  1, 3, 29 ; Second interval
   ...

Alternatively, the coding might be a little simpler to treat the data as three separate tables, one for each of the parameters.  This would avoid the need to increment the index value by 3, or multiply by 3, to fetch the data associated with the nth interval.  If adapting HC05 code, don't forget to clear the H-register prior to using indexed instructions such as:

   LDA (waitable+2),x  ; where x = 0, 3, 6 ...

Regards,
Mac



Message Edited by bigmac on 2009-02-03 10:49 PM
0 Kudos

1,005 Views
peg
Senior Contributor IV
Hi Mac,

I am pretty sure that although DC.B is the "native" form of the directive for Codewarrior it will still accept the more common FCB and do the same thing. The manual seems to back this up.

0 Kudos

1,005 Views
bigmac
Specialist III
Hello Peg,

I did quickly check the assembler manual (for an earlier CW version), but could not find FCB directive listed in the summary of directives.  The alternative DCB was specifically listed.  Where abouts did you find it documented?

Regards,
Mac

0 Kudos

1,005 Views
peg
Senior Contributor IV
Hi Mac,

I only have CW6.2 at the moment. In Assembler_HC08.chm under the command DC it list the "synonyms" of the various forms of DC, one of which is FCB = DC.B

0 Kudos

1,005 Views
SILKS
Contributor I
Thanks PEG,
 
Umm, This code worked under HC05, OK, I guess white space counts. How would you make an array 24 deep with three elements?
 
 
0 Kudos

1,005 Views
peg
Senior Contributor IV
Hi Randall,

What assembler did this work with?

Just drop the EQU directive and it would work as far as I can see.

Note that your snippet has no device/core specific instructions, it only contains assembler directives and therefore is entirely assembler specific.

0 Kudos

1,005 Views
peg
Senior Contributor IV
Hello and welcome to the fora, SILKS,

You don't have a valid expression after the EQU.

0 Kudos