[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: [avr-gcc-list] inline asm
From: |
Rune Christensen |
Subject: |
RE: [avr-gcc-list] inline asm |
Date: |
Thu, 27 May 2004 12:43:09 +0200 |
Hello
Why don't you just use normal C code for the calculations ??
In C you can use + for add and * for mul for example
long int temp;
long int a = 10, b = 20;
temp = a + b;
It is a lot easier to debug.
avr-gcc will optimize the code for you if you use
avr-gcc -Os calc.c -o calc.o
for space optimization
avr-gcc -O1 calc.c -o calc.o
avr-gcc -O2 calc.c -o calc.o
avr-gcc -O3 calc.c -o calc.o
for different forms of speed optimization
Cheers
Rune
-----Original Message-----
From: address@hidden [mailto:address@hidden
Behalf Of Muhammed
Sent: Thursday, May 27, 2004 11:55 AM
To: address@hidden
Subject: [avr-gcc-list] inline asm
How can I convert this code into inline assembly compatible with AVR-gcc
compiler. Is there a tool for that? Or a manual? Thanks in advance,
Here is my AVR assembler code:
START: ldi r16, 0x12
ldi r17, 0x52
ldi r18, 0xF3
ldi r19, 0xFF
ldi r20, 0xA7
ldi r21, 0x5B
ldi r22, 0x13
ldi r23, 0xC9
Add32: add a0,b0 ;Add low bytes
mov tmp0,a0
adc a1,b1 ;Add higher bytes with carry
mov tmp1,a1
adc a2,b2 ;
mov tmp2,a2
adc a3,b3
mov tmp3,a3 ;
ldi r16, 0x73
ldi r17, 0xD8
ldi r18, 0x49
ldi r19, 0xE4
ldi r20, 0xFF
ldi r21, 0x91
ldi r22, 0x5A
ldi r23, 0x73
add a0, b0
adc a1, b1
adc a2, b2
adc a3, b3
mov b0, tmp0
mov b1, tmp1
mov b2, tmp2
mov b3, tmp3
Mul32: clr res7 ;clear 4 highest bytes of result
clr res6 ;
clr res5 ;
sub res4,res4 ;and carry
ldi counter,33 ;init loop counter
m32u_loop: ror res3 ;rotate result and multiplier
ror res2 ;
ror res1 ;
ror res0 ;
dec counter ;decrement loop counter
breq Return32u ;if counter zero return
brcc m32u_skip ;if bit 0 of multiplier set
add res4, b0 ;add multiplicand to result
adc res5, b1 ;
adc res6, b2 ;
adc res7, b3 ;
m32u_skip: ror res7 ;shift right result byte 7
ror res6 ;rotate right result
ror res5 ;
ror res4 ;
rjmp m32u_loop ;
Return32u: ret
.EXIT
_______________________________________________
avr-gcc-list mailing list
address@hidden
http://www.avr1.org/mailman/listinfo/avr-gcc-list
---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.690 / Virus Database: 451 - Release Date: 22-05-2004
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.690 / Virus Database: 451 - Release Date: 22-05-2004