Sonsivri
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
April 20, 2024, 08:00:07 08:00


Login with username, password and session length


Pages: [1]
Print
Author Topic: Codevision adaptation ASM code from GCC syntax  (Read 7985 times)
0 Members and 1 Guest are viewing this topic.
breakenter
Newbie
*
Offline Offline

Posts: 11

Thank You
-Given: 3
-Receive: 0


« on: February 17, 2012, 08:54:53 08:54 »

Hi boys.

I am a beginner and use CODEVISION AVR.
I have a big problem with rewriting ASM routines for CODEVISION.
I need to write source code for a spectrum analyzer (FFT)  to AVRMEGA procesor and Codevision AVR.

-------------------------------------------------------------------------

I found several examples on the Internet.

Original library for AVRGCC is here >
http://elm-chan.org/docs/avrlib/avrfft.zip


-------------------------------------------------------------------------

The FFT.h use external asembler code FFT.S for this function.

void fft_input
void fft_execute
void fft_output

Can someone adapt the source code for CodeVision ??
terms of files  FFFT.H and FFFT.S and rewrite this syntax  to syntax Codevision.


-------------------------------------------------------------------------

Here is another project
http://www.jnutthailand.com/FFT.html
but also used AVRGCC syntax and code not work in CvAvr.


-------------------------------------------------------------------------


Please very much for help in rewriting code for CodeVision
thank you all for helping!!
sorry for my bad English :-)
Logged
metal
Global Moderator
Hero Member
*****
Offline Offline

Posts: 2420

Thank You
-Given: 862
-Receive: 678


Top Topic Starter


« Reply #1 on: February 17, 2012, 12:44:09 12:44 »

FFT is written in assembly for "speed" reasons. AVR doesn't have a dedicated hardware for FFT, and writing it in C will slow it down, no matter how optimized the compiler is, the FFT routine has to be written in .asm for AVR by an experienced human.

One thing I need to mention, if the project already works on one compiler, and you need not change it, then use the same original compiler.
« Last Edit: February 17, 2012, 12:55:22 12:55 by metal » Logged
breakenter
Newbie
*
Offline Offline

Posts: 11

Thank You
-Given: 3
-Receive: 0


« Reply #2 on: February 17, 2012, 01:29:36 13:29 »

CodeVision can also implement ASM code.
But the syntax for handling with ASM will be different.

I do not want to overwrite the original C code.

I need to adapt to the original GCC asm code to ->  asm code for CvAvr.
if it goes in the GCC, so it must go in CvAvr  (implement ASM routine).
Logged
hate
Hero Member
*****
 Warned
Offline Offline

Posts: 555

Thank You
-Given: 156
-Receive: 355


« Reply #3 on: February 17, 2012, 06:33:47 18:33 »

Codevision and AVRGCC uses different syntax for assembler and as far as I know AVRGCC supports both the Intel syntax and AT&T syntax with its assembler. Codevision had support only for Intel syntax if they didn't add support later. And assuming the code is in Intel syntax, there is also a huge difference in the 'inline assembly' syntax of Codevision and AVRGCC. Considering all this, I guess the work has to be done by hand. And if u are not capable of doing this, probably it will be very hard for u to debug the code. I suggest u switch to AVRGCC in that case. I did this in the past and it's not that hard.

Regards...
Logged

Regards...
sam_des
Senior Member
****
Offline Offline

Posts: 253

Thank You
-Given: 124
-Receive: 146


« Reply #4 on: February 18, 2012, 05:12:19 05:12 »

Hello,
Few things to remember when trying to port gcc's asm code to codevision,
1) As far as I know Codevision doesn't support separate assembly modules, since there is no linker for codevision. You have to write C functions with inline assembly.
2) Codevision(as most of C compilers for AVR) use separate 'software stack - Y-Pointed' and 'hardware stack- SP pointed' while GCC does not. It uses single stack, only handled by SP.
3) There is major difference in how & which registers, C functions use for parameter passing and return values. As far as I know, codevision uses entirely software stack for parameter passing while gcc uses registers heavily.
4) There is also difference in which registers need to be preserved accross function calls and which can be trashed.
5) gcc assembler is quite capable, while codevision supports only Atmel assembler's features.
6) And most obviously there are syntax differences, like I/O register access, atmel assembler supports it directly, but gcc requires special macros.

There are many such major and trivial things. Once you get them it is quite straight forward, codevision and gcc manuals are your best friends  Wink

In my opnion, instead of trying to port asm code from gcc to codevision, it is quite easy to port codevision c to gcc c. There is nothing which codeivison can and gcc can't do, except if your code rely heavily on codevision's hardware libraries.  Grin

regards,
sam_des
« Last Edit: February 18, 2012, 05:18:43 05:18 by sam_des » Logged

Never be afraid to do something new. Remember Amateurs built the Ark, Professionals built the Titanic !
Pages: [1]
Print
Jump to:  


DISCLAIMER
WE DONT HOST ANY ILLEGAL FILES ON THE SERVER
USE CONTACT US TO REPORT ILLEGAL FILES
ADMINISTRATORS CANNOT BE HELD RESPONSIBLE FOR USERS POSTS AND LINKS

... Copyright © 2003-2999 Sonsivri.to ...
Powered by SMF 1.1.18 | SMF © 2006-2009, Simple Machines LLC | HarzeM Dilber MC