我在学AVR单片机,仿真软件是IAR Embedded Workbench IDE. 我编了一个汇编程序,编译有错误 程序如下: .device AT90S8535 .equ PORTB =$18 .equ DDRB =$17 .equ PINB =$16 .equ SPH =$3E .equ SPL =$3D .equ EECR =$1C .equ EEDR =$1D .equ EEARH =$1F .equ EEARL =$1E .def ZH =r31 .def ZL =r30
rjmp RESET EEWrite: sbic EECR,01 rjmp EEWrite out EEARH,r18 out EEARL,r17 out EEDR,r16 sbi EECR,02 sbi EECR,01 ret EERead: sbic EECR,01 rjmp EEread out EEARH,r18 out EEARL,r17 sbi EECR,00 in r16,EEDR ret EEWrite_seq: sbic EECR,01 rjmp EEWrite_seq in r24,EEARL in r25,EEARH adiw r24,0x01 out EEARL,r24 out EEARH,r25 out EEDR,r16 sbi EECR,02 sbi EECR,01 ret EERead_seq: sbic EECR,01 rjmp EERead_seq in r24,EEARL in r25,EEARH adiw r24,0x01 out EEARL,r24 out EEARH,r25 sbi EECR,00 in r16,EEDR ret RESET: ldi r16,$02 out SPH,r16 ldi r16,$5f out SPL,r16 ;*************************** ldi r16,$ff out DDRB,r16 ldi r16,$aa ldi r18,$00 ldi r17,$40 rcall EEWrite ldi r18,$00 ldi r17,$40 rcall EERead out PORTB,r16 ;****************************** ldi r19,16 ser r20 out EEARH,r20 ser r20 out EEARL,r20 loop1: ldi r16,$55 rcall EEWrite_seq ldi r16,$aa rcall EEWrite_seq dec r19 brne loop1 ;****************************** ser r20 out EEARH,r20 ser r20 out EEARL,r20 clr ZH ldi ZL,1 loop2: rcall EERead_seq st Z,r16 inc ZL cpi ZL,12 brne loop2 forever: rjmp forever 编译错误如下: eeprom.asm Error[41]: Bad label D:\PROTEUS\eeprom.asm 1 Error[40]: Bad instruction D:\PROTEUS\eeprom.asm 1 Error[41]: Bad label D:\PROTEUS\eeprom.asm 2 Error[41]: Bad label D:\PROTEUS\eeprom.asm 2 Error[41]: Bad label D:\PROTEUS\eeprom.asm 3 Error[41]: Bad label D:\PROTEUS\eeprom.asm 3 Error[41]: Bad label D:\PROTEUS\eeprom.asm 4 Error[41]: Bad label D:\PROTEUS\eeprom.asm 4 Error[41]: Bad label D:\PROTEUS\eeprom.asm 5 Error[41]: Bad label D:\PROTEUS\eeprom.asm 5 Error[41]: Bad label D:\PROTEUS\eeprom.asm 6 Error[41]: Bad label D:\PROTEUS\eeprom.asm 6 Error[41]: Bad label D:\PROTEUS\eeprom.asm 7 Error[41]: Bad label D:\PROTEUS\eeprom.asm 7 Error[41]: Bad label D:\PROTEUS\eeprom.asm 8 Error[41]: Bad label D:\PROTEUS\eeprom.asm 8 Error[41]: Bad label D:\PROTEUS\eeprom.asm 9 Error[41]: Bad label D:\PROTEUS\eeprom.asm 9 Error[41]: Bad label D:\PROTEUS\eeprom.asm 10 Error[41]: Bad label D:\PROTEUS\eeprom.asm 10 Error[41]: Bad label D:\PROTEUS\eeprom.asm 11 Error[40]: Bad instruction D:\PROTEUS\eeprom.asm 11 Error[41]: Bad label D:\PROTEUS\eeprom.asm 12 Error[40]: Bad instruction D:\PROTEUS\eeprom.asm 12 Error[43]: Illegal effective address D:\PROTEUS\eeprom.asm 89 Error[43]: Illegal effective address D:\PROTEUS\eeprom.asm 90 Error[43]: Illegal effective address D:\PROTEUS\eeprom.asm 93 Error[43]: Illegal effective address D:\PROTEUS\eeprom.asm 94 Error[50]: Undefined symbol:'EECR' D:\PROTEUS\eeprom.asm 16 Error[50]: Undefined symbol:'EEARH' D:\PROTEUS\eeprom.asm 18 Error[50]: Undefined symbol:'EEARL' D:\PROTEUS\eeprom.asm 19 Error[50]: Undefined symbol:'EEDR' D:\PROTEUS\eeprom.asm 20 Error[50]: Undefined symbol:'EEread' D:\PROTEUS\eeprom.asm 26 Error[50]: Undefined symbol:'SPH' D:\PROTEUS\eeprom.asm 58 Error[50]: Undefined symbol:'SPL' D:\PROTEUS\eeprom.asm 60 Error[50]: Undefined symbol:'DDRB' D:\PROTEUS\eeprom.asm 63 Error[50]: Undefined symbol:'PORTB' D:\PROTEUS\eeprom.asm 71 Error[50]: Undefined symbol:'ZH' D:\PROTEUS\eeprom.asm 89 Error[50]: Undefined symbol:'ZL' D:\PROTEUS\eeprom.asm 90 Done. 39 error(s), 0 warning(s) 我估计是没添加头文件造成的。 可是我不知道该加哪个,请高手指教,谢谢!
|