Subject: Couple AL questions

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

If I can place a value in a register and INC it by 1 each time the  
loop passes the CI instruction, then I could simply use that as a way  
to check for completion of a task.... Like a FOR NEXT loop...

        CLR R0
LP   INC R0
        CI R0,768
        JNE LP

This should set R0 to zero, then INCrease it by one... Then the value  
stored in R0 is compared to 768 and if it is not equivalent, it should  
jump back to the label "LP" which will once again INCrease the value  
in R0 by one and continue until the value in R0=768.  So, let's say I  
added a VDP write into this directly after LP.  This could turn into a  
draw routine for an entire screen.... Sorry if this seems elementary,  
I'm a rookie again and loving it.

Owen Brand

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

---

From: Owen Brand <[email-masked]>
Date: Wed, 5 May 2010 03:35:53 -0400

Of course to use a VDP write utility, I would have to reserve R0, R1,  
and R2, right?  So my source should be

      CLR R4
LP INC R4
      CI R4,768
      JNE LP

Owen Brand

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

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

> loop passes the CI instruction, then I could simply use that as a  
> way to check for completion of a task.... Like a FOR NEXT loop...
>
>       CLR R0
> LP   INC R0
>       CI R0,768
>       JNE LP
>
> This should set R0 to zero, then INCrease it by one... Then the  
> value stored in R0 is compared to 768 and if it is not equivalent,  
> it should jump back to the label "LP" which will once again INCrease  
> the value in R0 by one and continue until the value in R0=768.  So,  
> let's say I added a VDP write into this directly after LP.  This  
> could turn into a draw routine for an entire screen.... Sorry if  
> this seems elementary, I'm a rookie again and loving it.
>
>
>
>
>
>
> Owen Brand
>
>       **webmaster**
> http://www.Opry99er.com

---

From: mark wills <[email-masked]>
Date: Wed, 5 May 2010 16:39:40 +0000 (GMT)

You can do it like that, *BUT* if you count backwards, you don't need the CI instruction, which saves 4 bytes AND makes the loop faster!

LI R0,768
LP DEC R0
JNE LP

The JNE is a 'jump if not equal' instruction. Read the section in the editor assembler manual about the status register. Most instructions, when they execute, effect the status register in some way. For example, when an instruction results in value in a register of 0, the EQ flag is set in the status register.

The JNE instruction looks at the EQ flag, and takes the jump if the flag is NOT set.

The JEQ (jump if equal) takes the jump if it is set (i.e. if the register is 0).

Which register? Well, the LAST one! So, the example above, eventually the DEC R0 will cause R0 to become 0. At that point, the EQ flag will be set which is examined by the JNE instruction.

When you use a COMPARE (like CI or C) instruction, the processor actually does a subtraction, and compares the RESULT to 0. If the result is 0, the flag goes up.

So, if R0 equals 10:

The instruction CI R0,768 actually does:

768-10=758

That is not equal to 0, so the flag doesn't go up.

We can save the hassle, and just omit the compare instruction.

Most instructions change the status register in some way. Have a look in the ED/AS manual for which bits in the SR are affected by which instruction.

Another quick example: If you want to compare to zero, you could do:

CI R5,0

But it is actually faster to do

MOV R5,R5

Can you see why?

Here endeth the first lesson ;-)

----- Original Message ----
> From: Owen Brand <[email-masked]>
> To: [email-masked]
> Sent: Wed, 5 May, 2010 7:13:08
> Subject: [TI994A] Couple AL questions
> 

LP   INC R0
        
        JNE LP

This should set R0 to 
> zero, then INCrease it by one... Then the value  
stored in R0 is 
> compared to 768 and if it is not equivalent, it should  
jump back to 
> the label "LP" which will once again INCrease the value  
in R0 by one 
> and continue until the value in R0=768.  So, let's say I  
added a 
> VDP write into this directly after LP.  This could turn into a  
> 

Owen 
> Brand

        **webmaster**

> href="http://www.Opry99er.com" target=_blank 
> >http://www.Opry99er.com

------------------------------------

Yahoo! 
> Groups Links

>   
> >http://groups.yahoo.com/group/TI994A/

> href="http://groups.yahoo.com/group/TI994A/join" target=_blank 
> >http://groups.yahoo.com/group/TI994A/join
    (Yahoo! ID 
> required)

> href="mailto:[email-masked]">[email-masked] 
> 
    
> href="mailto:[email-masked]">[email-masked]

> ymailto="mailto:[email-masked]" 
> href="mailto:[email-masked]">[email-masked]

> href="http://docs.yahoo.com/info/terms/" target=_blank 
> >http://docs.yahoo.com/info/terms/