8-bit SREG in Atmegam328P

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

Is it possible to copy SREG in any register, like R16 etc. ?

Raj

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

yes 'SREG' is a defined register name so you can just copy it like any other register.

 

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

This is the code:

 

.INCLUDE "/usr/share/avra/m328Pdef.inc"

LDI R16, 0B1111111
OUT DDRD,R16
SBI DDRB,0

LDI R16, 5
LDI R17, -7
ADD R16, R17
MOV R16,SREG
OUT PORTD,R16

 

It is giving the error:

cls_ses.asm(12) : Error   : No register associated with SREG

 

 

Raj

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

MOV R16,SREG
OUT PORTD,R16

 

It is giving the error:

cls_ses.asm(12) : Error   : No register associated with SREG

 SREG is an IO Register, not a CPU register.  Use:

   IN R16, SREG

 

(This is unlike some other CPUs, where the status bits (and/or the PC, and/or the Stack Pointer) are part of the CPU register address space.)

 

Last Edited: Mon. Nov 6, 2017 - 06:57 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thank you Sir :)

Raj