1 The Simpletron Assembly Language
|
|
- Lee Ford
- 5 years ago
- Views:
Transcription
1 Simpletron Assembler 50 points In the Simpletron assignment we introduced a fictional machine called the Simpletron and the Simpletron Machine Language (SML). In this assignment you are to write an assembler that converts programs written in the Simpletron Assembly Language to SML. We provide you with programs in this new assembler language with the intention of assembling them with the assembler you will write and running the resulting SML program on the simulator you wrote. 1 The Simpletron Assembly Language Before we begin building the assembler we describe the high-level programming language called Simpletron Assembly Language. Every line in the Simpletron Assembly Language consists of an optional label, which if present must begin in the leftmost column, a valid instruction, and depending on the instruction, an operand. Most of the instructions are simply mnemonics for Simpletron operation codes. The valid instructions are listed in figure 1. Note that it is not legal for lines containing the I instruction to start with a label. All other instructions may have the optional label starting in the leftmost column. Comments are allowed in the Simpletron Assembly Language. Comments in the Simpletron Assembly Language have adopted the C++ convention of starting with // and may appear anwhere on a line. Anything between // and the end of a line may/should be ignored by your assembler. This syntax allows for comments to appear at the end of a line and/or entire lines to be nothing but comments. Consider the following Simpletron Assembly program that accepts two input values and prints and prints 1 if the first is greater than the second otherwise it prints 2. // reads two numbers, // prints 1 if the first is greater than second // otherwhise it prints a 2 R first R second I 10 // first input number I 20 // second input number // subtract second from first, // if result is <= 0 then print 2 // otherwise print 1 L first S second BN printtwo BZ printtwo W one // print 1 and halt H printtwo W two // print 1 and halt H // storage first DS second DS one DC 1 two DC 2 1
2 Optional label Instruction Operand Description Input/Output instructions: < label > R label Read a word into the label operand. < label > W label Print the word from the label operand. Load/Store instructions: < label > L label Load the word from label operand into the accumulator. < label > ST label Store the contents of the accumulator into the word identified by the label operand. Arithmetic instructions: < label > A label Add the word identified by the label operand to the accumulator (leave result in accumulator). < label > S label Subtract the word identfied by the label operand from the accumulator (leave result in accumulator). < label > M label Multiply the word identified by the label operand to the accumulator (leave result in accumulator). < label > D label Divide the word identfied by the label operand into the accumulator (leave result in accumulator). Transfer of control instructions: < label > B label Branch to the address identified by the label operand. < label > BN label Branch to the address identified by the label operand if the value in the accumulator is negative. < label > BZ label Branch to the address identified by the label operand if the value in the accumulator is zero. < label > H Halt execution. Storage reserve/define instructions: < label > DS Reserve a single word of storage, initialize to zero. < label > DC constant Reserve a single word of storage, initialize to constant operand. I constant Constant input that is intended to be read by R commands. These instructions are not executed. Figure 1: Instruction set for Simpletron Assembly Language. 2
3 Each of the first three lines begin with // and therefore everything appearing on the rest of the line is ignored as comments. The first executable statement is the R first line. Read instructions (R) acquire a value from input instructions (I) and store the value at the word identified by the label operand. The very first read instruction that is executed uses the very first input instruction in the program. Subsequently executed read instructions use the remaining input instructions in the order in which they appear in the program. Input instructions are never used more than once. The same read instruction will consume many input instructions if it is executed many times (e.g., in a loop ). This first read instruction reads the constant 10 (from the I 10 line) into the the single word of storage reseved by the line first DS near the end of the program. The second read line R second reads the constant 20 (from the I 20 line) into the single word reserved by second DS. The next two lines define input constants and are not executed. Such input lines may appear anywhere in the program. Note, however, that both input lines have comments at the end of each. Execution continues through ignoring the next three lines which are comments (note that the // did not start in the leftmost column in these lines) and proceeds to L first. This loads the accumulator with the word identified by the label operand first. In our example program, this places the value 10 (the first input value we just read) into the accumulator. The next instruction S second subtracts the word identified by the label operand second from the value in the accumulator leaving the difference in the accumulator. The next two instructions are branching instructions. The first branches to the address associated with the operand label printtwo if the value in the accumulator is negative and the second branches to that same address if the value in the accumulator is zero. The next two lines of the program print the word identified by the label operand one (defined to be the constant 1) and halts execution. The following two lines print the constant 2 and halts. The end of our program is where we define our storage and constants. 2 Input The input to your program is a Simpletron Assembly program, just like the one shown in the previous section. You may assume that all Simpletron Assembly programs given to your assembler are syntactically correct. Syntax checking is a critical component of any assembler, however, proper syntax checking is a very difficult problem and well beyond the scope of this course. Hence, when you write your assembler you may make the simplifying assumption that the programs you are assembler are syntactically correct. 3 Output Your assembler will produce a complete SML program, including the line followed by any input (from any I instructions in the Simpletron Assembly program) or an error message (error messages described in section 4). The SML program generated by your assembler must be immediately suitable for execution on your simpletron. In other words, you should be able to take the SML program generated by your assembler and feed it directly (without modification) as input to your simpletron. 4 The Two Pass Assembler The result of the compiler is the SML program, which is composed of SML instructions and data, a line containing to mark the end of the program, and possibly some input data. Your assembler program should use a memory array identical to the one it used in the Simpletron assignment and a data array with a counter to to collect the values from the input (I) commands. int memory[memsize]; int data[memsize]; int ndata; 3
4 Your program will also use an array of flags and a symbol table (both are described below). The symbol table will have 2,000 rows where each row is an instance of the structure below. The flags array must have a flag for each memory location. #define SYMBOLTABLESIZE 2000 struct tableentry { char *symbol; int location; /* Simpletron address (000 to MEMSIZE-1) */ } symboltable[symboltablesize]; /* end struct tableentry */ int flags[memsize]; After some minor initialization, the assembler performs two passes. The first pass constructs the symbol table in which every label of the assembly program is stored with its corresponding location in the final SML code (the symbol table is described in detail below) and fills the data array with the values from the input commands. The first pass always writes partial SML instructions by always writing 000 for SML operand. The flags array, in conjunction with the symbol table, will be used to complete these partial SML instructions by fillling in the missing SML operand values during the second pass (described below). Your program should use the following variables to record the Simpletron address for the next instruction and an index for the next symbol in the symbol table. int next_instruction_addr; int next_symbol_table_idx; The second pass of the assembler locates (using the flags array) and completes (using the symbol table) the partial instructions. After the second pass, the assembler prints the finished SML program, followed by any input data. 4.1 Initialization Your compiler must initialize all of the Simpletron s memory to and all the flags to -1. It should initialize all the entries of the symbol table by setting each symboltable[i].symbol to NULL and each symboltable[i].location to -1. It should initialize the next instruction address to the top of the Simpletron s memory (memory location 0), the index of the next entry into the symbol table to 0, and finally the counter for the Simpletron Assembly input instructions (I) to 0. next_instruction_addr = 0; next_symbol_table_idx = 0; ndata = 0; 4.2 Pass 1 The first pass of the assembler reads and processes the assembly program one line at a time. In processing a single line of the assembly program the assembler can make addition(s) to the symbol table, add a (possibly partial) SML instruction to the Simpletron s memory, or add constants and/or reserve words in the Simpletron s memory. Each time a new line is read from the assembly program, if it is a line that has a label which must start in the leftmost column, that label must be added to the symbol table along with the corresponding address of the next instruction of the SML program (next_instruction_addr). Note that no two lines of the program may have the same label (i.e., labels must be unique). Each time a constant or storage is declared (i.e., DC or DS) a single word of the Simpletron s memory is allocated exactly where the DC or DS instruction appeared. Instructions that require a label operand (all but H, DS, DC, and I) result in partial instructions where the SML operand is written as 000. The label 4
5 operand is searched for in the symbol table and added if it was not found. Either way (whether the symbol was already in the symbol table or it was just added) the element of the flags array associated with the Simpletron s memory is changed from -1 to the index into the symbol table where the label operand resides. Here we discuss the details of how to processes each of the Simpletron Assembly Instructions commands in the first pass. In discussing each it is assumed that comments will be ignored and that any label that appeared in the leftmost column of the line has already been added to the symbol table. Also, for each instruction that takes a label operand, it is assumed that you will search the symbol table for the label operand, adding, if necessary, the label (and leaving symboltable[i].location as -1 if just added). For those assembler instructions which are simply mnemonics for Simpletron operation codes (i.e., R, W, L, ST, A, S, M, D, B, BN, BZ, and H) write corresponding partial SML instruction (i.e., , , , etc.) at the memory location next_instruction_addr being careful to write the SML operand as 000. Of those instructions that have label operands (all but H), place the symbol table index of the label operand into the flags array in the slot corrsponding to next_instruction_addr. Finally, be sure to increment next_instruction_addr for the next SML instruction. DS. Simply zero the word at the memory location next_instruction_addr and increment next_instruction_addr. DC. Verify that the integer constant will fit into a word of the Simpletron s memory (i.e., the constant must be >= and <= 99999). If it s a valid constant, set the memory location next_instruction_addr to that constant and increment next_instruction_addr. I. Place the constant operand into data[ndata] and increment ndata. Note that you do not increment next_instruction_addr for input instructions. There are only 1,000 words in the Simpletron memory and it is possible to deplete that. If by adding instructions you find that you have run past the end of memory or have entered the variable/constant section of the memory, or if by allocating space for variables/constants you have entered the program section of the memory, simply print *** ERROR: ran out Simpletron memory and terminate the assembly immediately, (i.e., without printing the SML program). To illustrate the first pass of the assembler we take you through its steps as it processes the example program from section 1. We start with the first non-comment line of the program, R first. We write the partial SML instruction at memory location 000 and search the symbol table for the label operand first. Since it is not there, we add first to the first row of the symbol table by using strdup() to make a copy of the string first and placing the pointer to the copy in symboltable[0].symbol. We leave symboltable[0].location untouched. symboltable[0].location will be filled in when we encounter the symbol first in the leftmost column of the program. We then add the index of the symbol first (in this case 0) to the element of the flags array that corresponds with our SML instruction s address, again in this case 0 (i.e., flags[000] = 0). This completes the first pass assembly of the first line of our program. Assembly continues with the second line R second. Again, we write the partial SML instruction 10000, this time at memory location 001, add the symbol second to the second row of the symbol table, and conclude by setting flags[001] = 1. The third line is the input instruction I 10. We simply place the constant operand 10 into the first element of our data array and increment ndata. We process the next line I 20 by placing the constant operand 20 into the second element of the data array and incrementing ndata again. Note that in processing both of these input instructions we did not modify the Simpletron s memory, the symbol table, nor the flags array. We continue by ignoring the next three comment lines and processing the load instruction L first. We write the partial SML instruction at memory location 002 and search the symbol table for the label operand first. This time we find the symbol and we note that it is in 5
6 row 0 of the symbol table. We update the flags array accordingly by setting flags[002] = 0. We process the subtract instruction S second similarly by writing the partial SML at memory location 003 and setting flags[003] = 1. Assembly continues with BN printtwo where we again write the partial SML instruction at memory location 004, adding the label operand printtwo to the third row of the symbol table, and setting flags[004] = 2. BZ printtwo is processed similarly by writing the partial SML instruction at memory location 005 and setting flags[005] = 2. In processing the W one instruction we write the partial SML instruction at memory location 006, add the label operand one to the fourth row of the symbol table, and set flags[006] = 3. The halt instruction H allows us to write our first complete SML instruction in memory location 007, which also allows us to leave the flags array untouched for this instruction. Finally we come to our first instruction that has a symbol starting in the leftmost column, printtwo W two. We start by searching the symbol table for the label starting in the leftmost column (printtwo). In this case we find the label in the third row of the symbol table (placed there when we previously processed BN printtwo). If we did not find the symbol printtwo in the symbol table, we would have added it here. In either case, we may now update the location field for this row of the symbol table to the Simpletron s memory location where we are about to write the next instruction, (i.e., symboltable[2].location = 008). Having processed the symbol starting in the leftmost column, we continue our processing of printtwo W two by writing the partial SML instruction in memory location 008, adding two to the fifth row of the symbol table, and setting flags[008] = 4. We then encounter another halt instruction H so we write the SML instruction in memory location 009 and proceed into the storage section of our program. The next instruction first DS starts with a label, so we search the symbol table and find first in the first row of the table. We update the location field of that row by setting it to 010. We may then process the DS command by reserving a word in the Simpletron s memory and initializing it to zero, so we write in memory location 010. Likewise we process the next DS instruction by setting the location field of the second row of the symbol table to 011 and writing in memory location 011. Finally we come to our last two instructions of the program, both defining storage for constants. The first instruction one DC 1 is processed by searching and finding the label one in the fourth row of the symbol table and setting the location field of that row to 012. We then write reserve a word of the Simpletron s memory for this constant and initialize it the value of the operand by writing into memory location 012. The last instruction is processed in a similar manner by first updating the location field of the fifth row of our symbol table (corresponding to the label two) to 013 and writing into memory location 013. This concludes the assembler s first pass through the maximum program. At the end of the first pass data[0]=10, data[1]=20, and ndata=2, the symbol table is as it is presented in figure 3 and the Simpletron memory and flags arrays are presented in figure 2. 6
7 Assembly Program SML flags R first R second I 10 I 20 L first S second BN printtwo BZ printtwo W one H printtwo W two H first DS second DS one DC two DC Figure 2: memory and flags after first pass of maximum program. Values througout memory arrary are and in flags array is -1 unless otherwise stated. Symbol SMLaddr first 010 second 011 printtwo 008 one 012 two 013 Figure 3: Symbol table after first pass of maximum program. 4.3 Pass 2 The purpose of the second pass is to complete the partial instructions written in the first pass. This is done by traversing the flags array and completing any instruction whose corresponding flags value is!= -1. All other entries in flags[i] correspond to a partial instruction that needs completion. When you encounter an element of the flags array that is!= -1, use the non-negative value found there to index the symbol table and set the operand portion of the partial instruction to the location field of that row of the symbol table. There is one error that could occur during the second pass. If you find a row of the symbol table that still has location = -1, then you have an unresolved reference in which case you should print *** ERROR: unresolved reference and terminate the assembly immediately, (i.e., without printing the SML program). Returing to our example program above, we see that there are eight elements in the flags array that have values other than -1. Processing the first one (location 000) requires us to use the value in flags[000], in this case 0, as in index into our symbol table and to use the value the location field (in this case 010) to complete the partial instruction in memory location 000. This changes the partial instruction from to Similarly, the partial instruction in memory location 001 is completed and re-written as Use the flags array and the symboltable to complete the remaining partial instructions. 7
8 4.4 Print SML Program After the second pass you will have a complete SML program (no partial instructions) and a data array ready for printing. Print all the words you filled in the memory array, one word per line, followed by , and conclude by printing all the values read into the data array. Using the example program above, the output of your assembler should look like this: Files I Give You In /home/olympus/classes/handout/03fall/sas you will find a collection of Simpletron assembler programs. They include four programs that will assemble and a collection of programs that will not. The filename and brief description of each Simple program is in figure 4. Filename Expected Result Description Simpletron assembler programs that will not assemble. duplabel.a *** ERROR: duplicate symbol Program has duplicate symbol. bigpgm.a *** ERROR: ran out Simpletron memory Cannot allocate space for an instruction. nolabel.a *** ERROR: unresolved symbol Program has unresolved symbol. bigconst.a *** ERROR: illegal constant Defines constant > smallconst.a *** ERROR: illegal constant Defines constant < Simpletron assembler programs that will assemble. end.a no output 1 line Simple program, end. read.a print READ: value Reads an integer into a variable. rw.a READ and output value then constant Reads and prints a number and constant. max.a max of two input values Reads two numbers and prints 1 if first is greater, otherwise prints 2. Figure 4: Simpletron assembler programs we supply you. In that same directory you will find the executable script submit_sas and two executable files, simpletron.key, the solution to the Simpletron assignment, and sas.key, the solution to this assignment. You may use the Simpletron Assembly programs above along with the solutions simpletron.key and sas.key to debug your program. The output of your assembler and Simpletron must look exactly like the output produced by sas.key and simpletron.key. Your programs will be tested, for example, in the following manner, 8
9 % sas.key < max.a simpletron.key > max.key % sas < max.a simpletron > max.out % diff max.out max.key % Where sas and simpletron are your solutions. To be eligible for full credit your output must exactly match (empty diff) the output of simpletron.key for each of the Simpletron Assembler programs listed in the table above. Note this is a minimum requirement. We may test your programs with Simpletron Assembler programs other than those listed above. 6 Files You Must Write You will submit at least three files for this assignment, a makefile that will allow a make clean which removes all binary files and a make sas which produces your executable solution to this assignment which must appear in a file called sas, a header file called simpletron.h, and as manyu source file(s) as you like. The header file, simpletron.h, must contall all the #define statements that define the Simpletron s instruction set, (i.e., #define READ 10, #define WRITE 11, etc.). You may also include other informatino in simpletron.h as you see fit. Use submit_sas to submit (one at a time) your makefile and each of your source code files (i.e., do not submit your binary files). To submit your makefile, for example, simply type submit_sas makefile. 9
Special Section: Building Your Own Compiler
cshtp6_19_datastructures_compiler.fm Page 1 Tuesday, February 14, 2017 10:31 AM 1 Chapter 19 Special Section: Building Your Own Compiler In Exercises8.31 8.33, we introduced Simpletron Machine Language
More information19 Much that I bound, I could not free; Much that I freed returned to me. Lee Wilson Dodd
19 Much that I bound, I could not free; Much that I freed returned to me. Lee Wilson Dodd Will you walk a little faster? said a whiting to a snail, There s a porpoise close behind us, and he s treading
More informationIn this chapter you ll learn:
Much that I bound, I could not free; Much that I freed returned to me. Lee Wilson Dodd Will you walk a little faster? said a whiting to a snail, There s a porpoise close behind us, and he s treading on
More informationLab 03 - x86-64: atoi
CSCI0330 Intro Computer Systems Doeppner Lab 03 - x86-64: atoi Due: October 1, 2017 at 4pm 1 Introduction 1 2 Assignment 1 2.1 Algorithm 2 3 Assembling and Testing 3 3.1 A Text Editor, Makefile, and gdb
More informationIntroduction to Computer Science Midterm 3 Fall, Points
Introduction to Computer Science Fall, 2001 100 Points Notes 1. Tear off this sheet and use it to keep your answers covered at all times. 2. Turn the exam over and write your name next to the staple. Do
More informationGechstudentszone.wordpress.com
CHAPTER -2 2.1 Basic Assembler Functions: The basic assembler functions are: ASSEMBLERS-1 Translating mnemonic language code to its equivalent object code. Assigning machine addresses to symbolic labels.
More information2.2 THE MARIE Instruction Set Architecture
2.2 THE MARIE Instruction Set Architecture MARIE has a very simple, yet powerful, instruction set. The instruction set architecture (ISA) of a machine specifies the instructions that the computer can perform
More informationProgramming Using C Homework 5
Programming Using C Homework 5 1. In this problem you will simulate the execution of a computer s CPU. The computer that we will simulate has 32 bytes of addressable memory (each byte is uniquely addressed).
More informationThe CPU and Memory. How does a computer work? How does a computer interact with data? How are instructions performed? Recall schematic diagram:
The CPU and Memory How does a computer work? How does a computer interact with data? How are instructions performed? Recall schematic diagram: 1 Registers A register is a permanent storage location within
More informationCS401 - Computer Architecture and Assembly Language Programming Glossary By
CS401 - Computer Architecture and Assembly Language Programming Glossary By absolute address : A virtual (not physical) address within the process address space that is computed as an absolute number.
More informationChapter 2: Basic Elements of C++ Objectives. Objectives (cont d.) A C++ Program. Introduction
Chapter 2: Basic Elements of C++ C++ Programming: From Problem Analysis to Program Design, Fifth Edition 1 Objectives In this chapter, you will: Become familiar with functions, special symbols, and identifiers
More informationECE 30 Introduction to Computer Engineering
ECE 30 Introduction to Computer Engineering Study Problems, Set #3 Spring 2015 Use the MIPS assembly instructions listed below to solve the following problems. arithmetic add add sub subtract addi add
More informationCS52 - Assignment 8. Due Friday 4/15 at 5:00pm.
CS52 - Assignment 8 Due Friday 4/15 at 5:00pm https://xkcd.com/859/ This assignment is about scanning, parsing, and evaluating. It is a sneak peak into how programming languages are designed, compiled,
More informationLittle Man Computer (LMC)
Little Man Computer (LMC) A-level Computing Independent Study Project Part Two The Little Man Computer (LMC) is a simulator which models the basic features of a modern computer. It features a central processing
More informationFORM 1 (Please put your name and section number (001/10am or 002/2pm) on the scantron!!!!) CS 161 Exam II: True (A)/False(B) (2 pts each):
FORM 1 (Please put your name and section number (001/10am or 002/2pm) on the scantron!!!!) CS 161 Exam II: True (A)/False(B) (2 pts each): 1. If a function has default arguments, they can be located anywhere
More informationUNIT-II. Part-2: CENTRAL PROCESSING UNIT
Page1 UNIT-II Part-2: CENTRAL PROCESSING UNIT Stack Organization Instruction Formats Addressing Modes Data Transfer And Manipulation Program Control Reduced Instruction Set Computer (RISC) Introduction:
More informationReview of the C Programming Language for Principles of Operating Systems
Review of the C Programming Language for Principles of Operating Systems Prof. James L. Frankel Harvard University Version of 7:26 PM 4-Sep-2018 Copyright 2018, 2016, 2015 James L. Frankel. All rights
More informationC/C++ Programming for Engineers: Working with Integer Variables
C/C++ Programming for Engineers: Working with Integer Variables John T. Bell Department of Computer Science University of Illinois, Chicago Preview Every good program should begin with a large comment
More informationCopyright 2000 N. AYDIN. All rights reserved. 1
Computer Architecture Prof. Dr. Nizamettin AYDIN naydin@yildiz.edu.tr http://www.yildiz.edu.tr/~naydin A virtual processor for understanding instruction cycle The Visible Virtual Machine (VVM) 1 2 The
More informationObjectives. Chapter 2: Basic Elements of C++ Introduction. Objectives (cont d.) A C++ Program (cont d.) A C++ Program
Objectives Chapter 2: Basic Elements of C++ In this chapter, you will: Become familiar with functions, special symbols, and identifiers in C++ Explore simple data types Discover how a program evaluates
More informationChapter 2: Basic Elements of C++
Chapter 2: Basic Elements of C++ Objectives In this chapter, you will: Become familiar with functions, special symbols, and identifiers in C++ Explore simple data types Discover how a program evaluates
More informationCS 2604 Minor Project 1 Summer 2000
RPN Calculator For this project, you will design and implement a simple integer calculator, which interprets reverse Polish notation (RPN) expressions. There is no graphical interface. Calculator input
More informationCSIS1120A. 10. Instruction Set & Addressing Mode. CSIS1120A 10. Instruction Set & Addressing Mode 1
CSIS1120A 10. Instruction Set & Addressing Mode CSIS1120A 10. Instruction Set & Addressing Mode 1 Elements of a Machine Instruction Operation Code specifies the operation to be performed, e.g. ADD, SUB
More informationTHE MICROPROCESSOR Von Neumann s Architecture Model
THE ICROPROCESSOR Von Neumann s Architecture odel Input/Output unit Provides instructions and data emory unit Stores both instructions and data Arithmetic and logic unit Processes everything Control unit
More informationB.V. Patel Institute of Business Management, Computer & Information Technology, Uka Tarsadia University
Unit 1 Programming Language and Overview of C 1. State whether the following statements are true or false. a. Every line in a C program should end with a semicolon. b. In C language lowercase letters are
More informationUnit II Basic Computer Organization
1. Define the term. Internal Organization-The internal organization of a digital system is defined by the sequence of microoperations it performs on data stored in its registers. Program- A program is
More informationChapter 10 - Computer Arithmetic
Chapter 10 - Computer Arithmetic Luis Tarrataca luis.tarrataca@gmail.com CEFET-RJ L. Tarrataca Chapter 10 - Computer Arithmetic 1 / 126 1 Motivation 2 Arithmetic and Logic Unit 3 Integer representation
More informationThe Assembly Language of the Boz 5
The Assembly Language of the Boz 5 The Boz 5 uses bits 31 27 of the IR as a five bit opcode. Of the possible 32 opcodes, only 26 are implemented. Op-Code Mnemonic Description 00000 HLT Halt the Computer
More informationSyntax of LC-3 assembly: Language elements. Instructions
LC-3 Assembly Language (Textbook Chapter 7) Assembly and assembler Machine language - binary 0001110010000110 Assembly language - symbolic ADD R6, R2, R6 ; increment index reg. Assembler is a program that
More informationLe L c e t c ur u e e 2 To T p o i p c i s c t o o b e b e co c v o e v r e ed e Variables Operators
Course Name: Advanced Java Lecture 2 Topics to be covered Variables Operators Variables -Introduction A variables can be considered as a name given to the location in memory where values are stored. One
More informationSAM Architecture Reference (Revised)
SAM Architecture Reference (Revised) Mika Nyström Department of Computer Science California Institute of Technology Pasadena, California, U.S.A. 2000 April 19, 2000 Revised April 2, 2002 1. Introduction
More informationHomework #3 CS2255 Fall 2012
Homework #3 CS2255 Fall 2012 MULTIPLE CHOICE 1. The, also known as the address operator, returns the memory address of a variable. a. asterisk ( * ) b. ampersand ( & ) c. percent sign (%) d. exclamation
More informationPart 1 (70% of grade for homework 2): MIPS Programming: Simulating a simple computer
CS 465 - Homework 2 Fall 2016 Profs. Daniel A. Menasce and Yutao Zhong Team Allowed: maximum of two per team. State clearly team member names and GMU IDs as comments in source code and each page of submitted
More informationThe C Programming Language Guide for the Robot Course work Module
The C Programming Language Guide for the Robot Course work Module Eric Peasley 2018 v6.4 1 2 Table of Contents Variables...5 Assignments...6 Entering Numbers...6 Operators...7 Arithmetic Operators...7
More informationC Review. MaxMSP Developers Workshop Summer 2009 CNMAT
C Review MaxMSP Developers Workshop Summer 2009 CNMAT C Syntax Program control (loops, branches): Function calls Math: +, -, *, /, ++, -- Variables, types, structures, assignment Pointers and memory (***
More informationCS61C Machine Structures. Lecture 4 C Pointers and Arrays. 1/25/2006 John Wawrzynek. www-inst.eecs.berkeley.edu/~cs61c/
CS61C Machine Structures Lecture 4 C Pointers and Arrays 1/25/2006 John Wawrzynek (www.cs.berkeley.edu/~johnw) www-inst.eecs.berkeley.edu/~cs61c/ CS 61C L04 C Pointers (1) Common C Error There is a difference
More informationMachine Language Instructions Introduction. Instructions Words of a language understood by machine. Instruction set Vocabulary of the machine
Machine Language Instructions Introduction Instructions Words of a language understood by machine Instruction set Vocabulary of the machine Current goal: to relate a high level language to instruction
More informationRelationship between Pointers and Arrays
Relationship between Pointers and Arrays Arrays and pointers are intimately related in C and often may be used interchangeably. An array name can be thought of as a constant pointer. Pointers can be used
More informationChapter 6: An Introduction to System Software and Virtual Machines
Objectives Chapter 6: An Introduction to System Software and Virtual Machines Invitation to Computer Science, C++ Version, Third Edition In this chapter, you will learn about: System software Assemblers
More information9/5/2018. Overview. The C Programming Language. Transitioning to C from Python. Why C? Hello, world! Programming in C
Overview The C Programming Language (with material from Dr. Bin Ren, William & Mary Computer Science) Motivation Hello, world! Basic Data Types Variables Arithmetic Operators Relational Operators Assignments
More informationIntroduction to MiniSim A Simple von Neumann Machine
Math 121: Introduction to Computing Handout #19 Introduction to MiniSim A Simple von Neumann Machine Programming languages like C, C++, Java, or even Karel are called high-level languages because they
More informationMaciej Sobieraj. Lecture 1
Maciej Sobieraj Lecture 1 Outline 1. Introduction to computer programming 2. Advanced flow control and data aggregates Your first program First we need to define our expectations for the program. They
More informationDigital Forensics Lecture 3 - Reverse Engineering
Digital Forensics Lecture 3 - Reverse Engineering Low-Level Software Akbar S. Namin Texas Tech University Spring 2017 Reverse Engineering High-Level Software Low-level aspects of software are often the
More informationThe C Programming Language. (with material from Dr. Bin Ren, William & Mary Computer Science)
The C Programming Language (with material from Dr. Bin Ren, William & Mary Computer Science) 1 Overview Motivation Hello, world! Basic Data Types Variables Arithmetic Operators Relational Operators Assignments
More informationModern Programming Languages Lecture An Introduction to SNOBOL Programming Language
Modern Programming Languages Lecture 9-12 An Introduction to SNOBOL Programming Language SNOBOL stands for StriNg Oriented SymBOlic Language. It is a Special purpose language for string manipulation and
More information1 Little Man Computer
1 Little Man Computer Session 5 Reference Notes CPU Architecture and Assembly 1.1 Versions Little Man Computer is a widely used simulator of a (very simple) computer. There are a number of implementations.
More informationby Pearson Education, Inc. All Rights Reserved.
Let s improve the bubble sort program of Fig. 6.15 to use two functions bubblesort and swap. Function bubblesort sorts the array. It calls function swap (line 51) to exchange the array elements array[j]
More informationCS LIR Language Specification and microlir Simulator Version 1.2
CS368-3133 LIR Language Specification and microlir Simulator Version 1.2 This document specifies the LIR language and describes a simulator for the langauge. The latest version of this document and the
More informationHave examined process Creating program Have developed program Written in C Source code
Preprocessing, Compiling, Assembling, and Linking Introduction In this lesson will examine Architecture of C program Introduce C preprocessor and preprocessor directives How to use preprocessor s directives
More informationCS311 Lecture: The Architecture of a Simple Computer
CS311 Lecture: The Architecture of a Simple Computer Objectives: July 30, 2003 1. To introduce the MARIE architecture developed in Null ch. 4 2. To introduce writing programs in assembly language Materials:
More informationMicroprocessors and Microcontrollers Prof. Santanu Chattopadhyay Department of E & EC Engineering Indian Institute of Technology, Kharagpur
Microprocessors and Microcontrollers Prof. Santanu Chattopadhyay Department of E & EC Engineering Indian Institute of Technology, Kharagpur Lecture - 09 8085 Microprocessors (Contd.) (Refer Slide Time:
More informationCSCI 2212: Intermediate Programming / C Review, Chapters 10 and 11
... 1/16 CSCI 2212: Intermediate Programming / C Review, Chapters 10 and 11 Alice E. Fischer February 3, 2016 ... 2/16 Outline Basic Types and Diagrams ... 3/16 Basic Types and Diagrams Types in C C has
More informationReview of the C Programming Language
Review of the C Programming Language Prof. James L. Frankel Harvard University Version of 11:55 AM 22-Apr-2018 Copyright 2018, 2016, 2015 James L. Frankel. All rights reserved. Reference Manual for the
More informationInstruction Sets: Characteristics and Functions Addressing Modes
Instruction Sets: Characteristics and Functions Addressing Modes Chapters 10 and 11, William Stallings Computer Organization and Architecture 7 th Edition What is an Instruction Set? The complete collection
More informationECE 375: Computer Organization and Assembly Language Programming
ECE 375: Computer Organization and Assembly Language Programming SECTION OVERVIEW Lab 5 Large Number Arithmetic Complete the following objectives: ˆ Understand and use arithmetic/alu instructions. ˆ Manipulate
More informationRepetition Structures
Repetition Structures Chapter 5 Fall 2016, CSUS Introduction to Repetition Structures Chapter 5.1 1 Introduction to Repetition Structures A repetition structure causes a statement or set of statements
More informationWhat is Pointer? Pointer is a variable that holds a memory address, usually location of another variable.
CHAPTER 08 POINTERS What is Pointer? Pointer is a variable that holds a memory address, usually location of another variable. The Pointers are one of the C++ s most useful and powerful features. How Pointers
More informationCondition-Controlled Loop. Condition-Controlled Loop. If Statement. Various Forms. Conditional-Controlled Loop. Loop Caution.
Repetition Structures Introduction to Repetition Structures Chapter 5 Spring 2016, CSUS Chapter 5.1 Introduction to Repetition Structures The Problems with Duplicate Code A repetition structure causes
More informationCS 2604 Minor Project 1 DRAFT Fall 2000
RPN Calculator For this project, you will design and implement a simple integer calculator, which interprets reverse Polish notation (RPN) expressions. There is no graphical interface. Calculator input
More informationINITIALISING POINTER VARIABLES; DYNAMIC VARIABLES; OPERATIONS ON POINTERS
INITIALISING POINTER VARIABLES; DYNAMIC VARIABLES; OPERATIONS ON POINTERS Pages 792 to 800 Anna Rakitianskaia, University of Pretoria INITIALISING POINTER VARIABLES Pointer variables are declared by putting
More informationControl Structures. Lecture 4 COP 3014 Fall September 18, 2017
Control Structures Lecture 4 COP 3014 Fall 2017 September 18, 2017 Control Flow Control flow refers to the specification of the order in which the individual statements, instructions or function calls
More informationLC-3 Assembly Language. (Textbook Chapter 7)"
LC-3 Assembly Language (Textbook Chapter 7)" Assembly and assembler" Machine language - binary" 0001110010000110 Assembly language - symbolic" ADD R6, R2, R6 ; increment index reg. Assembler is a program
More informationLab8: SAM Assembler and Simulator
Lab8: SAM Assembler and Simulator Due Date: Wednesday April 29th 2009 by midnight Background: The Instruction Set Architecture (ISA) provides a view of a processor's features as seen from the perspective
More informationWilliam Stallings Computer Organization and Architecture 8 th Edition. Chapter 11 Instruction Sets: Addressing Modes and Formats
William Stallings Computer Organization and Architecture 8 th Edition Chapter 11 Instruction Sets: Addressing Modes and Formats Addressing Modes Immediate Direct Indirect Register Register Indirect Displacement
More informationBasic program The following is a basic program in C++; Basic C++ Source Code Compiler Object Code Linker (with libraries) Executable
Basic C++ Overview C++ is a version of the older C programming language. This is a language that is used for a wide variety of applications and which has a mature base of compilers and libraries. C++ is
More informationCS61C : Machine Structures
inst.eecs.berkeley.edu/~cs61c CS61C : Machine Structures Lecture 4 C Pointers 2004-09-08 Lecturer PSOE Dan Garcia www.cs.berkeley.edu/~ddgarcia Cal flies over Air Force We re ranked 13 th in the US and
More informationChapter 2. Assembler Design
Chapter 2 Assembler Design Assembler is system software which is used to convert an assembly language program to its equivalent object code. The input to the assembler is a source code written in assembly
More informationLecture-30 Assemblers To assemble a program automatically the assembler needs information in the form of assembler direct that controls the assembly.
Lecture-30 Assemblers To assemble a program automatically the assembler needs information in the form of assembler direct that controls the assembly. E.g. the assembler must be told at what address to
More informationSubject: PROBLEM SOLVING THROUGH C Time: 3 Hours Max. Marks: 100
Code: DC-05 Subject: PROBLEM SOLVING THROUGH C Time: 3 Hours Max. Marks: 100 NOTE: There are 11 Questions in all. Question 1 is compulsory and carries 16 marks. Answer to Q. 1. must be written in the space
More informationCS 430 Computer Architecture. C/Assembler Arithmetic and Memory Access William J. Taffe. David Patterson
CS 430 Computer Architecture C/Assembler Arithmetic and Memory Access William J. Taffe using notes of David Patterson 1 Overview C operators, operands Variables in Assembly: Registers Comments in Assembly
More informationECE 5750 Advanced Computer Architecture Programming Assignment #1
ECE 5750 Advanced Computer Architecture Programming Assignment #1 Objective The objective of this assignment is to gain hands-on experience in writing parallel programs for shared-memory machines. You
More information(Not Quite) Minijava
(Not Quite) Minijava CMCS22620, Spring 2004 April 5, 2004 1 Syntax program mainclass classdecl mainclass class identifier { public static void main ( String [] identifier ) block } classdecl class identifier
More informationMicrocontroller Systems
µcontroller systems 1 / 43 Microcontroller Systems Engineering Science 2nd year A2 Lectures Prof David Murray david.murray@eng.ox.ac.uk www.robots.ox.ac.uk/ dwm/courses/2co Michaelmas 2014 µcontroller
More informationA Fast Review of C Essentials Part I
A Fast Review of C Essentials Part I Structural Programming by Z. Cihan TAYSI Outline Program development C Essentials Functions Variables & constants Names Formatting Comments Preprocessor Data types
More informationProject #1 Exceptions and Simple System Calls
Project #1 Exceptions and Simple System Calls Introduction to Operating Systems Assigned: January 21, 2004 CSE421 Due: February 17, 2004 11:59:59 PM The first project is designed to further your understanding
More informationFull file at C How to Program, 6/e Multiple Choice Test Bank
2.1 Introduction 2.2 A Simple Program: Printing a Line of Text 2.1 Lines beginning with let the computer know that the rest of the line is a comment. (a) /* (b) ** (c) REM (d)
More informationCHAPTER ASSEMBLY LANGUAGE PROGRAMMING
CHAPTER 2 8051 ASSEMBLY LANGUAGE PROGRAMMING Registers Register are used to store information temporarily: A byte of data to be processed An address pointing to the data to be fetched The vast majority
More informationCS1622. Semantic Analysis. The Compiler So Far. Lecture 15 Semantic Analysis. How to build symbol tables How to use them to find
CS1622 Lecture 15 Semantic Analysis CS 1622 Lecture 15 1 Semantic Analysis How to build symbol tables How to use them to find multiply-declared and undeclared variables. How to perform type checking CS
More informationChapter 2 Basic Elements of C++
C++ Programming: From Problem Analysis to Program Design, Fifth Edition 2-1 Chapter 2 Basic Elements of C++ At a Glance Instructor s Manual Table of Contents Overview Objectives s Quick Quizzes Class Discussion
More information17. Instruction Sets: Characteristics and Functions
17. Instruction Sets: Characteristics and Functions Chapter 12 Spring 2016 CS430 - Computer Architecture 1 Introduction Section 12.1, 12.2, and 12.3 pp. 406-418 Computer Designer: Machine instruction set
More informationSemantic Analysis. Outline. The role of semantic analysis in a compiler. Scope. Types. Where we are. The Compiler Front-End
Outline Semantic Analysis The role of semantic analysis in a compiler A laundry list of tasks Scope Static vs. Dynamic scoping Implementation: symbol tables Types Static analyses that detect type errors
More information68000 Assembler by Paul McKee. User's Manual
Contents 68000 Assembler by Paul McKee User's Manual 1 Introduction 2 2 Source Code Format 2 2.1 Source Line Format............................... 2 2.1.1 Label Field............................... 2 2.1.2
More informationA flow chart is a graphical or symbolic representation of a process.
Q1. Define Algorithm with example? Answer:- A sequential solution of any program that written in human language, called algorithm. Algorithm is first step of the solution process, after the analysis of
More informationCompilers Project 3: Semantic Analyzer
Compilers Project 3: Semantic Analyzer CSE 40243 Due April 11, 2006 Updated March 14, 2006 Overview Your compiler is halfway done. It now can both recognize individual elements of the language (scan) and
More informationCSC201, SECTION 002, Fall 2000: Homework Assignment #3
1 of 7 11/8/2003 7:34 PM CSC201, SECTION 002, Fall 2000: Homework Assignment #3 DUE DATE October 25 for the homework problems, in class. October 27 for the programs, in class. INSTRUCTIONS FOR HOMEWORK
More informationDEPARTMENT OF COMPUTER AND MATHEMATICAL SCIENCES UNIVERSITI TEKNOLOGI MARA CAWANGAN PULAU PINANG
DEPARTMENT OF COMPUTER AND MATHEMATICAL SCIENCES UNIVERSITI TEKNOLOGI MARA CAWANGAN PULAU PINANG PROGRAMME Diploma in Civil Engineering Diploma in Mechanical Engineering COURSE/CODE Fundamentals of Computer
More informationCS /534 Compiler Construction University of Massachusetts Lowell
CS 91.406/534 Compiler Construction University of Massachusetts Lowell Professor Li Xu Fall 2004 Lab Project 2: Parser and Type Checker for NOTHING Due: Sunday, November 14, 2004, 11:59 PM 1 Introduction
More informationCHAPTER 7 ARRAYS: SETS OF SIMILAR DATA ITEMS
CHAPTER 7 ARRAYS: SETS OF SIMILAR DATA ITEMS Computers process information and usually they need to process masses of information. In previous chapters we have studied programs that contain a few variables
More informationAssignment 5: MyString COP3330 Fall 2017
Assignment 5: MyString COP3330 Fall 2017 Due: Wednesday, November 15, 2017 at 11:59 PM Objective This assignment will provide experience in managing dynamic memory allocation inside a class as well as
More informationORG ; TWO. Assembly Language Programming
Dec 2 Hex 2 Bin 00000010 ORG ; TWO Assembly Language Programming OBJECTIVES this chapter enables the student to: Explain the difference between Assembly language instructions and pseudo-instructions. Identify
More informationWEEK 4 OPERATORS, EXPRESSIONS AND STATEMENTS
WEEK 4 OPERATORS, EXPRESSIONS AND STATEMENTS OPERATORS Review: Data values can appear as literals or be stored in variables/constants Data values can be returned by method calls Operators: special symbols
More information3.Constructors and Destructors. Develop cpp program to implement constructor and destructor.
3.Constructors and Destructors Develop cpp program to implement constructor and destructor. Constructors A constructor is a special member function whose task is to initialize the objects of its class.
More informationModule 6: Array in C
1 Table of Content 1. Introduction 2. Basics of array 3. Types of Array 4. Declaring Arrays 5. Initializing an array 6. Processing an array 7. Summary Learning objectives 1. To understand the concept of
More informationLectures 5-6: Introduction to C
Lectures 5-6: Introduction to C Motivation: C is both a high and a low-level language Very useful for systems programming Faster than Java This intro assumes knowledge of Java Focus is on differences Most
More informationC++ Basic Elements of COMPUTER PROGRAMMING. Special symbols include: Word symbols. Objectives. Programming. Symbols. Symbols.
EEE-117 COMPUTER PROGRAMMING Basic Elements of C++ Objectives General Questions Become familiar with the basic components of a C++ program functions, special symbols, and identifiers Data types Arithmetic
More informationModule 5 - CPU Design
Module 5 - CPU Design Lecture 1 - Introduction to CPU The operation or task that must perform by CPU is: Fetch Instruction: The CPU reads an instruction from memory. Interpret Instruction: The instruction
More informationAnnouncements HW1 is due on this Friday (Sept 12th) Appendix A is very helpful to HW1. Check out system calls
Announcements HW1 is due on this Friday (Sept 12 th ) Appendix A is very helpful to HW1. Check out system calls on Page A-48. Ask TA (Liquan chen: liquan@ece.rutgers.edu) about homework related questions.
More informationJim Lambers ENERGY 211 / CME 211 Autumn Quarter Programming Project 4
Jim Lambers ENERGY 211 / CME 211 Autumn Quarter 2008-09 Programming Project 4 This project is due at 11:59pm on Friday, October 31. 1 Introduction In this project, you will do the following: 1. Implement
More informationCHAPTER SEVEN PROGRAMMING THE BASIC COMPUTER
CHAPTER SEVEN 71 Introduction PROGRAMMING THE BASIC COMPUTER A computer system as it was mentioned before in chapter 1, it is subdivided into two functional parts: 1 Hardware, which consists of all physical
More informationCS 211 Programming Practicum Fall 2018
Due: Wednesday, 11/7/18 at 11:59 pm Infix Expression Evaluator Programming Project 5 For this lab, write a C++ program that will evaluate an infix expression. The algorithm REQUIRED for this program will
More information