Searching \ for 'Assembly help needed!' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: techref.massmind.org/techref/index.htm?key=assembly+help+needed
Search entire site for: 'Assembly help needed!'.

Truncated match.
PICList Thread
'Assembly help needed!'
1999\04\06@082314 by Lalakis Parafyadas

picon face
part 0 16 bytes
</x-html>

1999\04\06@085634 by Andy Kunz

flavicon
face
part 0 3379 bytes
x-html> At 04:07 AM 4/6/99 +0300, you wrote:
Hey everyone. I'm new to assembly, and I'd like to know how I can make a repeat loop that looks something like this (in Pascal):
 
for a:=1 to 10 do begin
  ....
  ....
end

First, Argaris, most assembly programmers work backwards, from n downto 0 instead because the language supports this more efficiently (which is the only reason to use assembly).

        movlw  ;  9
        movwf  ;  a
ForLoop
        (put your actions in here)

        decfsz&nbs p; a,f
        goto     ForLoop

If you still want to up-count:

        movlw  ;  1
        movwf  ;  a
ForLoop
        (put your actions in here)

        incf     a,f
        movlw  ;  10
        xorwf  ;  a,w
        btfss  ;  Z
        goto     ForLoop

Also, if there's a quick way to compare two values and if true something happens i.e.:
 
if a:=true and b:=true then ....
  or
if a:=23 and b:=12 then....


NOTE:  := is an assignment in Pascal.

        movf     a,w
        xorwf  ;  b
        btfss  ;  Z
        goto     NotEqual
Equal   (put your "then" here)
        
        goto     Endif
NotEqual
        (put your "else" here)

Endif

Andy

1999\04\06@104749 by mlsirton

flavicon
face
Hi,

A minor correction...

<snip>
> > for a:=1 to 10 do begin

This loop executes 10 times in pascal.

>         movlw   9
>         movwf   a
> ForLoop
>         (put your actions in here)
>
>         decfsz  a,f
>         goto    ForLoop

While this does 9 times on the PIC.  Decrease and skip on zero means
the PIC will not execute the loop with zero in A.

Hope this helps,
Guy

More... (looser matching)
- Last day of these posts
- In 1999 , 2000 only
- Today
- New search...