Lab1: Using ECLIPS Environment · 2019. 10. 6. · Ibrahim Hazmi | ECE 255 LAB 1 What is a...

Post on 12-Dec-2020

1 views 0 download

Transcript of Lab1: Using ECLIPS Environment · 2019. 10. 6. · Ibrahim Hazmi | ECE 255 LAB 1 What is a...

Ibrahim Hazmi | ECE 255 LAB

Lab1: Using ECLIPS Environment

ECE 255 - iHaz - 2019

1

ECE 255 LAB Lab Introduction to Computer Architecture

Ibrahim Hazmi | ECE 255 LAB

IBRAHIMHAZMI

Contact me at:Email: ihaz@uvic.ca

My UVic Blog:https://onlineacademiccommunity.uvic.ca/ihaz/

CENG 255 B01 TA

2

Ibrahim Hazmi | ECE 255 LAB

1 What is a cross-assembler? (0.5)An assembler that converts mnemonics to binary opcodes, other than the host machine’s2 What is an exception? (0.5)

A change of control flow from the current program execution due to errors, interrupts, … etc.4 Comment on the program in 1.4.2 (1) (What it does) (0.5)5 Comment on the program in 1.4.3 (1) (What it does) (0.5)

Pre-Lab Answers

3

Ibrahim Hazmi | ECE 255 LAB

OpCode!

Add/Sub0 0 0 1 1 0 I Rn Rs Rd

0 0 0 1 1 0 0R5 R4 R0

1 0 1 1 0 0 0 0 01 9 6 0

0 0 0 1 1 0 1R5 R4 R0

1 0 1 1 0 0 0 0 01 B 6 0

Add Rd, Rs, Rn (I=0) Sub Rd, Rs, Rn (I=1)

Move/Cmp/Add/Sub0 0 1 Op Rd Offset8/Immediate

0 0 1Mov R0 50 0 0 0 0 0 0 0 0 0 1 0 1

2 0 0 5

0 0 1Cmp R0 50 1 0 0 0 0 0 0 0 0 1 0 1

2 8 0 5

Mov Rd, offset (Op=00) Cmp Rd, Rn/Offset (Op=01)Add Rd, Rs, Rn (Op=10) Sub Rd, Rs, Rn (Op=11)

4

Hex value for ‘sub r0, r4, r5’ ? (Op = 1)

Ibrahim Hazmi | ECE 255 LAB 5

https://www.ece.uvic.ca/~ece255/lab/

LAB WEB-PAGE

Ibrahim Hazmi | CENG 255 LAB Ibrahim Hazmi | ECE 255 LAB

Part1

Import an existing project to Eclipse View and Read Memory after downloading the executable binary file to the ARM board. Change the content of the Memory with address “0x2000146” to a “SUBTRACT”

Part2Describe the function of the .asm Program Build and Debug the project, then Examine the contents of the Memory and Registers

Part3

Program function and listingMemory & Registers before & after executionChange the program for 32 elements, and Check for limitation

The Lab Task

6

Ibrahim Hazmi | ECE 255 LAB

Lab Hardware Settings!

7

Before starting our lab, let’s explore Assembly

Ibrahim Hazmi | CENG 255 LAB Ibrahim Hazmi | ECE 255 LAB

How the Assembly code looks

}

{___

{

__ __ __

__ __ __ __

Comments

Directives (Assembler)

Instructions

Label

} Operands________

____

Now let’s get back to instruction types

8

Ibrahim Hazmi | CENG 255 LAB Ibrahim Hazmi | ECE 255 LAB

How Debug mode looks ?

9

Ibrahim Hazmi | ECE 255 LAB

Instruction Types

ALU & REG

ADD/SUB

CMP

AND/OR

MEM & REG

MOV

STORE (ST)

LOAD (LD)

PROG. FLPW

BRANCH

BL

BE

10

Ibrahim Hazmi | ECE 255 LAB

How instructions are executed in ARM

Reg Content

r0r1r2r3r4r5r6r7

SPLRPC

Address Data

RAM

CPSRN Z C V

Regiters

ALUN

ZC

OOp

n1 n2

Result

data

instructions

11

Ibrahim Hazmi | ECE 255 LAB

How instructions are executed in ARM

Reg Content

r0r1 00001000

r2r3r4r5r6r7

SPLRPC 2000AA02

Address Data

00001000 1500001004 10

2000AA00 ldr r1, =l1

2000AA02 ldr r2, =l2

2000AA04 ldr r3, [r1]

2000AA06 ldr r4, [r2]

2000AA08 add r0, r4, r3

2000AA0A sub r0, r4, r3

2000AA0C str r0, [r1]

2000AA0E

2000XXXX xxxxxx

2000XXXX xxxxxx

RAMCPSRN Z C V

Regiters

L1L2

12

Assembly Codeldr ldr ldr ldr

add sub str

r1, =l1 r2, =l2 r3, [r1] r4, [r2]

r0, r4, r3 r0, r4, r3 r0, [r1]

Ibrahim Hazmi | ECE 255 LAB

How instructions are executed in ARM

Reg Content

r0r1 00001000

r2 00001004

r3r4r5r6r7

SPLRPC 2000AA04

Address Data

00001000 1500001004 10

2000AA00 ldr r1, =l1

2000AA02 ldr r2, =l2

2000AA04 ldr r3, [r1]

2000AA06 ldr r4, [r2]

2000AA08 add r0, r4, r3

2000AA0A sub r0, r4, r3

2000AA0C str r0, [r1]

2000AA0E

2000XXXX xxxxxx

2000XXXX xxxxxx

RAM

Assembly Codeldr ldr ldr ldr

add sub str

r1, =l1 r2, =l2 r3, [r1] r4, [r2]

r0, r4, r3 r0, r4, r3 r0, [r1]

CPSRN Z C V

Regiters

L1L2

13

Ibrahim Hazmi | ECE 255 LAB

How instructions are executed in ARM

Reg Content

r0r1 00001000

r2 00001004

r3 15r4r5r6r7

SPLRPC 2000AA06

Address Data

00001000 1500001004 10

2000AA00 ldr r1, =l1

2000AA02 ldr r2, =l2

2000AA04 ldr r3, [r1]

2000AA06 ldr r4, [r2]

2000AA08 add r0, r4, r3

2000AA0A sub r0, r4, r3

2000AA0C str r0, [r1]

2000AA0E

2000XXXX xxxxxx

2000XXXX xxxxxx

RAM

Assembly Codeldr ldr ldr ldr

add sub str

r1, =l1 r2, =l2 r3, [r1] r4, [r2]

r0, r4, r3 r0, r4, r3 r0, [r1]

CPSRN Z C V

Regiters

L1L2

14

Ibrahim Hazmi | ECE 255 LAB

How instructions are executed in ARM

Reg Content

r0r1 00001000

r2 00001004

r3 15r4 10r5r6r7

SPLRPC 2000AA08

Address Data

00001000 1500001004 10

2000AA00 ldr r1, =l1

2000AA02 ldr r2, =l2

2000AA04 ldr r3, [r1]

2000AA06 ldr r4, [r2]

2000AA08 add r0, r4, r3

2000AA0A sub r0, r4, r3

2000AA0C str r0, [r1]

2000AA0E

2000XXXX xxxxxx

2000XXXX xxxxxx

RAM

Assembly Codeldr ldr ldr ldr

add sub str

r1, =l1 r2, =l2 r3, [r1] r4, [r2]

r0, r4, r3 r0, r4, r3 r0, [r1]

CPSRN Z C V

Regiters

L1L2

15

Ibrahim Hazmi | ECE 255 LAB

How instructions are executed in ARM

Reg Content

r0 25r1 00001000

r2 00001004

r3 15r4 10r5r6r7

SPLRPC 2000AA0A

Address Data

00001000 1500001004 10

2000AA00 ldr r1, =l1

2000AA02 ldr r2, =l2

2000AA04 ldr r3, [r1]

2000AA06 ldr r4, [r2]

2000AA08 add r0, r4, r3

2000AA0A sub r0, r4, r3

2000AA0C str r0, [r1]

2000AA0E

2000XXXX xxxxxx

2000XXXX xxxxxx

RAM

Assembly Codeldr ldr ldr ldr

add sub str

r1, =l1 r2, =l2 r3, [r1] r4, [r2]

r0, r4, r3 r0, r4, r3 r0, [r1]

CPSRN Z C V0 0 0 0

Regiters

L1L2{

16

ALUN

ZC

O Sub

n1 n2

Result

Ibrahim Hazmi | ECE 255 LAB

How instructions are executed in ARM

Reg Content

r0 -5r1 00001000

r2 00001004

r3 15r4 10r5r6r7

SPLRPC 2000AA0C

Address Data

00001000 1500001004 10

2000AA00 ldr r1, =l1

2000AA02 ldr r2, =l2

2000AA04 ldr r3, [r1]

2000AA06 ldr r4, [r2]

2000AA08 add r0, r4, r3

2000AA0A sub r0, r4, r3

2000AA0C str r0, [r1]

2000AA0E

2000XXXX xxxxxx

2000XXXX xxxxxx

RAM

Assembly Codeldr ldr ldr ldr

add sub str

r1, =l1 r2, =l2 r3, [r1] r4, [r2]

r0, r4, r3 r0, r4, r3 r0, [r1]

CPSRN Z C V1 0 0 0

Regiters

L1L2

#517

ALUN

ZC

O Sub

n1 n2

Result

Ibrahim Hazmi | ECE 255 LAB

How instructions are executed in ARMAddress Data

00001000 -5 (FFFFFFFB)00001004 10 (0000000A)

2000AA00 ldr r1, =l1

2000AA02 ldr r2, =l2

2000AA04 ldr r3, [r1]

2000AA06 ldr r4, [r2]

2000AA08 add r0, r4, r3

2000AA0A sub r0, r4, r3

2000AA0C str r0, [r1]

2000AA0E

2000XXXX xxxxxx

2000XXXX xxxxxx

RAM

Assembly Codeldr ldr ldr ldr

add sub str

r1, =l1 r2, =l2 r3, [r1] r4, [r2]

r0, r4, r3 r0, r4, r3 r0, [r1]

L1L2

}

Reg Content

r0 -5r1 00001000

r2 00001004

r3 15r4 10r5r6r7

SPLRPC 2000AA0E

CPSRN Z C V1

Regiters

18

Ibrahim Hazmi | CENG 255 LAB Ibrahim Hazmi | ECE 255 LAB

Part1

Import an existing project to Eclipse View and Read Memory after downloading the executable binary file to the ARM board. Change the content of the Memory with address “0x2000146” to a “SUBTRACT”

Part2Describe the function of the .asm Program Build and Debug the project, then Examine the contents of the Memory and Registers

Part3

Program function and listingMemory & Registers before & after executionChange the program for 32 elements, and Check for limitation

The Lab Task

19

Ibrahim Hazmi | CENG 255 LAB Ibrahim Hazmi | ECE 255 LAB

Lab 1as

20

Ibrahim Hazmi | CENG 255 LAB Ibrahim Hazmi | ECE 255 LAB

Lab 1bs21

Ibrahim Hazmi | CENG 255 LAB Ibrahim Hazmi | ECE 255 LAB

1

Include a well-commented listing of your program. Comments should include register usage (i.e., which variables are kept in which registers), and a description of all symbols

2 Snap shots of the data section before and after execution of the program

3 Answer all questions in the lab manual!

Deliverable

22

1 Remember to backup your code always!

2 Your assembly code should start with defining your data and its space!

Advices for the lab work

Ibrahim Hazmi | CENG 255 LAB Ibrahim Hazmi | ECE 255 LAB 23

A Quick Flowchartfor How to work on

Eclipse