Yahoo Groups archive

AVR-Chat

Index last updated: 2026-04-28 22:41 UTC

Message

Re: [AVR-Chat] the "case" statement

2005-02-21 by John Stiekema

// IAR assembler, variables byte-sized in registers:

#define i r16 //int8
#define n r17
#define z r18
#define p r19

	CPI r16,LOW(-1)	//test: -1?
	BRNE $+6
  	SUBI n,LOW(-1)
	RJMP break_
	TST r16		//test: 0?
	BRNE $+6
  	SUBI z,LOW(-1)
	RJMP break_
	CPI r16,1	//test: 1?
	BRNE $+6
  	SUBI p,LOW(-1)
	RJMP break_
      case_other:
	//case other code
      break_:


Eric wrote:

> Hi all chat'ers
> In C/C++ there is a "case" statement, is there such a thing in assembly code? and is there a example
> around.
> 
> 
> e.g here is the C version
> switch( i )
> {
>     case -1:
>         n++;
>         break;
>     case 0 :
>         z++;
>         break;
>     case 1 :
>         p++;
>         break;
> }
> 
> how do you do the line containing the "switch( i )" in assembly code.
> 
>>From Eric
> no attachment was sent with this email, if there is one, you might have a problem.
> 
> 
> 
>  
> Yahoo! Groups Links
> 
> 
> 
>  
> 
> 
> 
>

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.