Searching \ for 'why won't this code fragment work ????????????????' 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=why+wont+code+fragment
Search entire site for: 'why won't this code fragment work ????????????????'.

Truncated match.
PICList Thread
'why won't this code fragment work ????????????????'
1998\02\11@011453 by kerzer

flavicon
face
word    set     one
       call    test
word    set     two
       call    test
word    set     three
       call    test

test
       call    word
       return

one
       return
two
       return
three
       return

The set command seems to only remember the last one, ie it calls three all
the time. I had it workin, but I don't know how I did it.

Gordon

1998\02\11@064151 by Caisson

flavicon
face
----------
> Van: spam_OUTkerzerTakeThisOuTspamCST.CO.ZW
> Aan: .....PICLISTKILLspamspam@spam@MITVMA.MIT.EDU
> Onderwerp: why won't this code fragment work ?????????????????
> Datum: woensdag 11 februari 1998 7:51
>
> word    set     one
>         call    test
> word    set     two
>         call    test
> word    set     three
>         call    test
>
> test
>         call    word
>         return

The first thing your 'test' routine does is 'call word' , wich executes
'set three'
hereby overruling your 'set one' command.

Next, your commands 'test: call word, word: set three, call test' are
building
a loop that will never end !

And, whats more, your stack will grow explosively !  (all those call's and
no
return's ...) In a micro-controller you will mostly not notice this,
because the
stack sits in a seperate piece of memory and will only overwrite its own
'return' data when overflowing.

Try something like :

word    set     three
test
       {do any output}
       return



> one
>         return
> two
>         return
> three
>         return
>
> The set command seems to only remember the last one, ie it calls three
all
> the time. I had it workin, but I don't know how I did it.
>
> Gordon

Greetz,
 Rudy Wieser

1998\02\11@140418 by Bob Shaver

flavicon
face
The "SET" command is an assembler command (i.e. has effect at assemble
time, *not* at run time).  As you have found, the assembler preprocessor
expands your source code to:
       call    test
       call    test
       call    test

test    call    three

The value of "word" when the assembler reaches "test" is "three".  It looks
like you are trying to have the destination of the call at "test"
determined at run time.  With the 16Cxx family, all CALLs are hard-coded.
You can emulate this by doing something like this (WARNING: not tested and
barely proof-read!):

;-- Set call destination to "one"
       movlw   high(one)       ;Load upper byte of address into PC Latch High
       movwf   PCLATH
       movlw   low(one)        ;Load lower byte of address into temp register
       movwf   CALLDEST
       call    test
zzz1    ... (more code here)

       movlw   high(two)       ;Load upper byte of address into PC Latch High
       movwf   PCLATH
       movlw   low(two)        ;       Load lower byte of address into temp reg
ister
       movwf   CALLDEST
       call    test
zzz2    ... (more code here)

test    ... (put some code here that does not change PCLATH)
       movf    CALLDEST,0
       movwf   PCL             ;Jumps (chains) to desired routine

one     ...(some code here)
       return                  ;Will return to zzz1

two     ...(some code here)
       return                  ;Will return to zzz2

On Wednesday, February 11, 1998 1:51 AM, kerzerspamKILLspamCST.CO.ZW
[SMTP:.....kerzerKILLspamspam.....CST.CO.ZW] wrote:
{Quote hidden}

all
> the time. I had it workin, but I don't know how I did it.
>
> Gordon
>

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