Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] asm to hex file Source file not found: (no file)!

Status
Not open for further replies.

user3737

Newbie
Joined
Sep 19, 2022
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
15
Here is my code for my arduino nano: The error message is as the title says. I'm completely new to assembly language and would be interested to hear about any resources to help me solve this problem. Thank You!
Code:
; PORTB 6th and 7th pin are used to connect two LEDs.
; LED1 - PB6
; LED2 - PB7

; PORTD 2nd and 3rd pin are used to connect two input buttons. Which are used as interrupts and it generates interrupt during the rising edge of INT pin. That is from 0 to 1

; ButtonA - PD2 - INT0
; ButtonB - PD3 - INT1

;eg: PORTB |= 0x20 can be written as PORTB |= (1 << PB5). What this means is that binary 1 is shifted left to the 6th position on the 8-bit wide register. ( 1<<PB5 = 0x20 = 00100000 )
#include "avr/io.h"

.cseg
          .org     0x00
           rjmp    reset
          .org     0x01
           rjmp    INT0_VECT
          .org     0x02
           rjmp    INT1_VECT
          .org     0x34
reset:     ldi     r16,(1<<ISC00) | (1<<ISC01) | (1<<ISC10) |(1<<ISC11)
           out     EICRA, r16           ;the rising edge of INT1 generates an interrupt.
           ldi     r16, (1<<INT0) | (1<<INT1)
           out     EIMSK, r16           ;enables external interrupts
           ldi     r16, (1<<INTF0) | (1<<INTF1)
           out     EIFR, r16            ;external interrupt flags are made high, when interrupt occurs it becomes low.
           ser     r16
           out     DDRB, r16            ;PORTB as output
           clr     r18                  ;clears r18 register
           out     DDRD, r18            ;PORTD as input
           out     PORTB, r18           ;both LEDs are in off state
           sei                          ;enables global interrupt
here:      rjmp    here


INT0_VECT:
           cpi     r18, 0x02
           breq    last                 ; jump (branch) if equal to subroutine last
           ldi     r18, 0x01
           ldi     r16, (1<<PB6)        ;LED1 glows
           out     PORTB, r16
last:      ldi     r16, (1<<INTF0)
           out     EIFR, r16
           reti
INT1_VECT:
           cpi     r18, 0x01
           breq    last1
           ldi     r18, 0x02
           ldi     r16, (1<<PB7)        ;LED2 glows
           out     PORTB, r16
       
last1:     ldi     r16, (1<<INTF1)
           out     EIFR, r16
           reti

The error message:
[exp1.asm,34] 007: Undefined constant, variable, label or device (DDRB)!
Error ==> out DDRD, r18 ;PORTD as input
[exp1.asm,36] 007: Undefined constant, variable, label or device (DDRD)!
Error ==> out PORTB, r18 ;both LEDs are in off state
[exp1.asm,37] 007: Undefined constant, variable, label or device (PORTB)!
Error ==> ldi r16, (1<<PB6) ;LED1 glows
[exp1.asm,47] 007: Undefined constant, variable, label or device (PB6)!
Error ==> ldi r16, (1<<PB6) ;LED1 glows
[exp1.asm,47] 025: Expression of constant ((1<<PB6)) unreadable!
Error ==> out PORTB, r16
[exp1.asm,48] 007: Undefined constant, variable, label or device (PORTB)!
Error ==> last: ldi r16, (1<<INTF0)
[exp1.asm,50] 007: Undefined constant, variable, label or device (INTF0)!
Error ==> last: ldi r16, (1<<INTF0)
[exp1.asm,50] 025: Expression of constant ((1<<INTF0)) unreadable!
Error ==> out EIFR, r16
[exp1.asm,51] 007: Undefined constant, variable, label or device (EIFR)!
Error ==> ldi r16, (1<<PB7) ;LED2 glows
[exp1.asm,58] 007: Undefined constant, variable, label or device (PB7)!
Error ==> ldi r16, (1<<PB7) ;LED2 glows
[exp1.asm,58] 025: Expression of constant ((1<<PB7)) unreadable!
Error ==> out PORTB, r16
[exp1.asm,59] 007: Undefined constant, variable, label or device (PORTB)!
Error ==> last1: ldi r16, (1<<INTF1)
[exp1.asm,62] 007: Undefined constant, variable, label or device (INTF1)!
Error ==> last1: ldi r16, (1<<INTF1)
[exp1.asm,62] 025: Expression of constant ((1<<INTF1)) unreadable!
Error ==> out EIFR, r16
[exp1.asm,63] 007: Undefined constant, variable, label or device (EIFR)!
64 lines done.

Compilation aborted, 24 errors!
 
Last edited:

Hi,

what compiler do you use?
is the compiler setup correct?

The error text says about 24 errors, so we just see a couple of them.
Try to correct first (upper) errors first.

Klaus
 

Hi,

what compiler do you use?
is the compiler setup correct?

The error text says about 24 errors, so we just see a couple of them.
Try to correct first (upper) errors first.

Klaus
I've tested the compiler with blinking code and that worked so it should be set up correctly. I'm using gavrasm.

So to compile I write
Code:
./gavrasm exp1.asm

where exp1.asm is the name of the file.

Apologies for the error message, I'll update it to include all of the error lines.
 

Hi,

each AVR has a (slighly) different instruction set. How/where do you tell the compiler which AVR you use?

Klaus
 

It looks like gavrasm does not recognize the mneumonics for the PORTS and other constants and variables.
I downloaded gavrasm and tried compiling a file that had been written for another AVRA assembler and that file compiled OK because it inluded a definition file for the processor. If I include a definition file from the AVRA
assembler.
Code:
.include "m328pdef.inc"
in the code you posted above, gavrasm compiles it OK, except for the line:
Code:
"out     EICRA, r16 "          ;the rising edge of INT1 generates an interrupt.
Which gives the error:
"[eda.asm,23] 021: Port value (105) out of range (0..63)!"
Look up the "out" instruction to see if it has a limitation on the memory address range it can use.

This solution would suggest that gavrasm needs additional definitions for the particular microcontroller
being used to work with mneumonics for ports, etc.
 

That '.include' line contains the port and bit definitions for the processor the code is written for. It is basically a list of all the registers and their addresses and all the bit positions inside the registers. As each processor type is slightly different, each needs its own 'inc' file. By adding one for the 328 you provided references to some of the registers, maybe not correctly, but were still missing the one for EICRA.

You have to include the correct file for it to work. The file is normally provided with the assembler package so find the one matching the processor you are using and it should then work.

Brian.
 

Until we know which AVR is being used, the include file m328Pdef.inc is just a guess. It does include the definition for "EICRA" however. As the error indicates the problem with the line of code using the OUT instruction is that the address of the operand needs to be in the range of 0x0 to 0x63.

Syntax: Operands:
OUT A, Rr 0 ≤ r ≤ 31, 0 ≤ A ≤ 63

In the include file the address for "EICRA" is given as 0x69.

If this is indeed the correct definition of EICRA for the microcontroller you are using, a different instruction than OUT may need to be used.
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top