реклама на сайте
подробности

 
 
> AVR-GCC: указатель для адресного пространства более 64К, как?!?!
ARV
сообщение Oct 22 2010, 16:36
Сообщение #1


Профессионал
*****

Группа: Свой
Сообщений: 1 143
Регистрация: 30-09-08
Из: Новочеркасск
Пользователь №: 40 581



возможно ли каким-то образом заставить AVR-GCC сделать указатель, в котором будет не 16 бит, а больше - 24 или 32?
подмена типа меня не устраивает, т.к. хочется, чтобы компилятор верно вычислял смещения адресов полей в структурах:
pgm_read_byte_far(ptr->field5) - как обявить ptr, если допустим, он должен быть равен 0x10027?!


--------------------
Я бы взял частями... но мне надо сразу.
Go to the top of the page
 
+Quote Post
 
Start new topic
Ответов
aesok
сообщение Oct 22 2010, 17:11
Сообщение #2


Знающий
****

Группа: Участник
Сообщений: 596
Регистрация: 26-05-06
Из: Москва
Пользователь №: 17 484



Цитата(ARV @ Oct 22 2010, 20:36) *
возможно ли каким-то образом заставить AVR-GCC сделать указатель, в котором будет не 16 бит, а больше - 24 или 32?


В настоящее время нельзя.

Анатолий.
Go to the top of the page
 
+Quote Post
demiurg_spb
сообщение Oct 23 2010, 08:24
Сообщение #3


неотягощённый злом
******

Группа: Свой
Сообщений: 2 746
Регистрация: 31-01-08
Из: Санкт-Петербург
Пользователь №: 34 643



Есть такой макрос для взятия адреса, может быть Вам будет чем-то полезен.
CODE
/* GET_FAR_ADDRESS() macro
*
* This macro facilitates the obtention of a 32 bit "far" pointer (only 24 bits
* used) to data even passed the 64KB limit for the 16 bit ordinary pointer. It
* is similar to the '&' operator, with some limitations.
*
* Comments:
*
* - The overhead is minimal and it's mainly due to the 32 bit size operation.
*
* - 24 bit sizes guarantees the code compatibility for use in future devices.
*
* - hh8() is an undocumented feature but seems to give the third significant byte
* of a 32 bit data and accepts symbols, complementing the functionality of hi8()
* and lo8(). There is not an equivalent assembler function to get the high
* significant byte.
*
* - 'var' has to be resolved at linking time as an existing symbol, i.e, a simple
* type variable name, an array name (not an indexed element of the array, if the
* index is a constant the compiler does not complain but fails to get the address
* if optimization is enabled), a struct name or a struct field name, a function
* identifier, a linker defined identifier,...
*
* - The natural place for this macro should be the header avr/pgmspace.h and the
* name... pgm_get_far_address?
*
* - The returned value is the identifier's VMA (virtual memory address) determined
* by the linker and falls in the corresponding memory region. The AVR Harvard
* architecture requires non overlapping VMA areas for the multiple address spaces
* in the processor: Flash ROM, RAM, and EEPROM. Typical offset for this are
* 0x00000000, 0x00800xx0, and 0x00810000 respectively, derived from the linker
* script used and linker options. The value returned can be seen then as a
* universal pointer.
*
*/


#ifndef _FAR_ADDRESS_H_
#define _FAR_ADDRESS_H_

#define GET_FAR_ADDRESS(var) \
({ \
uint_farptr_t tmp; \
\
__asm__ __volatile__( \
\
"ldi %A0, lo8(%1)" "\n\t" \
"ldi %B0, hi8(%1)" "\n\t" \
"ldi %C0, hh8(%1)" "\n\t" \
"clr %D0" "\n\t" \
: \
"=d" (tmp) \
: \
"p" (&(var)) \
); \
tmp; \
})

#endif


--------------------
“Будьте внимательны к своим мыслям - они начало поступков” (Лао-Цзы)
Go to the top of the page
 
+Quote Post

Сообщений в этой теме
- ARV   AVR-GCC: указатель для адресного пространства более 64К   Oct 22 2010, 16:36
- - ARV   все эти макросы и т.п. мне известны, но это совсем...   Oct 23 2010, 18:21
|- - Petka   Цитата(ARV @ Oct 23 2010, 22:21) все эти ...   Oct 23 2010, 19:52
- - ReAl   Единственное, что остаётся - стараться всё такое р...   Oct 23 2010, 19:39
|- - demiurg_spb   Цитата(ReAl @ Oct 23 2010, 23:39) Единств...   Oct 24 2010, 07:38
|- - ARV   Цитата(demiurg_spb @ Oct 24 2010, 11:38) ...   Oct 24 2010, 17:04
- - ReAl   Имелось ввиду "всё такое (где структуры/поля)...   Oct 24 2010, 09:45
|- - demiurg_spb   Цитата(ReAl @ Oct 24 2010, 13:45) строки ...   Oct 25 2010, 08:57
- - xelax   В IAR решили эту проблему, там указатели для мег с...   Oct 25 2010, 14:59
|- - ARV   Цитата(xelax @ Oct 25 2010, 18:59) В IAR ...   Oct 26 2010, 05:09
|- - xelax   Цитата(ARV @ Oct 26 2010, 09:09) наверное...   Oct 26 2010, 06:29
||- - ARV   Цитата(xelax @ Oct 26 2010, 10:29) Нет.. ...   Oct 26 2010, 08:13
||- - demiurg_spb   Цитата(ARV @ Oct 26 2010, 12:13) в avr-gc...   Oct 26 2010, 11:13
||- - ARV   Цитата(demiurg_spb @ Oct 26 2010, 15:13) ...   Oct 26 2010, 13:07
||- - demiurg_spb   Цитата(ARV @ Oct 26 2010, 17:07) разве не...   Oct 26 2010, 15:22
|- - demiurg_spb   Цитата(ARV @ Oct 26 2010, 09:09) наверное...   Oct 26 2010, 06:31
- - IgorKossak   В IAR AVR для указателей на дальние области были к...   Oct 26 2010, 06:46
|- - demiurg_spb   Цитата(IgorKossak @ Oct 26 2010, 10:46) В...   Oct 26 2010, 06:56
- - xelax   Вот к стати народ обсуждает как trampoline секцию ...   Oct 26 2010, 07:43


Reply to this topicStart new topic
1 чел. читают эту тему (гостей: 1, скрытых пользователей: 0)
Пользователей: 0

 


RSS Текстовая версия Сейчас: 28th July 2025 - 22:50
Рейтинг@Mail.ru


Страница сгенерированна за 0.01384 секунд с 7
ELECTRONIX ©2004-2016