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.

Please help me regarding my code - AVR IV

Status
Not open for further replies.

turbomen

Newbie level 1
Joined
Jun 12, 2009
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,289
Please help me on AVR IV

It is the hardest question to me.

Using any resources available, but only 1 register for the entire program, do the following:

Create 3 single byte variables in SRAM called NUM1, NUM2 and NUM3. You may create no more variables.

Load the values $02 $04 and $06 into NUM1, NUM2 and NUM3 respectively.

Write a program that does the following in sequence:

Swap the contents of NUM1 and NUM2
Swap the contents of NUM1 and NUM3
Swap the contents of NUM2 and NUM3

But remember, you may use any resources available, but only 1 register may be used for the whole program!

The final result will have NUM1 = $06
NUM2 = $04
NUM3 = $02

The following is my work. Please help me on this.

Code:
;Program name: task4 
;Author: Tony 
;Date: 11 June 2009 
;Purpose: To create 3 single byte variables in SRAM called NUM1, NUM2 and NUM3... 

.include "8515def.inc" ;Include file contains all register addresses 

ldi num2, high (RAMEND) ;high(RAMEND) is higher byte of $025F which is $02 
out SPH num2 ;SPH loaded with $02 
ldi num1, low (RAMEND) ;low (RAMEND) is lower byte 
out SPL num1 ;SPL LOADED WITH $5F 

Start 
push num2 ;Push num2 to stack, same sp decrements again 

Finish: 
rjmp Finish ;End of program
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top