11.07.2015 Views

Imagecraft c compiler and development environment for the atmel avr

Imagecraft c compiler and development environment for the atmel avr

Imagecraft c compiler and development environment for the atmel avr

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

ICCV8 <strong>for</strong> AVR – C Compiler <strong>for</strong> Atmel AVRAssembler SyntaxWord vs. Byte Oper<strong>and</strong>s <strong>and</strong> <strong>the</strong> ‘ (backquote) OperatorThe FLASH program memory of <strong>the</strong> AVR is addressed ei<strong>the</strong>r as words if it is viewedas program instructions or as bytes if it is used as read-only tables <strong>and</strong> such. Thus,depending on <strong>the</strong> instructions used, <strong>the</strong> oper<strong>and</strong>s containing program memoryaddressed may be treated as ei<strong>the</strong>r word or byte addresses.For consistency, <strong>the</strong> ICCV8 <strong>for</strong> AVR assembler always uses byte addresses. Certaininstructions, <strong>for</strong> example, <strong>the</strong> JMP <strong>and</strong> CALL instructions, implicitly convert <strong>the</strong> byteaddresses into word addresses. Most of <strong>the</strong> time, this is transparent if you are usingsymbolic labels as <strong>the</strong> JMP/CALL oper<strong>and</strong>s. However, if you are using a numericaddress, <strong>the</strong>n you must specify it as a byte address. For example,jmp 0x1F000jumps to <strong>the</strong> word address 0xF800. In <strong>the</strong> cases where you need to specify a wordaddress (e.g., using a .word directive), you can use <strong>the</strong> ‘ (backquote) operator:PL_func::.word ‘funcputs <strong>the</strong> word address of func into <strong>the</strong> word at location specified by PL_func.The assembler has <strong>the</strong> following syntax. Note that different vendors have <strong>the</strong>ir ownassemblers <strong>and</strong> it’s likely that our directives are different from o<strong>the</strong>r vendors.Generally, our assemblers are assumed in t<strong>and</strong>em with our <strong>compiler</strong>s with <strong>the</strong> mainobligation satisfying <strong>the</strong> dem<strong>and</strong> from <strong>the</strong> <strong>compiler</strong>s.NamesAll names in <strong>the</strong> assembler must con<strong>for</strong>m to <strong>the</strong> following specification:(‘_’ | [a-Z]) [ [a-Z] | [0-9] | ‘_’ ] *That is, a name must start with ei<strong>the</strong>r an underscore ( _) or an alphabetic character,followed by a sequence of alphabetic characters, digits, or underscores. In thisdocument, names <strong>and</strong> symbols are synonyms <strong>for</strong> each o<strong>the</strong>r. A name is ei<strong>the</strong>r <strong>the</strong>name of a symbol, which is a constant value, or <strong>the</strong> name of a label, which is <strong>the</strong> valueof <strong>the</strong> Program Counter (PC) at that moment. A name can be up to 30 characters inlength. Names are case-sensitive except <strong>for</strong> instruction mnemonics <strong>and</strong> assemblerdirectives.179

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!