GREETINGS FRIENDS, FOR DAYS I'M TRYING TO BE ABLE TO USE THE MACRO _SFR_IO_ADDR
WITHOUT RESULT. TO BE ABLE TO USE ASM AND C LANGUAGE AT THE SAME TIME I HAVE TO MODIFY OR ADD IN ORDER TO BE ABLE TO USE THE MACRO _SFR_IO_ADDR _SFR_IO_ADDR FOR THE COMPILER TO RECOGNIZE IT. REGARDS.
ASM FOR ATMEL STUDIO 7 ¡¡¡¡¡¡
What on earth have you done to that formatting?!
TO BE ABLE TO USE ASM AND C LANGUAGE AT THE SAME TIME
Have you seen this: https://www.nongnu.org/avr-libc/user-manual/group__asmdemo.html ?
EDIT
Also do a search of the forum - it has been discussed before:
https://www.avrfreaks.net/search/site/mix%2520c%2520assembler?filter_by=9631&so=0
My ears are ringing!
Ears? My eyeballs are spinning around and around.
Just show us an example of what you have tried and describe how the result is different from what is expected! You have written nothing that is helpful for any person who tries to answer your question.
Jim
I've tried to correct the silly font in post #1 but it won't change the inter-line spacing. Anyway...
@OP, if you read:
https://www.nongnu.org/avr-libc/user-manual/assembler.html
and follow the link to:
https://www.nongnu.org/avr-libc/user-manual/group__avr__sfr__notes.html
you will learn the __SFR_OFFSET trick. Now it does say:
This automatically subtracts 0x20 from I/O space addresses, but it's a hack,
but personally I don't agree with the manual. For my money it is not a "hack" it is the very best way to use <avr/io.h> in GNU as .S files and makes the code much cleaner.
Now instead of:
#include <avr/io.h> .section .text .global main main: ldi R16, 0xFF out _SFR_IO_ADDR(DDRB), R16 loop: in R17, _SFR_IO_ADDR(PORTB) eor R17, R16 out _SFR_IO_ADDR(PORTB), R17 rjmp loop
you can write the much "cleaner" code:
#define __SFR_OFFSET 0 #include <avr/io.h> .section .text .global main main: ldi R16, 0xFF out DDRB, R16 loop: in R17, PORTB eor R17, R16 out PORTB, R17 rjmp loop
which, to me anyway, seems like a very nice "hack" indeed !!
Your mileage may vary.
PS I do wonder why you are using the GNU assembler and not the the Atmel one. Or is this really about interworking C/C++ and Asm ?
hello my friend, thanks for taking the time sorry for the grammar at the beginning it turns out that I am not so good in English and I just copied and pasted for which I apologize, it turns out that if my intention to merge the c and asm language, plow a good time and tried to maximize a routine that I have beyond what the c language allows for much shorter times, with that I do not want to create a program that only uses asm but the function of my interest can be more efficient in the times, I found a text where he informed me that it was possible to use c and asm language routines together in atmel studio, and at the point of understanding the language and instructions, but I came across certain MACROS, which I did not understand and that is why I put my doubt (_SFR_IO_ADDR), as I understand so far the use of the assembly language with C is possible and atmel allows it according to and seen examples.
I leave a couple of links, down there if you may not explain very well what I'm trying to learn more.
https://gcc.gnu.org/onlinedocs/g...
https://www.ibiblio.org/gferg/ld...
I will be publishing a code that I am trying to compile, regarding an example of a rgb leds strips ws2812b it turns out that when using only c language, the times are not in the required margins and I have problems when assigning the color to each led, since each one needs a pulse in certain parameters, for a logical 1 0.8 us, and for a logical 0.4 us.