how to get high byte and low byte in GCC assembler?

Go To Last Post
2 posts / 0 new
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Are there equivalent functions in gcc assembler to the AVR assembler for high and low?
From the AVR manual:


LOW(expression) returns the low byte of an expression

HIGH(expression) returns the second byte of an expression

BYTE2(expression) is the same function as HIGH

BYTE3(expression) returns the third byte of an expression

BYTE4(expression) returns the fourth byte of an expression

LWRD(expression) returns bits 0-15 of an expression

HWRD(expression) returns bits 16-31 of an expression

PAGE(expression) returns bits 16-21 of an expression

EXP2(expression) returns 2 to the power of expression
DEFINED(symbol) Returns true if symbolis previously defined using .equ/.set/.def directives. Normally used in conjunction with .if directives (.if defined(foo)), but may be used in any context. It differs from other functions in that parentheses around its argument are not required, and that it only makes sense to use a single symbol as argument.

An example usage would be like:

;--- init stack
		ldi 	R24,low(RAMEND)		; RAMEND is a 16bit constant
		ldi 	R25,high(RAMEND)


  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

avrfreaks does not support Opera. Profile inactive.