Subject: EQU?

From: Owen Brand <[email-masked]>
Date: Wed, 5 May 2010 08:38:13 -0400

So, if I need a variable in assembly, I can set a memory location and  
access it by setting an EQU for easy access...

As an example:
BER  EQU >7F30

Now if I need to get to "BER", can I do a

     LI R1,BER
Or
     LI R1,@BER

Or perhaps I need to BLWP to BER...  Can someone let me know the  
proper syntax for this?

Owen Brand

        **webmaster**
http://www.Opry99er.com

---

From: Owen Brand <[email-masked]>
Date: Wed, 5 May 2010 08:43:46 -0400

BER  EQU >7F30
.
.
.
       BLWP @BER

But how do I get that value into a register for modification?

Owen Brand

        **webmaster**
http://www.Opry99er.com

On May 5, 2010, at 8:38 AM, Owen Brand <[email-masked]> wrote:

> So, if I need a variable in assembly, I can set a memory location  
> and access it by setting an EQU for easy access...
>
> As an example:
> BER  EQU >7F30
>

---

From: "Michael Zapf" <[email-masked]>
Date: Wed, 05 May 2010 12:56:52 -0000

EQU are just textual replacements; they have nothing to do with your program execution. They represent a number.

For instance, you can define 
THYEAR EQU 2010

and use THYEAR whereever you would have used the constant. The assembler replaces the occurances of THYEAR by the constant.

   LI R0,THYEAR 

is equivalent to

   LI R0,2010

in the objct code.

Also, the assembler performs arithmethic operations, so it's not a pure string replacement. If your write

   LI R0, THYEAR-1

this is equivalent to

   LI R0,2009

Thus, writing LI R0,@SOMETH is wrong, as LI=Load Immediate, and this requires an immediate (direct) value, and @ refers to a symbolic address.

If you write

   MOV @THYEAR,R1

this is equivalent to

   MOV @2010,R1

which copies the contents memory location 2010 (>07DA) into register 1.

Michael

---

From: Owen Brand <[email-masked]>
Date: Wed, 5 May 2010 09:04:56 -0400

Thanks-- that answered my question!

So
BER EQU >7F30
         MOV @BER,R1
Will take the value stored at >7F30 and place it in register 1...

Perfect.  Thanks Michael!

Owen Brand

        **webmaster**
http://www.Opry99er.com

On May 5, 2010, at 8:56 AM, "Michael Zapf" <[email-masked]> wrote:

>
>
> EQU are just textual replacements; they have nothing to do with your  
> program execution. They represent a number.
>
> and use THYEAR whereever you would have used the constant. The  
> assembler replaces the occurances of THYEAR by the constant.
>
> LI R0,THYEAR
>
> is equivalent to
>
> LI R0,2010
>
> in the objct code.
>
> Thus, writing LI R0,@SOMETH is wrong, as LI=Load Immediate, and this  
> requires an immediate (direct) value, and @ refers to a symbolic  
> address.
>
> If you write
>
> MOV @THYEAR,R1
>
> this is equivalent to
>
> MOV @2010,R1
>

---

From: "Tursi" <[email-masked]>
Date: Wed, 5 May 2010 09:50:06 -0700

> Will take the value stored at >7F30 and place it in register 1...

It will, but there's no RAM at >7F30.... and using EQU for variables means 
you need to know the layout of all memory, which, if you're doing 
relocatable code, you don't.

For defining variables, it's not EQU you want to use... rather, you have 
three options.

If you don't need an initial value, use "BSS", which is "Block starting with 
symbol". It takes the number of bytes you want to reserve. So for a normal 
2-byte word, you'd use:

VAR1 BSS 2
...
  MOV @VAR1,R1

Unlike EQU, the compiler sets the address in the same way as labels for the 
program are calculated.

If you do need an initial value, you can use DATA or BYTE. However, I'd 
discourage this approach and recommend that the code initialize the variable 
itself.

EQU is generally used for fixed values, to replace numbers with words for 
readability... for instance, you might use it to set the location of the 
sound chip (though you can REF it since EA already has that):

SOUND EQU >9400

Or you might use it to remember the size of the screen:

ROWS EQU 24
COLS EQU 32

The trick to remember is that BSS defines actual memory at its label - so 
you must make sure it's outside the code (before START or after the end of 
the code, or even between functions, just not in the middle). EQU only tells 
the assembler to use a name for a number.