How to increase memory address in AVR assembly language

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

Hello, I am using ATMega128

Last Edited: Wed. Apr 7, 2021 - 02:22 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

add + 1 to var :       sts var +1, r22

 

or setup and use st

also increase var :          var:  .byte 5 

 

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

Thanks.

Last Edited: Wed. Apr 7, 2021 - 02:23 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 2

another way is to set up a pointer reg pair/loop


var: .byte 5

        clr temp
	ldi count,5
	ldi YL, LOW(var)
	ldi YH,High(var)

putram:
      inc temp          ; puts 1-5 in ram(var)
      st Y+, temp       ; post increment Y pointer
      dec count         ; counter
      brne putram

      ... rest of code

I'll have to look up the m128... never used it

I use the Atmel assemblers and not GAS. That might be it...?

There is a  m103 issue that deals with memory relocation or something. 

Being that I have never used this chip my (ass)umtion was that avr's are generally the same

This chip is kind of a unicorn,  RampZ and all... Good Luck!

Last Edited: Sun. Apr 4, 2021 - 10:35 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 2

you dont need any special sram variables for this simple task.
use a pointer only:

ldi YL,0
ldi YH,1 ;Start address 0100H

loop:
in r22,pina
st Y+,r22
cpi YH,$11
brne loop ;until end address 10FFH

Last Edited: Mon. Apr 5, 2021 - 07:27 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks for the helpsmiley

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

DarkRider96 wrote:
I tried sts var +1, r22 and it didn't work, gave an error.

What was teh error?  No one can see your screen other than you.

 

 

Jim

I would rather attempt something great and fail, than attempt nothing and succeed - Fortune Cookie

 

"The critical shortage here is not stuff, but time." - Johan Ekdahl

 

"Step N is required before you can do step N+1!" - ka7ehk

 

"If you want a career with a known path - become an undertaker. Dead people don't sue!" - Kartman

"Why is there a "Highway to Hell" and only a "Stairway to Heaven"? A prediction of the expected traffic load?"  - Lee "theusch"

 

Speak sweetly. It makes your words easier to digest when at a later date you have to eat them ;-)  - Source Unknown

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB, RSLogix user