Searching \ for 'Beginners problem' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/index.htm?key=beginners+problem
Search entire site for: 'Beginners problem'.

Truncated match.
PICList Thread
'Beginners problem'
1998\04\08@131614 by MadDog Parvikko

picon face
Hello everyone!
I recieved my first 16F84 chip few days ago, and I made a simple
testboard with RC oscillator and 8 LEDs connected to each pin of
PORTB. Then I wrote a little program with PASM to flash leds.

delay   mov ax,#200
jump1   mov bx,#200
jump2   dec bx
       mov W,bx
       jnz jump2
       dec ax
       mov W,ax
       jnz jump1
       ret

loop1   mov portb, cx
       add cx,cx
       call delay
       mov portb, #0
       call delay
       jmp loop1
       ret

This should flash each led in PORTB, but it doesn't. When 'cx' reaches
value 32 (led in pin 11 flashes), the program sets 'cx' again to value 1.
So the program flashes only leds in pins 6-11. I'm not a big genious
in ASM coding and I've no idea what I've done wrong. That quite terrible
increment delay seems to be working fine. Help me please!



-MParvikko

1998\04\09@065430 by Caisson

flavicon
face
> Van: MadDog Parvikko <spam_OUTparvikkoTakeThisOuTspamSGIC.FI>
> Aan: .....PICLISTKILLspamspam@spam@MITVMA.MIT.EDU
> Onderwerp: Beginners problem
> Datum: woensdag 8 april 1998 19:13
>
> Hello everyone!
> I recieved my first 16F84 chip few days ago, and I made a simple
> testboard with RC oscillator and 8 LEDs connected to each pin of
> PORTB. Then I wrote a little program with PASM to flash leds.

> delay   mov ax,#200
> jump1   mov bx,#200
> jump2   dec bx
>         mov W,bx
>         jnz jump2
>         dec ax
>         mov W,ax
>         jnz jump1
>         ret

The combination :
 dec {reg}
 mov w,{reg}
 jnz ***
could be written like :
 decfsz {reg}
 goto ***
(that is, in standard Micro-Chip assembler - Freeware !)

The shortest (memory usage :-) ) delay loop I know goes like this :
 clrf  DelayH
 clrf  DelayH
Delay:
 decfsz DelayL
 goto Delay
 decfsz DelayH
 goto Delay
 return
(Again, in standard Micro-Chip assembler)

> loop1   mov portb, cx
>         add cx,cx
>         call delay
>         mov portb, #0
>         call delay
>         jmp loop1
>         ret

Apart from the initialisation of Port B and register CX it looks fine to
me.

Did you define where you wanted to store your 'registers' (ax,bx,cx) ?
They should be at 0x0C, 0x0D and 0x0E for your example.

> This should flash each led in PORTB, but it doesn't. When 'cx' reaches
> value 32 (led in pin 11 flashes), the program sets 'cx' again to value 1.
> So the program flashes only leds in pins 6-11. I'm not a big genious
> in ASM coding and I've no idea what I've done wrong. That quite terrible
> increment delay seems to be working fine. Help me please!

If you would send your Hex-code (the code generated as output by your
assembler), I could debug that.
If you do, send it _DIRECTLY_ to caissonspamKILLspamtelebyte.nl , so we don't clobber
this mailing-list.

>  -MParvikko

Greetz,
 Rudy wieser

1998\04\09@163049 by Marc Heuler

flavicon
face
Hi Caisson (Caisson), in <.....199804091053.MAA05694KILLspamspam.....degas.telebyte.nl> on Apr 9 you
wrote:

> The shortest (memory usage :-) ) delay loop I know goes like this :
>   clrf  DelayH
>   clrf  DelayH
> Delay:
>   decfsz DelayL
>   goto Delay
>   decfsz DelayH
>   goto Delay
>   return

You can save a register file:

       clrf    DelayH
       clrw
Delay:  addlw   1
       btfsc   STATUS,Z
       decfsz  DelayH,f
       goto    Delay
       return

:-) Isn't that cute?  - only one goto statement

1998\04\14@065228 by Caisson

flavicon
face
> Van: Marc Heuler <EraseMEmarcspam_OUTspamTakeThisOuTAARGH.MAYN.DE>
> Aan: PICLISTspamspam_OUTMITVMA.MIT.EDU
> Onderwerp: Re: Beginners problem
> Datum: donderdag 9 april 1998 21:42
>
> Hi Caisson (Caisson), in <@spam@199804091053.MAA05694KILLspamspamdegas.telebyte.nl> on Apr
9 you
>  wrote:
[Cut]
{Quote hidden}

Yeah !!   That's why I like this 'discussion list' so much !
There is allways someone with a better/other solution & willing to share.

Thanks Marc.  It will be put into my 'snippets' directory.

Greetz,
 Rudy Wieser

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