OutLine of Tutorial 3 Memory Allocation Const string New string(byte array) Read memory in simulator Function invocation How Import library files Modify.

Slides:



Advertisements
Similar presentations
Character Arrays (Single-Dimensional Arrays) A char data type is needed to hold a single character. To store a string we have to use a single-dimensional.
Advertisements

C Language.
Fundamentals of Computer and programming in C Programming Languages, Programs and Programming Rohit Khokher.
Chapter 10 Linking and Loading. Separate assembly creates “.mob” files.
Catch up on previous topics Summary and putting together first four classes.
OutLine of Tutorial 5 Summary of Load/Store instructions Exercises reading memory in Simulator Exercises writing code.
1 ARM Movement Instructions u MOV Rd, ; updates N, Z, C Rd = u MVN Rd, ; Rd = 0xF..F EOR.
The 8051 Microcontroller and Embedded Systems
I/O: SPARC Assembly Department of Computer Science Georgia State University Georgia State University Updated Spring 2014.
SPIM and MIPS programming
What is a pointer? First of all, it is a variable, just like other variables you studied So it has type, storage etc. Difference: it can only store the.
Syscall in MIPS Xinhui Hu Yuan Wang.
MIPS Assembly Language Programming
1 Computer Architecture MIPS Simulator and Assembly language.
More on Assembly CS 210 Tutorial 4. Detail of Echo program entry main.enter; import "../IMPORT/callsys.h"; block main uses CALLSYS { code { public enter:
Assembly Language Working with the CPU.
Web siteWeb site ExamplesExamples Irvine, Kip R. Assembly Language for Intel-Based Computers, Intrinsic Data Types (1 of 2) BYTE, SBYTE 8-bit unsigned.
Files. System Calls for File System Accessing files –Open, read, write, lseek, close Creating files –Create, mknod.
© The McGraw-Hill Companies, 2006 Chapter 5 Arrays.
Table 1. Software Hierarchy Levels.. Essential Tools An assembler is a program that converts source-code programs into a machine language (object file).
Chapter 4 H1 Assembly Language: Part 2. Direct instruction Contains the absolute address of the memory location it accesses. ld instruction:
Engineering H192 - Computer Programming The Ohio State University Gateway Engineering Education Coalition Lect 6P. 1Winter Quarter I/O in C Lecture 6.
CS2422 Assembly Language & System Programming September 26, 2006.
Chapter 3: Introduction to C Programming Language C development environment A simple program example Characters and tokens Structure of a C program –comment.
Chapter 18 I/O in C. Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display Standard C Library I/O commands.
Computer Organization - Syscalls David Monismith Jan. 28, 2015 Based on notes from Patterson and Hennessy Text and from Dr. Bill Siever.
ICS312 Set 4 Program Structure. Outline for a SMALL Model Program Note the quiz at the next lecture will be to reproduce this slide.MODEL SMALL.586 ;
CMPE13 Cyrus Bazeghi Chapter 18 I/O in C. CMPE Standard C Library I/O commands are not included as part of the C language. Instead, they are part.
MIPS coding. SPIM Some links can be found such as:
Chapter 3 Elements of Assembly Language. 3.1 Assembly Language Statements.
CP104 Introduction to Programming File I/O Lecture 33 __ 1 File Input/Output Text file and binary files File Input/output File input / output functions.
STRINGS & STRING HANDLING FUNCTIONS STRINGS & STRING HANDLING FUNCTIONS.
Riyadh Philanthropic Society For Science Prince Sultan College For Woman Dept. of Computer & Information Sciences CS 251 Introduction to Computer Organization.
© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Tutorial 5 – Dental Payment Application: Introducing.
1 Chapter 2 C++ Syntax and Semantics, and the Program Development Process Dale/Weems/Headington.
Working With Main Memory. Why Main Memory Register space limited Used for communication.
Chapter 18 I/O in C.
Property of Jack Wilson, Cerritos College1 CIS Computer Programming Logic Programming Concepts Overview prepared by Jack Wilson Cerritos College.
CECS 121 Test 1. Functions allow you to group program statements under one name C and C++ are case-sensitive so main(), MAIN(), and Main() are all different.
CHAPTER 7 arrays I NTRODUCTION T O C OMPUTER P ROGRAMMING (CSC425)
CET 3510 Microcomputer Systems Tech. Lecture 2 Professor: Dr. José M. Reyes Álamo.
Ch2b- 2 EE/CS/CPE Computer Organization  Seattle Pacific University Thanks for all the Memory! When 32 registers just won’t do. Many times (almost.
1 Chapter 2 C++ Syntax and Semantics, and the Program Development Process.
Functions in Assembly CS 210 Tutorial 7 Functions in Assembly Studwww.cs.auckland.ac.nz/ ~mngu012/public.html/210/7/
CSCI 3133 Programming with C Instructor: Bindra Shrestha University of Houston – Clear Lake.
X86 Programming Memory Accessing Modes, Characters, and Strings Computer Architecture.
Chapter 10 Instruction Sets: Characteristics and Functions Felipe Navarro Luis Gomez Collin Brown.
Programming Fundamentals. Summary of previous lectures Programming Language Phases of C++ Environment Variables and Data Types.
Arrays. The array data structure Array is a collection of elements, that have the same data type Integers (int) Floating point numbers (float, double)
1 CSC103: Introduction to Computer and Programming Lecture No 28.
Integers/Characters Input/Output Integers and Characters Input/Output System Calls. syscall Trap Handler Services for Integers and Characters Read Integer,
MIPS Architecture Topics –What resources MIPS assembly manipulates –CPU (Central Processing Unit) –ALU (Arithmetic & Logical Unit), Registers –Memory –I/O.
Assembly Language Lecture 2. Lecture Outline Program Structure Memory models Data Segment Stack Segment Code Segment Input and Output Instructions INT.
Chapter 7 Continued Arrays & Strings. Arrays of Structures Arrays can contain structures as well as simple data types. Let’s look at an example of this,
CCSA 221 Programming in C INPUT AND OUTPUT OPERATIONS IN C – PART 1 1.
File Operations. FILE PROCESSING For the purposes of the following discussion, reading means copying all or part of an existing file into memory Writing.
Arrays and Pointers Variables are just names of memory locations An array is a variable (just with many memory locations – all contiguous) Address = pointer.
DYNAMIC MEMORY ALLOCATION. Disadvantages of ARRAYS MEMORY ALLOCATION OF ARRAY IS STATIC: Less resource utilization. For example: If the maximum elements.
CS 312 Computer Architecture & Organization
MIPS Arithmetic is 32 bits
Introduction to Lab #1 José Nelson Amaral.
System Programming and administration
Additional Assembly Programming Concepts
Ken D. Nguyen Department of Computer Science Georgia State University
Chapter 4 –Requirements for coding in Assembly Language
Introduction to C EECS May 2019.
Ken D. Nguyen Department of Computer Science Georgia State University
MIPS Assembly Language Programming Computer Architecture
CS 286 Computer Architecture & Organization
Chapter 10 Instruction Sets: Characteristics and Functions
Presentation transcript:

OutLine of Tutorial 3 Memory Allocation Const string New string(byte array) Read memory in simulator Function invocation How Import library files Modify example 1 using what we learned today

Memory Allocation – Const String const { align quad; message1: asciiz“question” align quad; message2: ascii“question” } Notes: Strings are stored in big endian One char is stored in one byte Allocated space is multiple of the size of the specified type (here is quad). asciiz directive: an extra zero byte is allocated and added on the end Exercise 1:  Draw a memory table to show the data stored.  Write down the first quad word in Hex

Const String – Exercise 2 Write alpha assembly code to allocate memory for two strings. One is “Type some input: ”. The other is “Your input was: ” Draw a table to show how memory is allocated

Const String – Exercise Answer Write alpha assembly code to allocate memory for two strings. One is “Please type some inputs: ”. The other is “Your input is: ” const { align quad; message1: asciiz “Type some input: ”; align quad; message2: asciiz “Your input was: ”; }

Memory Allocation – New String abs{ BUFFERSIZE = 10 } data{ align quad; buffer: byte [BUFFERSIZE + 1]; } Notes: define buffer size of the string In “abs”-absolute section Allocating memory for a new string by allocating memory for a byte array Allocate array in “data” section Array size needs to be buffer size plus 1 because of ascizz

Memory Reading in Simulator Load example 2 Open user memory window Find memory section by using search window. Or type “CTRL+f” Type blockName.sectionName or blockName.memoryLabel For example “main.data”,“main.message1”

Function Invocation – How bsr Sys.getChar.enter; Steps: Load function parameters to register $a0…$a6 Call procedure by using instruction “bsr” followed by a operand(entry point to the function). The return value is stored in register $V0 Library name Function name enter

Function invocation – Exercise1 Read a char input by using Sys.getChar Display the inputted char to screen by using Sys.putChar

Function invocation – Exercise1 Answer Read a char input by using Sys.getChar Display the inputted char to screen by using Sys.putChar bsr Sys.getChar.enter; mov $v0, $a0; bsr Sys.putChar.enter;

Library files What and why declarations, definitions, and functions supported by the simulator system. “IMPORT” folder contains all files that you can import in your assembly code code syntax to import library files: import “path of the file to import”; For example: import “..\IMPORT\register.h”;

Library files 2 files in “IMPORT” folder.h files: contain declarations and absolute definitions which usually are used in your assembly code and system supplied functions. Like, registers($a0,$v0…) “callsys.h”: system call “register.h”: integer and float registers “proc.h”: special registers which are used in functions supplied by system “entryReg.h”.s files: contain system supplied functions, like print. “callsys.lib.s”: contains functions like “getChar” “io.lib.s”: contains functions like “print”, “readLine” Others: you can read them if you are interested. Reading library files is always a good way to know a language system quickly.

Exercise Modify example 1 by replacing system calls with functions Sys.getChar and Sys.putChar Try to find out what library files you need to import to use these two functions.