Accessing Memory Chapter 5 Lecture notes for SPARC Architecture, Assembly Language Programming and C, Richard P. Paul by Anu G. Bourgeois.

Slides:



Advertisements
Similar presentations
UltraSPARC.
Advertisements

Lecture 13: 10/8/2002CS170 Fall CS170 Computer Organization and Architecture I Ayman Abdel-Hamid Department of Computer Science Old Dominion University.
Chapter 6 Data Structures
1 ECE462/562 ISA and Datapath Review Ali Akoglu. 2 Instruction Set Architecture A very important abstraction –interface between hardware and low-level.
SPARC Architecture & Assembly Language
I/O: SPARC Assembly Department of Computer Science Georgia State University Georgia State University Updated Spring 2014.
SPIM and MIPS programming
ITCS 3181 Logic and Computer Systems 2015 B. Wilkinson slides3.ppt Modification date: March 16, Addressing Modes The methods used in machine instructions.
1 COMS 361 Computer Organization Title: Instructions Date: 9/28/2004 Lecture Number: 10.
Princess Sumaya Univ. Computer Engineering Dept. Chapter 3: IT Students.
Chap.2: Instructions: Language of the computer Jen-Chang Liu, Spring 2006 Adapted from
CS 61C L09 Introduction to MIPS: Data Transfer & Decisions I (1) Garcia, Fall 2004 © UCB Lecturer PSOE Dan Garcia inst.eecs.berkeley.edu/~cs61c.
Elec2041 lec-11-mem-I.1 Saeid Nooshabadi COMP 3221 Microprocessors and Embedded Systems Lecture 11: Memory Access - I
Programming the HC12 in C. Some Key Differences – Note that in C, the starting location of the program is defined when you compile the program, not in.
What is an instruction set?
5/6/99 Ashish Sabharwal1 JVM Architecture n Local storage area –Randomly accessible –Just like standard RAM –Stores variables (eg. an array) –Have to specify.
ARM C Language & Assembler. Using C instead of Java (or Python, or your other favorite language)? C is the de facto standard for embedded systems because.
Data Transfer & Decisions I (1) Fall 2005 Lecture 3: MIPS Assembly language Decisions I.
9/29: Lecture Topics Memory –Addressing (naming) –Address space sizing Data transfer instructions –load/store on arrays on arrays with variable indices.
INTRODUCTION TO IBM PC ASSEMBLY LANGUAGE
Topic 8: Data Transfer Instructions CSE 30: Computer Organization and Systems Programming Winter 2010 Prof. Ryan Kastner Dept. of Computer Science and.
1/2002JNM1 Basic Elements of Assembly Language Integer Constants –If no radix is given, the integer is assumed to be decimal. Int 21h  Int 21 –A hexadecimal.
1/2002JNM1 Positional Notation (Hex Digits). 1/2002JNM2 Problem The 8086 has a 20-bit address bus. Therefore, it can access 1,048,576 bytes of memory.
Dr Mohamed Menacer College of Computer Science and Engineering Taibah University CS-334: Computer.
Natawut NupairojAssembly Language1 Memory and Stack.
CSC 3210 Computer Organization and Programming Chapter 5 THE STACK D.M. Rasanjalee Himali.
Character Data and 32-bit Constants (Lecture #20) ECE 445 – Computer Organization The slides included herein were taken from the materials accompanying.
Computer Architecture EKT 422
George W. Woodruff School of Mechanical Engineering, Georgia Tech ME4447/6405 ME 4447/6405 Microprocessor Control of Manufacturing Systems and Introduction.
Richard P. Paul, SPARC Architecture, Assembly Language Programming, and C Chapter 8 – Machine Instructions These are lecture notes to accompany the book.
Chapter 2 — Instructions: Language of the Computer — 1 Memory Operands Main memory used for composite data – Arrays, structures, dynamic data To apply.
EECS 370 Discussion 1 xkcd.com. EECS 370 Discussion Topics Today: – ARM Addressing Endianness, Loading, and Storing Data – Data Layout Struct Packing.
Home Assignment 5 Assigned. Deadline 2016 March 2, Wednesday.
Lecture 2 Chapter 4 –Requirements for coding in Assembly Language 1.
The Stack Chapter 5 Lecture notes for SPARC Architecture, Assembly Language Programming and C, Richard P. Paul by Anu G. Bourgeois, Abinashi Dhungel.
Assembly Variables: Registers Unlike HLL like C or Java, assembly cannot use variables – Why not? Keep Hardware Simple Assembly Operands are registers.
First Foray into Programming (the hard way). A reminder from last lesson: A machine code instruction has two parts:  Op-code  Operand An instruction.
CSCI-365 Computer Organization Lecture Note: Some slides and/or pictures in the following are adapted from: Computer Organization and Design, Patterson.
Arrays and Pointers Variables are just names of memory locations An array is a variable (just with many memory locations – all contiguous) Address = pointer.
Chapter 8 – Machine Instructions
MIPS Arithmetic is 32 bits
ISA - Instruction Set Architecture
Data representation How do we represent data in a digital system?
Loading a Single Byte There are two instructions that load a byte from a memory address. The instructions differ in how the 8-bit byte is put into the.
The Stack Chapter 5 Lecture notes for SPARC Architecture, Assembly Language Programming and C, Richard P. Paul by Anu G. Bourgeois.
Morgan Kaufmann Publishers
Chapter 3 – Digital Logic and Binary Numbers
COMP3221: Microprocessors and Embedded Systems
Instruction Formats Each instruction consists of two parts:
Ken D. Nguyen Department of Computer Science Georgia State University
Microprocessor and Assembly Language
CSCI206 - Computer Organization & Programming
The University of Adelaide, School of Computer Science
Topic 6: Bitwise Instructions
Architecture Overview
ECEG-3202 Computer Architecture and Organization
Chapter 4 –Requirements for coding in Assembly Language
Chapter 9 Instruction Sets: Characteristics and Functions
Chapter 7 Assembly Language
ECEG-3202 Computer Architecture and Organization
Chapter 4 –Requirements for coding in Assembly Language
3.
Data representation How do we represent data in a digital system?
Computer Architecture and System Programming Laboratory
Ken D. Nguyen Department of Computer Science Georgia State University
Data representation How do we represent data in a digital system?
An Introduction to the ARM CORTEX M0+ Instructions
Chapter 10 Instruction Sets: Characteristics and Functions
Presentation transcript:

Accessing Memory Chapter 5 Lecture notes for SPARC Architecture, Assembly Language Programming and C, Richard P. Paul by Anu G. Bourgeois

2 Memory Addresses are 32 bits wide Therefore, 2 32 bytes in memory Each location is numbered consecutively Memory data types –Byte = 1 byteHalfword = 2 bytes –Word = 4 bytesDoubleword = 8 bytes

3 Data types C TypeSPARCBitsUnsignedSigned charbyte80, , 127 shorthalf160, 65,535-32,768, 32,767 int, longword320, 4.294x10 9  x 10 9 All memory references must be aligned x byte quantities must begin in an address divisible by x

Memory Allocation.section “.data” input:.word 0x limit:.half 0x9a prompt:.asciz “Hello!” Address (decimal) Data (hex) a ‘H’ 307‘e’ 308‘l’ 309‘l’ 310‘o’ 311‘!’ input limit prompt

Memory Allocation.section “.data” input:.word 0x limit:.half 0x9a prompt:.asciz “Hello!” Address (decimal) Data (hex) a ‘H’ 307‘e’ 308‘l’ 309‘l’ 310‘o’ 311‘!’ – divisible by 4 input takes up 4 byte locations

Memory Allocation.section “.data” input:.word 0x limit:.half 0x9a prompt:.asciz “Hello!” Address (decimal) Data (hex) a ‘H’ 307‘e’ 308‘l’ 309‘l’ 310‘o’ 311‘!’ – divisible by 2 limit takes up 2 byte locations Note: location 305 will have leading zeroes fill in the extra byte not specified in the data section

Memory Allocation.section “.data” input:.word 0x limit:.half 0x9a prompt:.asciz “Hello!” Address (decimal) Data (hex) a ‘H’ 307‘e’ 308‘l’ 309‘l’ 310‘o’ 311‘!’ – divisible by 1 Each element of prompt takes up 1 byte location

8 Addressing Variables Load and Store operations are the only instructions that reference memory Both instructions take two operands –One memory, and one register Can access memory using different data types (byte, half word, word, double word)

9 Load Instructions MnemonicOperation ldsb Load signed byte, propagate sign left in register ldub Load unsigned byte, clear high 24 bits of register ldsh Load signed halfword, propogate sign left in register lduh Load unsigned halfword, clear high 16 bits of register ld Load word ldd Load double, reg. # even, first 4 bytes into reg. n, next 4 into reg. n + 1

10 set input, %o0 ld [%o0], %o1 %o1 = 0x ldub [%o0 + 7], %o2 %o2 = ‘e’ ldsh [%o0 + 3], %o3 error ldsh [%o0 + 4], %o4 %o4 = 0x9a ldsb [%o0 + 4], %o5 %o5 = 0xffffff9a

11 Store Instructions MnemonicOperation stb Store low byte of register, bits 0-7, into memory sth Store low two bytes of register, bits 0-15 into memory st Store register std Store double, reg. # even, first 4 bytes from reg. n, next 4 from reg. n + 1 Why don’t we have all the same options as we did for the load instructions?

Address (decimal) Data (hex) mov 300, %o0 mov 0x , %o1 st %o1, [%o0] sth %o1, [%o0 + 6] sth %o1, [%o0 + 9] stb %o1, [%o0 + 13] error 78

Address (decimal) Data (hex) mov 0x9abcdef0, %o2 mov 0x , %o3 std %o2, [%o0 + 4] f0 de bc 9a

Rules to Remember 1.Lower byte Lower address 2.Reference is to the lowest address 3.Memory references must be byte aligned 14

Data Section.section “.data” first:.word 0x03, 0x0ef321 second:.byte 0x5c.align 2 third:.half 0x987, 0x7e string:.asciz “done” PointerAddressdata first f3 4060e second4085c 409undef third e string414‘d’ 415‘o’ 416‘n’ 417‘e’

Allocating Space.skip is a psedo-op that will provide space without any initialization my_array:.skip 4*100 Provides space for a 100-word unintialized array 16