LAB 1 Using Visual Emulator. Download the emulator https://salmanarif.bitbucket.io/visual/downloads.html Answer to questions (Q)

Similar documents
Processor Status Register(PSR)

MNEMONIC OPERATION ADDRESS / OPERAND MODES FLAGS SET WITH S suffix ADC

ARM Instruction Set Architecture. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

Bitwise Instructions

ARM Assembly Language. Programming

ARM Assembly Programming

Chapter 2 Instructions Sets. Hsung-Pin Chang Department of Computer Science National ChungHsing University

Lecture 4 (part 2): Data Transfer Instructions

ECE 471 Embedded Systems Lecture 5

ARM Cortex-M4 Architecture and Instruction Set 2: General Data Processing Instructions

EE251: Tuesday September 5

ARM Instruction Set. Introduction. Memory system. ARM programmer model. The ARM processor is easy to program at the

Chapter 15. ARM Architecture, Programming and Development Tools

ARM Assembly Language

Basic ARM InstructionS

ARM Instruction Set. Computer Organization and Assembly Languages Yung-Yu Chuang. with slides by Peng-Sheng Chen

ECE 498 Linux Assembly Language Lecture 5

ARM Cortex M3 Instruction Set Architecture. Gary J. Minden March 29, 2016

Assembly Language. CS2253 Owen Kaser, UNBSJ

ARM Cortex-A9 ARM v7-a. A programmer s perspective Part 2

Writing ARM Assembly. Steven R. Bagley

ECE 571 Advanced Microprocessor-Based Design Lecture 3

Comparison InstruCtions

ARM Cortex-M4 Programming Model Memory Addressing Instructions

Chapters 3. ARM Assembly. Embedded Systems with ARM Cortext-M. Updated: Wednesday, February 7, 2018

ARM Processors ARM ISA. ARM 1 in 1985 By 2001, more than 1 billion ARM processors shipped Widely used in many successful 32-bit embedded systems

STEVEN R. BAGLEY ARM: PROCESSING DATA

Instruction Set Architecture (ISA)

EE319K Fall 2013 Exam 1B Modified Page 1. Exam 1. Date: October 3, 2013

ARM Cortex-M4 Programming Model Logical and Shift Instructions

ARM. Assembly Language and Machine Code. Goal: Blink an LED

ARM. Assembly Language and Machine Code. Goal: Blink an LED

University of California, San Diego CSE 30 Computer Organization and Systems Programming Winter 2014 Midterm Dr. Diba Mirza

The ARM Instruction Set

3. The Instruction Set

Overview COMP 3221 Bitwise Logical Operations

Instruction Set. ARM810 Data Sheet. Open Access - Preliminary

Worksheet #4 Condition Code Flag and Arithmetic Operations

The ARM Cortex-M0 Processor Architecture Part-2

The ARM processor. Morgan Kaufman ed Overheads for Computers as Components

ARM Cortex-M4 Programming Model Arithmetic Instructions. References: Textbook Chapter 4, Chapter ARM Cortex-M Users Manual, Chapter 3

A Bit of History. Program Mem Data Memory. CPU (Central Processing Unit) I/O (Input/Output) Von Neumann Architecture. CPU (Central Processing Unit)

Architecture. Digital Computer Design

CS 310 Embedded Computer Systems CPUS. Seungryoul Maeng

Introduction to Embedded Systems EE319K (Gerstlauer), Spring 2013

18-349: Introduction to Embedded Real- Time Systems Lecture 3: ARM ASM

(2) Part a) Registers (e.g., R0, R1, themselves). other Registers do not exists at any address in the memory map

EE319K Spring 2016 Exam 1 Solution Page 1. Exam 1. Date: Feb 25, UT EID: Solution Professor (circle): Janapa Reddi, Tiwari, Valvano, Yerraballi

ARM Shift Operations. Shift Type 00 - logical left 01 - logical right 10 - arithmetic right 11 - rotate right. Shift Amount 0-31 bits

Microcontroller Architecture and Interfacing HOMEWORK 3

CMPSCI 201 Fall 2005 Midterm #2 Solution

Exam 1 Fun Times. EE319K Fall 2012 Exam 1A Modified Page 1. Date: October 5, Printed Name:

Exam 1. Date: Oct 4, 2018

CMPSCI 201 Fall 2004 Midterm #1 Answers

Chapter 3: ARM Instruction Set [Architecture Version: ARMv4T]

Computer Architecture Prof. Smruthi Ranjan Sarangi Department of Computer Science and Engineering Indian Institute of Technology, Delhi

Hi Hsiao-Lung Chan, Ph.D. Dept Electrical Engineering Chang Gung University, Taiwan

Outline. ARM Introduction & Instruction Set Architecture. ARM History. ARM s visible registers

Chapter 15. ARM Architecture, Programming and Development Tools

ECE 471 Embedded Systems Lecture 9

Systems Architecture The ARM Processor

ECE 471 Embedded Systems Lecture 6

EE319K Spring 2015 Exam 1 Page 1. Exam 1. Date: Feb 26, 2015

CMPSCI 201 Fall 2004 Midterm #2 Answers

Overview COMP Microprocessors and Embedded Systems. Lecture 11: Memory Access - I. August, 2003

ARM7TDMI Instruction Set Reference

ENGN1640: Design of Computing Systems Topic 03: Instruction Set Architecture Design

Cortex M3 Programming

ARM Instruction Set Dr. N. Mathivanan,

Exam 1. Date: February 23, 2018

EE445M/EE380L.6 Quiz 2 Spring 2017 Solution Page 1 of 5

Solution to the Problems and Questions

Binary Logic (review)

EE319K Exam 1 Summer 2014 Page 1. Exam 1. Date: July 9, Printed Name:

Arm Processor. Arm = Advanced RISC Machines, Ltd.

ARM Processor. Based on Lecture Notes by Marilyn Wolf

Cortex-M4F Instructions used in ARM Assembly for Embedded Applications (ISBN )

ARM Architecture and Instruction Set

ARM Cortex-M4 Programming Model Flow Control Instructions

Problem Sheet 1: ANSWERS (NOT ) (NOT ) 3. 37, ,

Exam 1. Date: March 1, 2019

Developing StrongARM/Linux shellcode

Cortex-M3 Instruction Set

ARM Instruction Set 1

Advanced Assembly, Branching, and Monitor Utilities

ARM-7 ADDRESSING MODES INSTRUCTION SET

Control Flow Instructions

NET3001. Advanced Assembly

Exam 1. EE319K Spring 2013 Exam 1 (Practice 1) Page 1. Date: February 21, 2013; 9:30-10:45am. Printed Name:

The ARM Architecture T H E A R C H I T E C T U R E F O R TM T H E D I G I T A L W O R L D

ARM and the ARM Powered logo are trademarks of Advanced RISC Machines Ltd.

Introduction to the ARM Processor Using Intel FPGA Toolchain. 1 Introduction. For Quartus Prime 16.1

SIGNED AND UNSIGNED SYSTEMS

CprE 288 Introduction to Embedded Systems Course Review for Exam 3. Instructors: Dr. Phillip Jones

The ARM Instruction Set Architecture

Lecture 15 ARM Processor A RISC Architecture

COMP3221: Microprocessors and Embedded Systems

ECE 471 Embedded Systems Lecture 7

Lookup Tables Example of Arbitrary Waveform Generator

COMP2121: Microprocessors and Interfacing

Transcription:

LAB 1 Using Visual Emulator Download the emulator https://salmanarif.bitbucket.io/visual/downloads.html Answer to questions (Q)

Load the following Program in Visual Emulator ; The purpose of this program is to add: aa+bb=cc ; First we define the variables; The variables are stored in locations 0x100-0x108 in the MEMMORY aa DCD 0x00112233 ;load (32 bit) value 0x00000001 into memory location 0x100 (by default) call it aa bb DCD 2 ;load (32 bit) value 0x00000002 into memory location 0x104 (by default) cc DCD 0 ;load (32 bit) value 0x00000000 into memory location 0x108 (by default) DCB Define Constant Byte Reserve 8-bit values DCW Define Constant Halfword Reserve 16-bit values DCD Define Constant Word Reserve 32-bit values DCQ Define Constant Reserve 64-bit values main LDR r1, =aa ;load memory address of aa into r1 After execution: PC = 0xC+4 LDR r2, [r1] ;load content of memory address in r1 into r2 (that is 0x0001) LDR r3, =bb LDR r4, [r3] ADDS r5, r2, r4 ;r2+r4 -> r5 and update flags LDR r6, =cc ;load memory address of cc into r6 STR r5, [r6] ;store the sum into variable cc ; this section shows that the sum is infact loaded into cc LDR r7, =cc LDR r8, [r7] ; cc+1--> r9 ADDS r9, r8, #1 END

Execute the Program: Click on Step Froward

See what happens as you step through Note how registers R1-R9 change Note that the memory address for aa is 0x100, for bb is 0x104 and so far. Click on HEX BIN and DEC and see the values. Question: Q1. What is the largest value of aa variable in HEX and DECIMAL? How many bits are required to represent this value? Q2. What is the memory address of cc?

See what happens as you step through Note that every time an instruction is executed, the PC value is increased. Note that as ADDS is executed, the color of CSPR changes indicating it is being updated. Question: Q3. By the time the program is completed, what is the value of PC?

See what happens as you step through Note that every time an instruction is executed the INTRUCTION clock cycle is increased. Question: Q4. How many instruction cycles are required to execute ADDS instruction? Q5. How many instruction cycles are required to execute STR instruction? Q6. How many instruction cycles are require to complete this code?

As you execute.click on MEMORY when LDR is executed. Note that you can see the Memory address for variable aa this is where it is saved. Q7. How many bytes variable aa has? Note that every time an instruction is executed the INTRUCTION clock cycle is increased. Question: Q4. How many instruction cycles are required to execute ADDS instruction? Q5. How many instruction cycles are required to execute STR instruction? Q6. How many instruction cycles are require to complete this code?

DATA MEMORY LOCATIONS 0x100 aa 0x104 bb 0x108 cc INSTRUCTION MEMORY LOCATIONS Line 1 0x00 Line 9 0x08 Line 10 0x0C There are two separate memory structures for DATA and INSTRUCTIONS. The DATA MEMORY in this EMUALTOR starts from 0x100. However, the Instruction MEMORY starts from 0x0. We know that based on the value of the PC Note that in this case as PC increases, it points to a new instruction. Q8. What is the PC value AFTER ADDS r9, r8, #1 is executed Q9. What Does PC stand for?

ADD the following code to the end of your program. Step through the program and see how R1 changes. Q10. Clearly explain what is happening to R1. What does RRX instruction do? Q11. Mathematically every time RRX is performed what happens? Q12. What does B instruction do? Note that every time an instruction is executed the INTRUCTION clock cycle is increased. Question: Q4. How many instruction cycles are required to execute ADDS instruction? Q5. How many instruction cycles are required to execute STR instruction? Q6. How many instruction cycles are require to complete this code?

Try the following commands. In each case specify the purpose of the command, what happens to the destination register Examples Purpose? What happens to the dest.? MOV r0, #42 MOV r2, r3 MVN r1, r0 MOV r0, r0 ADD r0, r1, r2 SUB r5, r3, #10 RSB r2, r5, #0xFF00 AND r8, r7, r2 ORR r11, r11, #1 BIC r11, r11, #1 EOR r11, r11, #1 ADC r5, r3 r1 MUL r6, r4, r2 http://web.sonoma.edu/users/f/farahman/sonoma/courses/es310/310_arm/res ources/datasheets/list_of_assembly_commands.pdf Examples CMP r0, #42 CMN r2, #42 TST r11, #1 MOV R2, R0, LSL #2 ADD R9, R5, R5, LSL #3 RSB R9, R5, R5, LSL #3 SUB R10, R9, R8, LSR #4 MOV R12, R4, ROR R3 stop B stop SUBS r4, r0, r2 SBC r5, r1, r3 UMUL r6, r4, r2 MLS r6, r4, r1, r0 ADD r1, r0, r0, LSL #3 Purpose? What happens to the dest.?

http://web.sonoma.edu/users/f/farahman/sonoma/courses/es310/310_arm/res ources/datasheets/list_of_assembly_commands.pdf Q.13 Practice With the Following Commands TRY ONE COMMAND AT A TIME: MOV R1, #64 ;R1=0b0100 0000 ADDS R1, R2, R3 MOV R1, R3 MOV R1, #10 MOV R2, #5 ADD R0, R2,R1, LSL #1 ; R0 = R2 + (R1 << 1) = 0X84 MOV R2, #0X4 ;R2=0X 1000 1000 ADC R1,R2,#0 ;R9-R9+0+C MOV R3, #2 MOV R3, #2 ;R3=0X 0000 0010 MOV R4, #7 ;R4=0X 0000 0111 MOV R5, #0XFF ;R4=0X FF - MAX VALUE THAT CAN BE LOADED IS 0XFF MOV R2, #0x4F MOV R3, #0x39 SUBS R4,R2,R3 ;R4=R2-R3 MLA R4, R1, R2,R3 ;R4=R1xR2 + R3 or R3 += R1 X R2 ANDS R4, R2, R3 ;R4=0X0 Z FLAG ANDS R4, R2, R3 ;R4=0X0 NO GLAG ROR R1, R1, #4 ;R1 = 0X4 ROTATE TO RIGHT BY 4 BITS RRX R1, R4 ; ROTATE R4 BY ONE BIT AND PLACE IN R1=0X3 ADD R1, R2, R3 aa DCD 0xFFFFFFF5 LDR R0, =aa LDR R1, [R0] MOV R3, #0x0B MOV R2, #0x4F SUBS R4,R2,#0x05 ;R4=R2-5 SUB R2, R2, R1 :R2=R2-R1=4-64 = 0X4 + FF FF FF C0 = FF FF FF C4 (2 S COMP) SUB R2, R2, #0x2 ; Immediate number operand -> R2=0x2 SUB R0, #1, R3 ; Note this is an error! SBC R2, R2, R1 ; Assume Carry is 1???? MOV R1, #64 ;R1=0X 0100 0000 ; alfword ORRS R4, R2, R3 ;R4=0X8A ORR R5, R2, R3 ; Set a bit! EOR R2, R1, #0x78 ;R2=R1 ExOred with 0x78 BIC R3, R2, #0x0F ;R3=R2 AND 0x0F BIC R3, R2, #~0x0F ;R3=R2 AND Complement of 0x0F LSL R1, R1, #1 ;R1=0X80 LSL R1, R2, #1 ;R1 = 0X110 ADD R0, R2,R1, LSL #1 ; R0 = R2 + (R1 << 1) = 0X84 MOV R1, #0x36 MOVS R1, R1, ROR #1 ;Rotate to right by one bit MOVS R1, R1, ROR #1 ;Rotate to right by one bit - C=1 MOV R2, #0X4 ;R2=0X 1000 1000 MUL R3, R2, R1 LSL R1, R2, R3 ;R1 = 0X220 - NO FLAG UPDATE LSLS R5, R5, #1 ;R5 = 0X1FE - NOTE THAT N,Z,C FLAGS ARE UPDATED ONLY (NOT V) MOV R1, #0x36 MOV R2, #0x06 MOVS R3, R2, ROR R1 ;Rotate to right by value of R1 > R3

Use the following Table to Complete Each Command Must be submitted Examples Purpose? What happens to the dest.? MOV r0, #42 Moving a value into a register Register R0=42 decimal /

Submit the following: Answer all the questions. Write a program to do the following: Load R5 with 0x5 Load R1 with 0x2 R2=R1+R2 R2=R1+R2 Set R5=0x20 Store R2 into location pointed by R5 Let s say we add 0x9C and 0xFFFFFF64. Which flags will be set? Take a snap shot of the simulator. Explain your answer. Let s say we add 0x9C and 0xFFFFFF69. Which flags will be set? Take a snap shot of the simulator. Explain your answer. Write a program to do the following: Load R2 with 0x4 Load R3 with 0x2 Load R4 with 0x4 R5= R2-R3 R5=R2-R4 What is the is the state of the flags? Define a 32-bit register called Steve and set it to 0x2321. Then move the address of Steve to register R2 Write an instruction to set bit 4 of R7 only Write a simple routine that can add TWO 64-bit values. The results must be in Reg R5 & R6