skee3732 up laboratory 1 sheet 20152016-1 (updated 210915).pdf

19
SKEE3732 uP Laboratory 1 Sheet 20152016-1 (updated).docx 1 -------------------------------------------------------------------------------------------------------------- Fakulti: FAKULTI KEJURUTERAAN ELEKTRIK Nama Matapelajaran: Kod Matapelajaran : SKEE 3732 Semakan Tarikh Keluaran Pindaan Terakhir No. Prosedur : 1 : September 2015 : : PK-UTM-FKE-(0)-10 FAKULTI KEJURUTERAAN ELEKTRIK UNIVERSITI TEKNOLOGI MALAYSIA KAMPUS SKUDAI JOHOR SKEE 3732 MICROPROCESSOR LABORATORY Laboratory 1: Using the AVR Studio Prepared by: ZURAIMI BIN YAHYA Approved by : Head of Department Name: Signature & Stamp: Signature & Stamp: Date: Date:

Upload: fishy-kenny

Post on 06-Dec-2015

230 views

Category:

Documents


3 download

TRANSCRIPT

Page 1: SKEE3732 uP Laboratory 1 Sheet 20152016-1 (updated 210915).pdf

SKEE3732 uP Laboratory 1 Sheet 20152016-1 (updated).docx 1

--------------------------------------------------------------------------------------------------------------

Fakulti: FAKULTI KEJURUTERAAN ELEKTRIK

Nama Matapelajaran:

Kod Matapelajaran : SKEE 3732

Semakan Tarikh Keluaran Pindaan Terakhir No. Prosedur

: 1 : September 2015 : : PK-UTM-FKE-(0)-10

FAKULTI KEJURUTERAAN ELEKTRIK

UNIVERSITI TEKNOLOGI MALAYSIA

KAMPUS SKUDAI

JOHOR

SKEE 3732

MICROPROCESSOR LABORATORY

Laboratory 1: Using the AVR Studio

Prepared by:

ZURAIMI BIN YAHYA

Approved by : Head of Department

Name:

Signature & Stamp: Signature & Stamp:

Date: Date:

Page 2: SKEE3732 uP Laboratory 1 Sheet 20152016-1 (updated 210915).pdf

SKEE3732 uP Laboratory 1 Sheet 20152016-1 (updated).docx 2

I. PRELIMINARY PREPARATION (15 marks)

Important Note: You are required to do following BEFORE the lab session.

1. Install AVR Studio 6.2. You can download from the file “AStudio6_2sp2_1563.exe” http://www.atmel.com/tools/atmelstudio.aspx or get a copy from the Microprocessor Laboratory.

2. You should also have the following files that can be obtained from the Microprocessor Laboratory.

a. Atmega32 Reference manual.pdf b. AVR-Instruction-Set.pdf c. Instruction Set Summary.pdf d. AVR Assembler User Guide.pdf e. Lab1 Appendix.pdf

3. Print a hardcopy of the program in Figure A.17(A5), pp 329 – 331 of the “Atmega32 Reference manual.pdf”, all pages of AVR Assembler User Guide.pdf and “Lab1 Appendix.docx”. Have it available at all time while doing Pre-Lab and Laboratory session.

For the files “Atmega32 Reference manual.pdf” and “AVR-Instruction-Set4.pdf”, you may have it handy on a computer or tablet for quick and convenient reference at any time by using the search feature.

4. Referring section A.17 in Step A(5), write the program “Lab1Pre.asm” given in Figure A.17(A5) of “Lab1 Appendix” on Atmel Studio 6.

For clarity of reading the program during debugging process, it is advisable that you do not copy the lengthy comments given in the program but write short comment (using your own word) if possible only on the line of the instruction.

The comments are given as reference for you understand the operation of program which you can refer to from the hardcopy that you have printed.

Use Section A.1 through A.9 of file “Lab1 Appendix.pdf” as reference for the theory on the exercise example in section A.16 through A.24.

Exercise example in section A.16 through A.24 that must be completed in order for you complete this laboratory session.

5. Referring to Section Figure A.18 Step (A7) of “Lab1 Appendix” select the target of program as Simulator.

Page 3: SKEE3732 uP Laboratory 1 Sheet 20152016-1 (updated 210915).pdf

SKEE3732 uP Laboratory 1 Sheet 20152016-1 (updated).docx 3

6. Referring to program “Lab1Pre.asm”, fill the empty blanks in the Table 1 by referring to the following list reference.

Column

Number

Objective Reference

2

(Labels for

instruction)

To determine address of label in the Program Memory

Section A.19 of file “Lab1 Appendix.pdf”

2

(Labels for

Data)

To determine label address in Data Memory

Section A.23 Step A12 of file “Lab1 Appendix.pdf”

5 To determine Result of Instructions executions

Section A.8 of file “Lab1 Appendix.pdf” “AVR-Instruction-Set.pdf” or “Instruction Set Summary.pdf” 6 To determine Flags in Status

Register that changed

7 To determine Addressing modes

Section A.7 of file “Lab1 Appendix.pdf” and “AVR-Instruction-Set.pdf”

8 To determine Instruction Execution Cycle

Section A.8 (f) of file “Lab1 Appendix.pdf”

Note: Filling in column 4 and 5 may be difficult initially so to overcome this you may debug

the program (by single-stepping), observe result by referring to the instruction set

specification, and after that try entering the result using your mental evaluation. It is very

crucial for you to be able to determine the result through your manual evaluation by

referring to the Instruction Set reference.

7. Referring to program “Lab1Pre.asm”, Fill in Table 3, the final result of each process identified in in the program given in Figure A.29 of “Lab1 Appendix”. GPR’ that are used and intermediate temporary storage should be omitted. Give value of content of register/memory locations in hexadecimal number. Process 1 and 8 are pre-filled for your guidance. The specific register/memory location of the respective process is given for your guidance.

8. Referring to program “Lab1Pre.asm”, calculate the operation times taken to complete Process 10 commented in the program, by referring to section A.29 of “Lab1 Appendix”. Show the solution workings.

Hint: Refer Table. 1 for execution time of instructions that complete Process 10. There are instructions that go through a loop whose total execution time has to be multiplied by the numbers repeats in the loop. Note that execution time of BRNE instruction depend whether the condition is TRUE or FALSE.

Page 4: SKEE3732 uP Laboratory 1 Sheet 20152016-1 (updated 210915).pdf

SKEE3732 uP Laboratory 1 Sheet 20152016-1 (updated).docx 4

II. LABORATORY SHEET

1 Title: Using the AVR Studio 6

2 Objective:

To use AVR Studio 6 debugging methods:

1. To determine the address of labels and instruction in an ATmega32A program

2. To identify and inspect contents of ATmega32A Processor Registers, Program Memory and

SRAM on the AVR Studio 6.2 Simulator on Debugging mode.

3. To identify the Addressing Modes operation of various ATmega32A instruction on the AVR

Studio 6.2 Simulator on Debugging mode.

4. To prove the calculation/deduction for the execution an instruction, and of a loop process.

5. To describe (with evidence) the operation complete by the process identified the program

given in Figure A.17(A5) of “Lab1 Appendix”

3 Equipment/Software/Reference:

1. A computer system running Windows XP or Window Vista or Window 7.

2. AVR Studio 6.2 installed on the system

3. Reference 1 – Atmega32 Reference manual

4. Reference 2 - AVR-Instruction-Set

5. Reference 3- AVR Assembler User Guide

All softcopy of documents and software can be sourced at the Microprocessor Laboratory at P04-

420.

4 Procedures

Note: You must complete Preliminary Preparation before proceeding this section. Make sure

that AVR Studio 6.2 has been installed on your Window PC.

1. By referring to Section A.20 of “Lab1 Appendix”, debug the program write the program given

in Figure A.17(A5) in “Lab1 Appendix” on Atmel Studio 6 (assuming you have solved all errors

if any) by tracing through the program and fill Table 2. You will need to restart program

multiple time to fill the table so use Breakpoint when necessary

2. By referring process #, take snap shots of relevant registers/memory locations affected

before the process and after the process complete. These snapshots can be used as the

secondary result complementing Table 2 to support “Discussion” materials in of your report.

3. Referring to A.29(c) of “Lab1 Appendix” verify the Calculated Execution Time determined in

section 7 of Preliminary Preparation.

Page 5: SKEE3732 uP Laboratory 1 Sheet 20152016-1 (updated 210915).pdf

SKEE3732 uP Laboratory 1 Sheet 20152016-1 (updated).docx 5

5 Result to be Taken:

For Procedure 1: Fill Table 2

For Procedure 2:

Give evidence of the final result of each process (11 process total) identified in the program and

in Table 3 that you have completed in the Preliminary Preparation. Highlight Register/Memory

location affected the by completion of the process in snapshot taken. Result for Process 1 and

Process 8 is given below for your guidance. You can trace through (single stepping) or use break

point to stop at the beginning of each process (which is also the end of the previous process).

However what view to snapshot depends on what you need to read. The snapshot of the PC that

identifies the instance of the overall result must also be taken.

Example 1 (in Procedure 2) :

For Process 1 Register/Memory location affected is PC and SP (also Indicated in

column 5 of table 1 covering instruction 2, 3, 4 and 5), so you are needed to give the

snap shot of content SP with PC for their condition just before the process (PC should

be = 000A) starts and their condition just after the process ends. Value of R16 is not

required because it is not the ultimate objects affected in the process but just used as

a temporary storage,

PC and SP before Process #1 start

and the snap shot of content SP with PC (highlighted in red identified as the subject)

after the process 1 (PC should be = 000E) complete

PC and SP after Process #1 complete

Page 6: SKEE3732 uP Laboratory 1 Sheet 20152016-1 (updated 210915).pdf

SKEE3732 uP Laboratory 1 Sheet 20152016-1 (updated).docx 6

Example 2 (in Procedure 2):

For Process 8, the snap shot of content memory at address $0080 thru $0084 and PC

(highlighted in red identified as the subject) before the process (PC should be = 0024)

and the snap shot of content memory at address $0080 thru $0084 with PC

(highlighted in red identified as the subject) after the process 1 (PC should be = 0030)

completes.

Page 7: SKEE3732 uP Laboratory 1 Sheet 20152016-1 (updated 210915).pdf

SKEE3732 uP Laboratory 1 Sheet 20152016-1 (updated).docx 7

For Procedure 3:

1. Select Debug Stop Debugging (if in Debugging mode)

2. Select Debug Start Debugging and Break

3. Select Debug Clear all Breakpoint (just in case there are breakpoints set elsewhere)

4. Set Breakpoint at first instruction of Process 10 (“ldi ZH,high(numbers1<<1)”),

5. Open Precessor View and read Cycle Counter. Should be 0 because you have not run anything

yet.

6. Select Debug continue

7. Read Cycle Counter. Print snapshot

8. Set Breakpoint at first instruction of after Process 10 (“rjmp here”),

9. Select Debug continue

10. Read Cycle Counter. Print snapshot

11. Total execution = (Cycle counter at end of Process 10) – Cycle (counter at beginning of

Process 10)

6 Preparation for Discussion:

Describe/Discuss all result taken above.

For 5(e) describe (which are explained in comment fields) each process (Process 1 through 8)

identified in the given in Figure A.17(A5) of “Lab1 Appendix” by using diagram showing the

movement of data that implement the process. Refer to diagram can be taken from during

snapshot in results during debugging process of the program.

a. Identify any labels used that represent memory location or constant.

b. Identify any ATmega32A Processor Register used as intermediate storage, pointer to

locations.

c. Identify Addressing Modes used.

d. To prove the calculation/deduction for the execution an instruction, and of a loop process.

Discussion Example:

In Process #1, SPis initialise the 16 bit value of label RAMEND which is defined in

“m32Adef.inc” taken by using R16 as the intermediate register. Immediate addressing mode is

used to load the low(RAMEND) data then high(RAMEND) into R16, and I/O Direct addressing

mode is used to store data into the SPL and SPH from R16.

…………………………

Page 8: SKEE3732 uP Laboratory 1 Sheet 20152016-1 (updated 210915).pdf

SKEE3732 uP Laboratory 1 Sheet 20152016-1 (updated).docx 8

Process # 8, shows how a series of 5 addresses $80,81,82,83 and 84, the 5 byte array which

are pointed by label numbers3 which was initialize with 0a, 0b, 0c, 0d, and 0e respectively.

Repetitive sequential executions of Immediate and register indirect with post increment

instructions are used 5 times to implement the process. R16 is used as the intermediate

register.

.

…………………………

You will notice the different method of transferring data in the program. Discuss them

7 Conclusion

Conclude you report by citing facts given in result and discussion. You do not conclude by just t

writing “Objective achieve” referring/citing evidence that should be given in Result and

Discussion.

Example (do not copy- use your own word),

By using label, we are relief of ………… (of what?). If we need to find the value of label we….

(find where).

Transferring data from constants is quite straightforward ……(why?). However there are need

to transfer data from memory to register, memory to memory ……..(give other examples and

explained how is it implemented).

To transfer and series of data (identify the method used….. (compare using sequential method

vs using loops).

…………

Page 9: SKEE3732 uP Laboratory 1 Sheet 20152016-1 (updated 210915).pdf

SKEE3732 uP Laboratory 1 Sheet 20152016-1 (updated).docx 9

8 Report Writing:

For Short Report:

Date of Laboratory Experiment

Make/Model/Serial No. of Machine or Platform/OS version of computer/software used must be

given.

Theory: Just give titles relevant theory material used in the laboratory experiment.

Procedure: Report step taken to fulfill requirement in objectives including design of program to fulfill

objective. Use flowchart if necessary. Procedure may be summarized.

Result: Report all result with evidences specified this laboratory sheet by taking snapshots of relevant

Codes, Register, or Memory windows.

Discussion: Discuss technically on the procedures taken and result observed based on Objectives,

Theories and Results.

Conclusion: Give Conclusion based on Objectives, Theories, Procedures, Results and Discussions.

Important: A general statement saying without supporting evidence will cause deduction of marks.

For Long Report:

Date of Laboratory Experiment

Make/Model/Serial No. of Machine or Platform/OS version of computer/software used must be

given.

Theory: A summary of the relevant theory material used in the laboratory experiment. Irrelevant and

massive material that is a cut and paste from the internet will leads to deductions of mark.

Procedure: Give brief description of the steps taken by numbering steps.

Result: Report all result (citing the step number in Procedure) with evidences specified this laboratory

sheet by taking snapshots of relevant Codes, Register, or Memory windows based on objectives.

Discussion: Discuss technically on the procedures taken and result observed based on Objectives,

Theories and Results.

Conclusion: Give Conclusion based on Objectives, Theories, Procedures, Results and Discussions.

Important: A general statement saying without supporting evidence will be cause deduction of marks.

Example of general statement for Conclusion which is not accepted:

The objective was successfully done

Do no cut and paste materials from sample report. Learn from the sample report.

Page 10: SKEE3732 uP Laboratory 1 Sheet 20152016-1 (updated 210915).pdf

SKEE3732 uP Laboratory 1 Sheet 20152016-1 (updated).docx 10

Table 1 Pre-Lab Table to be filled. Some boxes are pre-filled for your guidance. By referring to program in Figure A.17(A5) of Lab1 Appendix manually enter the empty blanks. The Shaded box need not be filled.

Before Entering value you must Create the project for the program, enter into debugging mode, and view the disassembly of the program.

For Clarity of reading in the disassembly view, it is suggested that you remove all comment and just enter the instructions of the program. You My refer to Figure A.17(A5) if you need to refer to comments in the program.

In the disassembly mode read (obtain) the addresses of each instruction to be filled in the "Address of Instruction/Label of Memory location" column.

By referring to "AVR-Instruction-Set 2002.pdf" fill the "Register/Memory that will be changed by execution of instruction" column, the "# of Cycle for Instruction Execution" column and the "Status Register" column.

All numbers in Registers, Memory and Address are in Hexadecimal (the "$" or "0x" prefix character is omitted).

Referring to "AVR-Instruction-Set.pdf" the "Status Register" is on changed by certain specific instruction and in some of this instruction does not change all the flags in the Status Register.

For Flags in Status Register (SR) that is not changed from the execution of a instruction, insert dashes ("-") on the respective Flag column (so you will be able to identify which Flag changes).

1 2 3 4 5 6 7 8

Instruction #

Address of Instruction/ Data Labels

(Hex)

Label Instruction/ Directive

Result of Instructions

executions/Assembler Directive (numbers

in Hex)

Status Register (Only fill Flags that changed )

Addressing mode (Refer section A.7(c) in "Lab1

Appendix")

Instruction Execution

Cycle (Refer

Section A.8 (f) in "Lab1

Appendix") H S V N Z C

"ten" will not be assembled into CPU memory ten .equ ten = 10 label "ten" = 0A

Assembler will takes value 10 when it sees label "ten" since "ten" is declared as value 10.

.CSEG Code declared below ".CSEG" statement will be located inProgram memory:

Initial Conditions: Contents of Registers and Data Memory locations = 00 0 0 0 0 0 0

.org 0 Code declared below ".org 0x0" starts at address:

1 0000 reset: jmp start PC = 000A - - - - - - Direct Program 3

.org 0xA Code declared below ".org 0x0" starts at address 0x000A

2 000A start: ldi R16,low(RAMEND) R16 = 5F - - - - - - Immediate 1

3 000B out SPL,R16 SP =005F - - - - - - I/0 Direct 1

4 000C ldi r16,high(RAMEND) R16 = 5F - - - - - - 1

5 000D out SPH,R16 SP = 085F - - - - - - 1

6 ldi r17,$2a Immediate 1

7 sts num1,r17 Direct 2

8 lds r17,num1 2

9 sts temp1,r17 2

Page 11: SKEE3732 uP Laboratory 1 Sheet 20152016-1 (updated 210915).pdf

SKEE3732 uP Laboratory 1 Sheet 20152016-1 (updated).docx 11

10 lds r0,num1 Direct 2

11 lds r1,temp1 r1=2A - - - - - - Direct 2

12 add r0,r1 r0=54 0 0 0 0 0 0 Two Register 1

13 ldi r16,5 r16=05 - - - - - - Immediate 1

14 add r0,r16 Two Register 1

15 sts sum,r0 Direct 2

16 ldi YL,low(numbers3) Immediate 1

17 ldi YH,high(numbers3) Immediate 1

18 ldi r16,$53 Immediate 1

19 st Y,r16 Indirect 2

20 ldi r16,$35 Immediate 1

21 std Y+3,r16 Indirect with displacement

2

22 ldi XL,low(numbers3) Immediate 1

23 ldi XH,high(numbers3) Immediate 1

24 ldi r20,ten Immediate 1

25 st X+,r20 (80)=10,X=81 - - - - - -

2

26 inc r20 r20=11 0 0 0 0 0 - 1

27 st X+,r20 2

28 002A inc r20 1

29 002B st X+,r20 2

30 002C inc r20 1

31 002D st X+,r20

32 002E inc r20

33 002F st X+,r20

34 0030 ldi XL,low(numbers2+4) Immediate 1

35 0031 ldi XH,high(numbers2+4) Immediate 1

36 0032 ldi YL,low(numbers3) Immediate 1

37 0033 ldi YH,high(numbers3) Immediate 1

38 0034 ld r16,Y+ R16=10,Y=0081 - - - - - - Indirect with

post increment 2

Page 12: SKEE3732 uP Laboratory 1 Sheet 20152016-1 (updated 210915).pdf

SKEE3732 uP Laboratory 1 Sheet 20152016-1 (updated).docx 12

39 0035 st -X,r16 X=67,(0067)=10 - - - - - -

2

40 0036 ld r16,Y+ Indirect with post increment

2

41 st -X,r16 2

42 ld r16,Y+ Indirect with post increment

2

43 st -X,r16 2

44 ld r16,Y+ Indirect with post increment

45 st -X,r16

46 ldi ZH,high(numbers1<<1) Immediate

47 ldi ZL,low(numbers1<<1) Immediate

48 ldi YH,high(numbers4) Immediate 1

49 ldi YL,low(numbers4) Immediate 1

50 ldi r17,4 Immediate 1

51 repeat: lpm r18,Z+ 3

52 st Y+,r18 2

53 dec r17 1

54 brne repeat 1

55 here: rjmp here Relative Program 2

Page 13: SKEE3732 uP Laboratory 1 Sheet 20152016-1 (updated 210915).pdf

SKEE3732 uP Laboratory 1 Sheet 20152016-1 (updated).docx 13

.org $50 Code declared below ".org 0x50" starts at address 0x0050

$0050 SS_table: .db $3f,$06,$5b,$4f,$66,$6d,$7d, $03, $7f, $6f

Refer section A.3(b) in "Lab1 Appendix" for

theory of byte size data locations in Program

Memory when accessed by the CPU (using Pointer

Register Z)

Absolute Address seen by Pointer Register Z if LPM is used

Content of SS_table

$00A0 3f

Refer section A.22(b) in "Lab1 Appendix" to read data from View Memory window

$00A1

$00A2

$00A3

$00A4

$00A5

$00A6

$00A7

$00A8

$00A9

$0055 numbers1: .db 0x10, 0x1,0x12,0x3,0x14,0x15,0x6,0x7,0x18,0x9

Refer section A.3(b) in "Lab1 Appendix" for

theory of byte size data locations in Program

Memory when accessed by the CPU (using Pointer

Register Z)

Absolute Address seen by Pointer Register Z if LPM is used

Content of numbers1 array

Refer section A.22(b) in "Lab1 Appendix" to read data from View Memory window

14

$00B3

Page 14: SKEE3732 uP Laboratory 1 Sheet 20152016-1 (updated 210915).pdf

SKEE3732 uP Laboratory 1 Sheet 20152016-1 (updated).docx 14

.DSEG Locations declared below ".DSEG" statement will be located in SRAM

Default address of next statement below begins at:

num1: .byte 1 1

Size (in bytes) of variable reserved (decimal value)

num2: .byte 1 1

data1: .byte 1 1

data2: .byte 1 1

numbers2: .byte 7 7

endofnumbers2: .byte 1 1

.org 0x80 Address of next statement below begins at:

0080 numbers3: .byte 6

Size (in bytes) of variable reserved (decimal value)

0086 numbers4: .byte $10

0096 temp1: .byte 1

0097 temp2: .byte 1

0098 sum: .byte 1

Page 15: SKEE3732 uP Laboratory 1 Sheet 20152016-1 (updated 210915).pdf

SKEE3732 uP Laboratory 1 Sheet 20152016-1 (updated).docx 15

Table 2: Result Table by Debugging the Program

To execute Single stepping from RESET select Debug --> Start Debugging and Break.

Anytime if you need to restart debugging process that initialize register and SRAM, select Debug --> Stop Debugging and then select Debug --> Start Debugging and Break.

In debug Mode, read the CPU Frequency From Processor Window

CPU Clock Frequency: CPU Clock period

Single Step (Strike F11) through the program until the PC (the program) reaches "here: rjmp here" address.

At each "Single Step" count read the content of PC and write in the respective "Content of PC before Single Stepping" column.

After each "Single stepping" of the "Single Step" count,write the register/memory location changed effected by the execution of the instruction. You may need to refer to the Instruction Set Summary. Some Readings are entered for your quidance.

All Numbers in Registers, Memory and Address is in Hexadecimal (the "$" or "0x" prefix character is omitted)

If Instruction to not change the Status Register keep empty on the respective Starus Register column (so you will be able to identify which instruction execution changes the SR).

For certain Flags in Status Register (SR) that is not changed from the execution of a instruction, insert dashes ("-") on the respective Flag column (so you will be able to identify which Flag changes).

For Program Flow Control Instructions, if it modified PC (CPU will Branch), show content of PC. Othewise do not shown content of PC because by default it will takes address of next instruction.

Single Step #

Content of PC before "Step Over"

Program Codes from Source File "Lab1Pre.asm"

Result after Single Stepping

Register/Memory location changed after "Single Stepping"

Status Register (Flags that changed "Step

Over")

Cycle Counter (dec)

Instruction Execution Cycle

Instruction Execution Time (μs)

Label Instruction/ Directive H S V N Z C

ten .equ ten = 10 ten = 10

In Program memory .CSEG

Initial Conditions All Registers and Data Memory locations = 00 0 0 0 0 0 0

1 0000 reset: jmp start PC = 000A 0 0 0 0 0 0 0 3

2 000A start: ldi R16,low(RAMEND) R16 = 5F 0 0 0 0 0 0 3

3 000B out SPL,R16 SP =005F 0 0 0 0 0 0 4

4 000C ldi r16,high(RAMEND) R16 = 5F 0 0 0 0 0 0 5

5 000D out SPH,R16 SP = 085F 0 0 0 0 0 0 6

6 000E ldi r17,$2a R17 = 2A 0 0 0 0 0 0 7

7 000F sts num1,r17 (0060) = 2A 0 0 0 0 0 0 8

8 0011 lds r17,num1 r17=2A 0 0 0 0 0 0 10

9 0013 sts temp1,r17 (0096)=2A 0 0 0 0 0 0 12

Page 16: SKEE3732 uP Laboratory 1 Sheet 20152016-1 (updated 210915).pdf

SKEE3732 uP Laboratory 1 Sheet 20152016-1 (updated).docx 16

10 0015 lds r0,num1 r0=2A 0 0 0 0 0 0 14

11 0017 lds r1,temp1 r1=2A 16 2

12 0019 add r0,r1 r0=54 18 1

13 001A ldi r16,5 r16=05 19 1

14 001B add r0,r16 r0=59 20 1

15 001C sts sum,r0 (0098)=59 21 2

16 001E ldi YL,low(numbers3) Y=0080 0 0 0 0 0 0 23 1

17 001F ldi YH,high(numbers3) Y=0080 0 0 0 0 0 0 24 1

18 0020 ldi r16,$53 r16=53 0 0 0 0 0 0 25 1

19 0021 st Y,r16 (0080)=53 0 0 0 0 0 0 26 2

20 0022 ldi r16,$35 r16=35 0 0 0 0 0 0 28 1

21 0023 std Y+3,r16 (0083)=35 0 0 0 0 0 0 29 2

22 0024 ldi XL,low(numbers3) X=0080 0 0 0 0 0 0 31 1

23 0025 ldi XH,high(numbers3) y=0080 0 0 0 0 0 0 32 1

24 0026 ldi r20,ten r20=10 0 0 0 0 0 0 33 1

25 0027 st X+,r20 (80)=10,X=81 0 0 0 0 0 0 34 2

26 0028 inc r20 r20=11 36 1

27 0029 st X+,r20 (81)=11,X=82 37 2

28 002A inc r20 r20=12 39 1

29 002B st X+,r20 (82)=12,X=83 40 2

30 002C inc r20 r20=13 42 1

31 002D st X+,r20 (83)=13,X=84 43 2

32 002E inc r20 r20=14 45 1

33 002F st X+,r20 (83)=14,X=85 46 2

34 0030 ldi XL,low(numbers2+4) X=0068 0 0 0 0 0 0 48 1

35 0031 ldi XH,high(numbers2+4) X=0068 0 0 0 0 0 0 49 1

36 0032 ldi YL,low(numbers3) Y=0080 0 0 0 0 0 0 50 1

37 0033 ldi YH,high(numbers3) Y=0080 0 0 0 0 0 0 51 1

38 0034 ld r16,Y+ R16=10,Y=0081 0 0 0 0 0 0 52 2

39 0035 st -X,r16 X=67,(0067)=10 0 0 0 0 0 0 54 2

40 0036 ld r16,Y+ R16=11,Y=0082 0 0 0 0 0 0 56 2

41 0037 st -X,r16 X=66,(0066)=11 0 0 0 0 0 0 58 2

42 0038 ld r16,Y+ R16=12,Y=0083 0 0 0 0 0 0 60 2

43 0039 st -X,r16 X=65,(0065)=12 0 0 0 0 0 0 62 2

44 003A ld r16,Y+ R16=13,Y=0084 0 0 0 0 0 0 64 2

45 003B st -X,r16 X=64,(0064)=13 0 0 0 0 0 0 66 2

46 003C ldi ZH,high(numbers1<<1) Z=00AA 0 0 0 0 0 0 68 1

47 003D ldi ZL,low(numbers1<<1) Z=00AA 0 0 0 0 0 0 69 1

48 003E ldi YH,high(numbers4) Y=0086 0 0 0 0 0 0 70 1

Page 17: SKEE3732 uP Laboratory 1 Sheet 20152016-1 (updated 210915).pdf

SKEE3732 uP Laboratory 1 Sheet 20152016-1 (updated).docx 17

49 003F ldi YL,low(numbers4) Y=0086 0 0 0 0 0 0 1

50 0040 ldi r17,4 R17=4 0 0 0 0 0 0 1

0041 repeat: lpm r18,Z+ R18=10,Z=00AB 0 0 0 0 0 0 3

0042 st Y+,r18 (0086)=10,Y=0087 0 0 0 0 0 0 2

0043 dec r17 R17=3 0 0 0 0 0 0 1

0044 brne repeat Z<>1, PC=0041 0 0 0 0 0 0 2

0041 repeat: lpm r18,Z+ 3

0042 st Y+,r18 2

0043 dec r17 1

0044 brne repeat 2

51 0041 repeat: lpm r18,Z+ 3

52 0042 st Y+,r18 2

53 0043 dec r17 1

54 0044 brne repeat 2

0041 repeat: lpm r18,Z+ 3

0042 st Y+,r18 2

0043 dec r17 1

0044 brne repeat

1

55 0045 here: rjmp here PC = 0045

.org $50

SS_table: .db $3f,$06,$5b,$4f,$66,$6d,$7d, $03, $7f, $6f

numbers1: .db 0x10, 0x1,0x12,0x3,0x14,0x15,0x6,0x7,0x18,0x9

Data taken from Prelab

Address seen by Pointer Register Z

Content of SS_table

$00A0 3f

$00A1 06

$00A2 5B

$00A3 4F

$00A4 66

$00A5 6D

$00A6 7D

$00A7 03

$00A8 7F

$00A9 6F

$0055 numbers1: .db 0x10, 0x1,0x12,0x3,0x14,0x15,0x6,0x7,0x18,0x9

Page 18: SKEE3732 uP Laboratory 1 Sheet 20152016-1 (updated 210915).pdf

SKEE3732 uP Laboratory 1 Sheet 20152016-1 (updated).docx 18

Data taken from Prelab

Address seen by Pointer Register Z

Content of numbers1 array

In Data memory .DSEG

0060 num1: .byte 1

0061 num2: .byte 1

0062 data1: .byte 1

0063 data2: .byte 1

0064 numbers2: .byte 7

006B endofnumbers2: .byte 1

.org 0x80

0080 numbers3: .byte 6

0086 numbers4: .byte $10

0096 temp1: .byte 1

0097 temp2: .byte 1

0098 sum: .byte 1

Page 19: SKEE3732 uP Laboratory 1 Sheet 20152016-1 (updated 210915).pdf

SKEE3732 uP Laboratory 1 Sheet 20152016-1 (updated).docx 19

Table 3 Pre-Lab Table to be filled. Some boxes are pre-filled for your guidance.

Process No Final Result

1 Register Content

SP 085F

2

Address Content

0x0060

3

Address Content

4

Address Content

5

Register Content

6

Address Content

0x0080

7

Address Content

35

8 Address Content

0x0080

0x0081

0x0082

0x0083

0x0084

9 Address Content

10 Address Content

11

Register Content

PC Hint: You can find the value of address “here” from the Disassembly View