0

i write a program for ATmega32 to get 8-bit number and show in 7segment but when i simulate it in Proteus it shows me that it is out of program memory what should i do exactly?

.INCLUDE "M32DEF.INC"
.ORG $00
//data to save in program memory
.DB $FC,$30,$6E,$7A,$B2,$DA,$DE,$70,$FE,$FA
.ORG $08
LDI R16,$01
//Statements
  • I'm voting to close this question as off-topic because this questions belongs to http://arduino.stackexchange.com/ – zx485 Dec 02 '16 at 21:55
  • 1
    This question has nothing to do with Arduino. It is assembly on AVR, just like the tags say. – UncleO Dec 03 '16 at 01:36

1 Answers1

2

The .ORG directives don't look right. The processor starts executing instructions at address 0, but you have placed data there. As well, there are 10 bytes of data, but only 8 bytes to place them in. I'm not sure what the data is for, as you didn't give it a label. Is it supposed to be instructions? Is the digits for an LCD display?

It would be helpful if you added some comments to your code to describe what your program is trying to do. I can see the part setting up the stack pointer and setting the port directions, but I don't want to try to analyze the loops. Just tell us what you mean to do.

As a start, you can try to change around the .ORG locations. Often, a program will have a part labelled "main:", with the first instruction at .ORG $0 to be a jump to main. This way you can place data at the top of the program, say at .ORG $08 so that it is easy to find in the code, but does not get executed by mistake.

.INCLUDE "M32DEF.INC"
.ORG $00
jmp main

.ORG $08
digits: .DB $FC,$30,$6E,$7A,$B2,$DA,$DE,$70,$FE,$FA

main:
LDI R16,$01 ; set stack pointer
OUT SPH,R16
LDI R16,$00
OUT SPL,R16

and so on
UncleO
  • 8,299
  • 21
  • 29
  • Thanks very much . Those data are for LCD to show digit. I want to save them in program memory from address 0 to 10 to access them –  Dec 17 '16 at 13:04