Full Version : compile error wih asm code
avr >>ASM PROGRAMMING (AVR) >>compile error wih asm code


Guyen- 11-27-2006
Hi guys, I am completely new to ATMEL programming and I was trying the example code trying tofigure out, and it gives error when i issue 'make'

In this code there seem to be two macros and one function definition. Compile error says
Error[4]: Unexpected end of file encountered
Recodring macto started at in line 14 (which is MACRO IRQ_ENTRY $reg in following code). Can you give any hint? Thanks!

;AREA TIMER_ASM_HANDLER, CODE, READONLY

AIC_BASE EQU 0xFFFFF000
AIV_IVR EQU 0x100
AIC_EOICR EQU 0x130

;ARM CODE MODE and Status bits

ARM_MODE_IRQ EQU 0x12
ARM_MODE_SYS EQU 0x1F

I_BIT EQU 0x80

MACRO IRQ_ENTRY $reg
;Adjust and save LR_irq in IRQ stack
sub r14, r14, #4
stmfd sp!, {r14}

;write in the IVR to support Protect Mode
;-No effect in Normal mode
;De-assert the NIRQ and clear teh source in Protect Mode
ldr r14, =AIC_BASE
str r14, [r14, #AIC_IVR]

;save SPSR and r0 in IRQ stack
mrs r14, SPSR
stmfd sp!, {r0, r14}

;enable interrupt adn switch in SYS mode
mrs r0, CPSR
bic r0, r0, #I_BIT
orr r0, r0, #ARM_MODE_SYS
msr CPSR_c, r0

;save scratch used registers and LR in user stack
IF "$reg" = ""
stmfd sp!, {r1-r3, r12,r14}
ELSE
stmfd sp!, {r1-r3, $reg, r12,r14}
ENDIF

MEND

MACRO
IRQ_EXIT $reg

;restore scratch/used registers and LR from user stack
IF "$reg" = ""
ldmia sp!, {r1-r3, r12, 14}
ELSE
ldmia sp!, {r1-r3, $reg, r12, r14}
ENDIF

;Disable interrup and switch back in IRQ mode
mrs r0, CPSR
bic r0, r0, $ARM_MODE_SYS
orr r0, r0, $I_BIT:OR:ARM_MODE_IRQ
msr CPSR_c, r0

;mark the end of interrup on the AIC
ldr r0, = AIC_BASE
str r0, [r0, #AIC_EOICR]

;restore SPSR_irq and r0 from IRQ stack
ldmia sp!, {r0, r14}
msr SPSR_cxsf, r14

;restore adjusted LR_irq from IRQ stack direcly in the PC
ldmia sp!, {pc}^

MEND

;------------------------------------------------------------------------
;-Function :timer1_asm_irq_handler
;-Treatments :timer 1 interrupt handler
;-Called functions :timer1_c_irq_handler
;-Called macros :IRQ_ENTRY, IRQ_EXIT
;------------------------------------------------------------------------
EXPORT timer1_asm_irq_handler
IMPORT timer1_c_irq_handler

timer1_asm_irq_handler

;manage exception entry
IRQ_ENTRY

;call the timer interrupt c handler
ldr r1, =timer1_c_irq_handler
mov r14, pc
bx r1

;manage exception exit
IRQ_EXIT
END






Forumer™ is Voted #1 Free Forum Hosting provider
Build your own community today with the largest message board hosting company.