[Top][All Lists]

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

[avr-gcc-list] Howto I/O in asm instructions?

From: Ruud Vlaming
Subject: [avr-gcc-list] Howto I/O in asm instructions?
Date: Tue, 1 Jul 2008 15:40:17 +0200
User-agent: KMail/1.9.1


There are a couple of ways to use i/o address in assymbly.
Below i used a some:

#define _EEARL_ "0x1E"
uint8_t portFSReadByte(unsigned char * pAddress)
{ uint8_t result;
  asm volatile ( \
   "in   r26, __SREG__      \n\t"  
   "cli                     \n\t"  
   "out  %2, %A0            \n\t" 
   "out  "_EEARL_", %B0     \n\t" 
   "sbi  __EECR__, 0        \n\t"  
   "in   %A0, 0x1D          \n\t" 
   "out __SREG__, r26       \n\t" 
   "" :"=r" (result) :"0" (pAddress), "I" (_SFR_IO_ADDR(EEARH)) : "r26" );
  return result; }

(1) You can define a constant, like i did for _EEARL_ 
  This is nice but no so portable.
(2) You can use the asm paramter list, like for EEARH
  Also nice, but errorprone, since i keep making mistakes in 
  numbering, especially when you have many parameters and 
  have to change something.
(3) The best thing to have would be something like __EECR__,
  resembling the definition for __SREG__, but that does not
  compile right now.

Is the latter possible somehow? Or are there other solutions?


reply via email to

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