Assembly Language Review Being able to repeat on the Blackfin the things we were able to do on the MIPS 2/26/2016 Review of 50% OF ENCM369 in 50 minutes1.

Slides:



Advertisements
Similar presentations
Week 3. Assembly Language Programming  Difficult when starting assembly programming  Have to work at low level  Use processor instructions >Requires.
Advertisements

IT253: Computer Organization Lecture 6: Assembly Language and MIPS: Programming Tonga Institute of Higher Education.
Blackfin BF533 EZ-KIT Control The O in I/O Activating a FLASH memory “output line” Part 2.
Blackfin BF533 EZ-KIT Control The O in I/O Activating a FLASH memory “output line” Part 3 – New instruction recap Tutorial.
Assignment Overview Thermal oscillator One of the ENCM415 Laboratory 2 items Oscillator out GND +5V.
Blackfin BF533 EZ-KIT Control The O in I/O Activating a FLASH memory “output line” Part 2.
Hints for Post-Lab Quiz 1 Works for other quizzes and exams too.
Inline Assembly Section 1: Recitation 7. In the early days of computing, most programs were written in assembly code. –Unmanageable because No type checking,
CS 61C L02 Number Representation (1)Harvey / Wawrzynek Fall 2003 © UCB 8/27/2003  Brian Harvey ( John Wawrzynek  (Warznek) (
1 Homework Turn in HW2 at start of next class. Starting Chapter 2 K&R. Read ahead. HW3 is on line. –Due: class 9, but a lot to do! –You may want to get.
Data Representation Computer Organization &
1 Hints for Post-Lab Quiz 1 Works for other quizzes and exams too.
COMP3221 lec06-numbers-II.1 Saeid Nooshabadi COMP 3221 Microprocessors and Embedded Systems Lecture 6: Number Systems - II
Data Representation COE 205
Understanding the TigerSHARC ALU pipeline Determining the speed of one stage of IIR filter.
Feb 18, 2009 Lecture 4-2 instruction set architecture (Part II of [Parhami]) MIPS encoding of instructions Spim simulator more examples of MIPS programming.
CS 61C L02 Number Representation (1) Garcia, Spring 2004 © UCB Lecturer PSOE Dan Garcia inst.eecs.berkeley.edu/~cs61c CS61C.
2-1 Computer Organization Part Fixed Point Numbers Using only two digits of precision for signed base 10 numbers, the range (interval between lowest.
8 November Forms and JavaScript. Types of Inputs Radio Buttons (select one of a list) Checkbox (select as many as wanted) Text inputs (user types text)
Getting the O in I/O to work on a typical microcontroller Ideas of how to send output signals to the radio controlled car. The theory behind the LED controller.
Laboratory 1 – ENCM415 Familiarization with the Analog Devices’ VisualDSP++ Integrated Development Environment.
Blackfin BF533 EZ-KIT Control The O in I/O Activating a FLASH memory “output line” Part 2.
Getting the O in I/O to work on a typical microcontroller Activating a FLASH memory “output line” Part 1 Main part of Laboratory 1 Also needed for “voice.
Blackfin BF533 EZ-KIT Control The O in I/O
Data Transfer & Decisions I (1) Fall 2005 Lecture 3: MIPS Assembly language Decisions I.
Tutorial Essentially all the Blackfin instruction you need for all of ENCM511. The instructions are easy. Its knowing when to use them that is the difficult.
Topic 8: Data Transfer Instructions CSE 30: Computer Organization and Systems Programming Winter 2010 Prof. Ryan Kastner Dept. of Computer Science and.
CENG 311 Machine Representation/Numbers
Simple Data Type Representation and conversion of numbers
Input Laboratory: GPIO Pin control needed to have the Blackfin accept your commands Re-uses information from ENEL353 and ENCM369 courses and text books.
Assembly Language Review Being able to repeat on the Blackfin the things we were able to do on the MIPS 9/19/2015 Review of 50% OF ENCM369 in 50 minutes1.
Blackfin Array Handling Part 2 Moving an array between locations int * MoveASM( int foo[ ], int fee[ ], int N);
Lec 3: Data Representation Computer Organization & Assembly Language Programming.
M. Smith University of Calgary.  Many people like to sing in the shower.  However, its rather boring as there is no accompaniment.  The McVASH device.
Software Overview. Why review software? Software is the set of instructions that tells hardware what to do The reason for hardware is to execute a program.
8-1 Embedded Systems Fixed-Point Math and Other Optimizations.
BR 8/99 Binary Numbers Again Recall than N binary digits (N bits) can represent unsigned integers from 0 to 2 N bits = 0 to 15 8 bits = 0 to 255.
M. Smith University of Calgary.  Many people like to sing in the shower.  However, its rather boring as there is no accompaniment.  The McVASH device.
TK2633 : MICROPROCESSOR & INTERFACING Lecture 10: Fixed Point Arithmetic Lecturer: Ass. Prof. Dr. Masri Ayob.
Understanding the TigerSHARC ALU pipeline Determining the speed of one stage of IIR filter – Part 2 Understanding the pipeline.
Generating “Rectify( )” Test driven development approach to TigerSHARC assembly code production Assembly code examples Part 1 of 3.
Copyright 2006 by Timothy J. McGuire, Ph.D. 1 MIPS Assembly Language CS 333 Sam Houston State University Dr. Tim McGuire.
Blackfin Array Handling Part 1 Making an array of Zeros void MakeZeroASM(int foo[ ], int N);
CMSC 150 PROGRAM EXECUTION CS 150: Wed 1 Feb 2012.
Works for other quizzes and exams too A FEW SLIDES ARE UPDATED OVER THE SLIDES IN THE NOTES 1 Hints for Post-Lab Quiz 1.
Digital Representations ME 4611 Binary Representation Only two states (0 and 1) Easy to implement electronically %0= (0) 10 %1= (1) 10 %10= (2) 10 %11=
Copyright 2006 by Timothy J. McGuire, Ph.D. 1 MIPS Assembly Language CS 333 Sam Houston State University Dr. Tim McGuire.
Building a simple loop using Blackfin assembly code If you can handle the while-loop correctly in assembly code on any processor, then most of the other.
Works for other quizzes and exams too 1 Hints for Post-Lab Quiz 1.
Lab. 1 – GPIO Pin control Using information ENEL353 and ENCM369 text books combined with Blackfin DATA manual.
Assembly Language Review Being able to repeat on the Blackfin the things we were able to do on the MIPS 3/3/2016 Review of 50% OF ENCM369 in 50 minutes1.
“Lab. 5” – Updating Lab. 3 to use DMA Test we understand DMA by using some simple memory to memory DMA Make life more interesting, since hardware is involved,
Announcements Assignment 2 Out Today Quiz today - so I need to shut up at 4:25 1.
Assembly Variables: Registers Unlike HLL like C or Java, assembly cannot use variables – Why not? Keep Hardware Simple Assembly Operands are registers.
COMPUTER PROGRAMMING Year 9 – lesson 1. Objective and Outcome Teaching Objective We are going to look at how to construct a computer program. We will.
User-Written Functions
DMA example Video image manipulation
Handling Arrays Completion of ideas needed for a general and complete program Final concepts needed for Final.
Assembly Language Review
Assembly Language Review
Hints for Post-Lab Quiz 1
Handling Arrays Completion of ideas needed for a general and complete program Final concepts needed for Final.
Tutorial Essentially all the Blackfin instruction you need for all of ENCM511. The instructions are easy. Its knowing when to use them that is the difficult.
MARIE: An Introduction to a Simple Computer
Lab. 1 – GPIO Pin control Using information ENEL353 and ENCM369 text books combined with Blackfin DATA manual.
Input Laboratory: GPIO Pin control needed to have the Blackfin accept your commands Re-uses information from ENEL353 and ENCM369 courses and text books.
Handling Arrays Completion of ideas needed for a general and complete program Final concepts needed for Final.
Blackfin BF533 EZ-KIT Control The O in I/O
This presentation will probably involve audience discussion, which will create action items. Use PowerPoint to keep track of these action items during.
CS334: MIPS language _Mars simulator Lab 2_1
Presentation transcript:

Assembly Language Review Being able to repeat on the Blackfin the things we were able to do on the MIPS 2/26/2016 Review of 50% OF ENCM369 in 50 minutes1

Assembly code things to review 50% of ENCM369 in 50 minutes Being able to ADD and SUBTRACT the contents of two data registers Being able to bitwise AND and bitwise OR the contents of two data registers Being able to place a (small) required value into a data register Being able to place a (large) required value into a data register Being able to write a simple “void” function Being able to write a simple “int” function Being able to ADD and SUBTRACT the contents of two memory locations 2/26/2016 Review of 50% OF ENCM369 in 50 minutes2 / 28

Being able to ADD and SUBTRACT the contents of two data registers Blackfin DATA registers R0, R1, R2 and R3 R0 = R1 + R2;// Addition R3 = R1 – R2;// Subtraction It makes sense to ADD and SUBTRACT “values” stored in data registers 2/26/2016 Review of 50% OF ENCM369 in 50 minutes3 / 28

Being able to bitwise AND and OR the contents of two data registers Blackfin DATA registers R0, R1, R2 and R3 R0 = R1 & R2;// Bitwise AND R3 = R1 | R2;// Bitwise OR It makes sense to perform OR and AND operations on “bit-patterns” stored in data registers. NEVER perform ADD and SUBTRACT operations on “bit-patterns” stored in data registers. (Although SOMETIMES get the correct answer – code defect) 2/26/2016 Review of 50% OF ENCM369 in 50 minutes4 / 28

Is it a bit pattern or a value? Hints from “C++” If the coder is consistent when writing the code then Bit patterns are normally stored as “unsigned integers” e.g. unsigned int bitPattern = 0xFFFFFFFF Values are normally stored as “signed integers” e.g. signed int fooValue = -1; or int fooValue = -1; where the word “signed” is understood as being there although not actually written. Note that “bitPattern” and “fooValue” are stored as the SAME bit pattern 0xFFFFFFFFF in the registers and memory 2/26/2016 Review of 50% OF ENCM369 in 50 minutes5 / 28

Being able to place a required value into a data register –1 Like the MIPS, the Blackfin uses 32 bit instructions – all the same size to ensure maximum speed (highly pipelined). The 32 bit Blackfin instruction for placing a value into a data register has been designed to have16 bits available for describing the instruction and 16 bits for describing the “signed” 16 bit value to be put into a “signed” 32 bit data register. This means that you have to use “2” 32-bit instructions to put large values into a data register 2/26/2016 Review of 50% OF ENCM369 in 50 minutes6 / 28

Placing a value into a data register R1 = 0; legal -- 0 = 0x0000 (signed 16 bits); (becomes the signed 32 bit 0x after auto sign extension) R0 = 33; legal = 0x0021 (signed 16 bits) (becomes the signed 32 bit 0x after auto sign extension) R2 = -1; legal = 0xFFFF (signed 16 bits) (becomes the signed 32 bit 0xFFFFFFFF after auto sign extension) R3 = -33; legal = 0xFFDE (signed16 bits) (becomes the signed 32 bit 0xFFFFFFDE after auto sign extension) 2/26/2016 Review of 50% OF ENCM369 in 50 minutes7 / 28

Placing a “large” value into a data register This approach does not work for any “large” value R1 = 40000; illegal -- as can’t be expressed as a signed 16-bit value – it is the positive 32 bit value 0x00009C40 If the assembler tried to take the bottom 16 bits of the decimal and sign extend it then this would happen “16-bit” hex value 9C40 ( ) becomes “32-bit” hex value after sign extension 0xFFFF9C40 which is a “negative value” Therefore it is “illegal” to try to put a 32-bit value directly into a register; just as it would be illegal to try in MIPS. 2/26/2016 Review of 50% OF ENCM369 in 50 minutes8 / 28

Placing a “large” value into a data register If the assembler tried to take the bottom 16 bits of the decimal and sign extend it then this would happen “16-bit” hex value 9C40 ( ) becomes “32-bit” hex value after sign extension 0xFFFF9C40 which is a “negative value” “illegal” just as it would be in MIPS // Want to do R1 = // Instead must do operation in two steps as with MIPS R1.L = lo(40000); // Tell assembler to put “bottom” // 16-bits into “low” part of R1 register R1.H = hi(40000); // Tell assembler to put “top” // 16-bits into “high” part of R1 register 2/26/2016 Review of 50% OF ENCM369 in 50 minutes9 / 28

Placing a “large” value into a data register A common error in the laboratory and exams is getting this two step thing “wrong” // Want to do R1 = R1.L = lo(41235); // “bottom” 16-bits into “low” part of R1 register R1.H = hi(41325); // “top” 16-bits into “high” part of R1 register RECOMMENDED SYNTAX TO AVOID “CODE DEFECTS” #define LARGEVALUE 41235// C++ - like syntax R1.L = lo(LARGEVALUE) ; R1.H = hi(LARGEVALUE) ; Yes -- this assembler allows you to put multiple Blackfin assembly language instructions on one line – NOTE the syntax 2/26/2016 Review of 50% OF ENCM369 in 50 minutes10 / 28

Being able to write a simple “void” function void SimpleVoidASM(void) #include #define.section program;.global _SimpleVoidASM__Fv; _SimpleVoidASM__Fv: _SimpleVoidASM__Fv.END: RTS; 2/26/2016 Review of 50% OF ENCM369 in 50 minutes11 / 28 Things in red were cut-and-pasted using the editor

Being able to write a simple “int” function int SimpleIntASM(void) #include #define.section program;.global _SimpleIntASM__Fv; _SimpleIntASM__Fv: R0 = 7; // Return “7” _SimpleIntASM__Fv.END: RTS; 2/26/2016 Review of 50% OF ENCM369 in 50 minutes12 / 28 Things in red were cut-and-pasted using the editor

Being able to ADD and SUBTRACT the contents of two memory locations Let’s set up a practical situation A “background” thread is putting values into an array. For “background” thread read “interrupt service routine” or ISR. ISR work “in parallel” with the “foreground” thread that is doing the major work on the microprocessor Write a subroutine (returns int) that adds together the first two values of the array 2/26/2016 Review of 50% OF ENCM369 in 50 minutes13 / 28

Start with a copy of the “int” function int SimpleIntASM(void) #include #define.section program;.global _SimpleIntASM__Fv; _SimpleIntASM__Fv: R0 = 7; // Return “7” _SimpleIntASM__Fv.END: RTS; 2/26/2016 Review of 50% OF ENCM369 in 50 minutes14 / 28 Things in red were cut-and-pasted using the editor

Modify to be int AddArrayValuesASM(void) #include #define.section program;.global _AddArrayValuesASM__Fv; _AddArrayValuesASM __Fv: R0 = 7; // Return “7” _AddArrayValuesASM __Fv.END: RTS; 2/26/2016 Review of 50% OF ENCM369 in 50 minutes15 / 28 Things in red were cut-and-pasted using the editor

Add a “data” array #include #define.section L1_data;.byte4 _fooArray[2];.section program;.global _AddArrayValuesASM__Fv; _AddArrayValuesASM __Fv: R0 = 7; // Return “7” _AddArrayValuesASM __Fv.END: RTS; 2/26/2016 Review of 50% OF ENCM369 in 50 minutes16 / 28 Things in red were cut-and-pasted using the editor

Plan to return “sum”, initialize sum to 0 #include #define.section L1_data;.byte4 _fooArray[2];.section program;.global _AddArrayValuesASM__Fv; _AddArrayValuesASM __Fv: #define sum_R0 R0// register int sum; sum_R0 = 0; // sum = 0; _AddArrayValuesASM __Fv.END: RTS; 2/26/2016 Review of 50% OF ENCM369 in 50 minutes17 / 28 Things in red were cut-and-pasted using the editor

Place the memory address of the start of the array into a pointer register …. Other code.section L1_data;.byte4 _fooArray[2];.section program;.global _AddArrayValuesASM__Fv; _AddArrayValuesASM __Fv: #define sum_R0 R0// register int sum; sum_R0 = 0; // sum = 0; #define pointer_to_array_P0 P0// register int * pointer_to_array P0.L = lo(_fooArray); P0.H = hi(_fooArray); // pointer_to_array = &fooArray[0]; _AddArrayValuesASM __Fv.END: RTS; 2/26/2016 Review of 50% OF ENCM369 in 50 minutes18 / 28 Things in red were cut-and-pasted using the editor

Read the contents of the first array location into register R1 and add to sum_R0; …. Other code.section L1_data;.byte4 _fooArray[2];.section program;.global _AddArrayValuesASM__Fv; _AddArrayValuesASM __Fv: #define sum_R0 R0// register int sum; sum_R0 = 0; // sum = 0; #define pointer_to_array_P0 P0// register int * pointer_to_array P0.L = lo(_fooArray); P0.H = hi(_fooArray); // pointer_to_array = &fooArray[0]; R1 = [pointer_to_array_P0]; // int temp = fooArray[0]; sum_R0 = sum_R0 + R1; // sum = sum + temp _AddArrayValuesASM __Fv.END: RTS; 2/26/2016 Review of 50% OF ENCM369 in 50 minutes19 / 28 Things in red were cut-and-pasted using the editor

Read the contents of the second array location into register R1 and add to sum_R0; …. Other code.section L1_data;.byte4 _fooArray[2];.section program;.global _AddArrayValuesASM__Fv; _AddArrayValuesASM __Fv: #define sum_R0 R0// register int sum; sum_R0 = 0; // sum = 0; #define pointer_to_array_P0 P0// register int * pointer_to_array P0.L = lo(_fooArray); P0.H = hi(_fooArray); // pointer_to_array = &fooArray[0]; R1 = [pointer_to_array_P0]; // int temp = fooArray[0]; sum_R0 = sum_R0 + R1; // sum = sum + temp R1 = [pointer_to_array_P0 + 4]; // temp = fooArray[1]; sum_R0 = sum_R0 + R1; // sum = sum + temp _AddArrayValuesASM __Fv.END: RTS; 2/26/2016 Review of 50% OF ENCM369 in 50 minutes20 / 28 Things in red were cut-and-pasted using the editor

Add the code into an.ASM file in Assignment 1 and check syntax 2/26/2016 Review of 50% OF ENCM369 in 50 minutes21 / 28

Fix syntax – and run some tests it 2/26/2016 Review of 50% OF ENCM369 in 50 minutes22 / 28

Assignment 1, Q1 Demo answer 2/26/2016 Review of 50% OF ENCM369 in 50 minutes23 / 28

Assembly code things to review 50% of ENCM369 in 50 minutes Being able to ADD and SUBTRACT the contents of two data registers Being able to bitwise AND and bitwise OR the contents of two data registers Being able to place a (small) required value into a data register Being able to place a (large) required value into a data register Being able to write a simple “void” function Being able to write a simple “int” function Being able to ADD and SUBTRACT the contents of two memory locations 2/26/2016 Review of 50% OF ENCM369 in 50 minutes24 / 28