jump to a include file

Go To Last Post
7 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

HI I made a program in a Attiny24
That looks at a setting and due to the setting it has to jump to hiccup or latch.

If I put the program in one asm-file everything is working but if I split the file up. I got something strange.
If I make a jump to hiccup everything goes well but if I make a jump to Latch it always jumps to hiccup.

If I put the latch on top in the include program it always jump to latch.

Do I have to make more files for instance hiccup.asm and latch.asm, or is there a way to make a other kind of jump inside the included file?

I included the files

I hope any one can help, thanks

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The 2 files seems the same.

			ANDI	temp0,$88			;only look at bit #3 and #7
			cpi		temp0,$08			;is bit #3 set and bit #7 not set?
			rjmp	Hiccup				;yes jump to Hiccup
			cpi		temp0,$00			;is bit #3 and #7 not set?
			rjmp	Latch				;yes jump to Latch

But you are NOT testing for anything and doing a jump if the condition is met. So you always jump to Hiccup.

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I read PA3 and PA7 and put a mask over it. Than I compare the maked bits with a value and if there is a compare it jumps to Hiccup or Latch.

But as I mentioned before it is working if I put it in one asm-file but if I split the file up it is not working anymore?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
if there is a compare it jumps to Hiccup or Latch.
Where are you doing that? You are doing a compare and then jumping UNCONDITIONALLY instead of doing something like "BREQ Hiccup". The compare only set the flags, the next istruction needs to use those flags. RJMP does NOT, it just doesn't care.

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I see what you mean thanks a lot.
When it was one file I used the BREQ instruction but after I split the file I made a JUMP and as you say it does not look to anything but just make the jump(stupid of me).

Thanks again for making it clear to me!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

JUMP

Unwise in a Tiny24 - it only supports RJMP

(but I guess you meant that - just being pedantic as is my wont)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Now if the jump distance is too far for BREQ then you may need to reverse the logic of the test. ie

brne check_for_latch
rjmp Hiccup            ;yes jump to Hiccup  

check_for_latch:
latch code 

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly