avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] How to do multi-line assembler macros?


From: E. Weddington
Subject: Re: [avr-gcc-list] How to do multi-line assembler macros?
Date: Tue, 9 Sep 2003 16:10:56 GMT

> Hi,
> 
> I'm writing some assembler routines where the use of C 
#define macros
> would make my life a lot easier.  I need to write a macro 
of the form:
> 
>       lds     r0, servo_0
>       tst     r0
>       brne    servos_reset_0_over_1
>       cbi     SERVO_0_PORT, SERVO_0_BIT
>       rjmp    servos_reset_0_over
> servos_reset_0_over_1:
>       sbi     SERVO_0_PORT, SERVO_0_BIT
> 
> There are lots of servos, so I'd like to write a macro 
like this:
> 
> #define RESET_SERVO(servo) \
>       lds     r##servo, servo_##servo ;\
>       tst     r##servo ;\
>       brne    servos_reset_##servo##_over_1 ;\
>       cbi     SERVO_##servo##_PORT, 
SERVO_##servo##_BIT; \
>       rjmp    servos_reset_##servo##_over; \
> servos_reset_##servo##_over_1: \
>       sbi     SERVO_##servo##_PORT, 
SERVO_##servo##_BIT; \
> servos_reset_##servo##_over:
> 
> To be used like so:
> 
>       RESET_SERVO(0)
>       RESET_SERVO(1)
>       ...
> 

Dumb question: Any reason why you're doing this all in 
assembly instead of C with macros that generate inline 
assembly?

Thanks
Eric




reply via email to

[Prev in Thread] Current Thread [Next in Thread]