Monday, February 11, 2013

Size: px
Start display at page:

Download "Monday, February 11, 2013"

Transcription

1 Monday, February 11, 2013 Topics for today The Pep/8 memory Four example programs The loader The assembly language level (Chapter 5) Symbolic Instructions Assembler directives Immediate mode and equate Location of variables in a program Trap instructions Symbols in Pep/8 Math operations in Pep/8 Compilers and Assemblers Making Assembly Code Readable Example translations from high-level language The Pep/8 memory Diagrams in the book (eg Fig 437) can be misleading as to the relative sizes of various sections of the Pep/8 memory For example, from Fig 437 you might think the area available for Application Programs and the area used by the Operating System are about the same size Here is a summary of the memory Application Program Area Address Range 0FBCE 16 (064462) Contents About 98% of the memory! In this area is the user program and the runtime stack The user program occupies bytes 0 onwards and the stack grows upwards toward the user program The stack typically grows and shrinks as the program runs It is possible for the stack to run into and overwrite the user program Operating System Area FBCFFC56 16 ( ) FC47FFFF 16 ( ) RAM - Here is the variable part of the operating system: The system stack (128 bytes) and the I/O buffer (108 bytes) ROM - Here is the unchanging part of the operating system: the loader (about 64 bytes), the trap handler (about 863 bytes) and pointers to (a) base of user stack, (b) I/O buffer, (c) start of loader, (d) start of trap handler Comp 162 Notes Page 1 of 19 February 11, 2013

2 Four Example programs We look at four example programs from the book to get an idea of how the Pep/8 machine operates Once we get to Chapter 5, we will abandon machine code programming Example 1: Fig 432 This is a very simple program The instruction to output a character has first byte followed by a two-byte operand Here is how the first byte is interpreted opcode mode In general, an addressing mode tells the CPU how to use the two-byte number that follows the opcode byte When mode= 001 the number is treated as the address of the operand At this point in our look at low-level programming, the programmer has to figure out addresses of data locations (this will change when we get to Chapter 5) This program outputs Hi with the ASCII codes for H and i in the two bytes following the STOP instruction Example 2: Figure 434 Uses the character input instruction which has first byte opcode mode We read from the input device (can be either the keyboard or the active window) into the memory There is no way to read data directly from an external source directly into a register Note that the data locations here are further down memory than those in Fig 432 because we have more room taken up by instructions This program uses two memory locations to store characters from input then outputs them in reverse order Example 3: Figure 435 This program adds two constants (3,5) then outputs their sum The program has to convert the result of the sum (0008) into the ASCII code for 8 (which is 0038) It does the conversion by OR-ing the register with 30(hex) Clearly program is not very general and will not work if the sum > 9 Comp 162 Notes Page 2 of 19 February 11, 2013

3 Example 4: Figure 436: a self-modifying program Address Contents 0 D D 3 F C A 00 B 19 The first two instructions of the program get a byte (81) from location 1D (hex) and store it in location 9 Byte 9 is the opcode byte of the 4 th instruction of the program The effect of the modification is to change the 4 th instruction from an Add (opcode byte 71) to a Sub (opcode byte 81) instruction Now instead of adding data locations containing 5 and 3, it subtracts 3 from 5 Not very interesting but it does demonstrate that the program code is not "write protected" in any way (In contrast, part of the operating system is write-protected and cannot be modified by a user program) We can imagine a more interesting program that (1) is interactive - letting the user input the new opcode or (2) changes an operand rather than an opcode so that the address on which the instruction operates is changed The loader One of the built-in utilities in the Pep/8 system is a facility to load a program (written in hex) into memory Example in Fig 441 shows the format required for a file that is to be loaded The loader is a very simple program it is listed in Fig 83 if you are interested The loader is fussy about the form of the input (1) between hex numbers is a single space or a newline (2) program is terminated with zz We can write programs in hexadecimal and have the Pep/8 system run them The three steps involved are as follows (may be different for different versions of Pep/8): Comp 162 Notes Page 3 of 19 February 11, 2013

4 (1) Enter your hex program in the Object Code window remembering the loader conventions above (2) If the program inputs data from the user then above the Input window, select tab to Terminal I/O (3) Under Build select Run Object This will load your program into the Pep/8 memory and if that succeeds, will execute the program You can see that writing programs in hex is tedious and error prone Hex programs are difficult to write, to edit, to read and to debug So two of the earliest developments in computing (back in the 1950s) were symbolic languages (assembly code) translators (assemblers) from assembly code to machine code Warford s Chapter 5 looks at symbolic programming and the way in which assemblers work Chapter 5 In Chapter 5, Warford moves up a level in the multi-level machine to the assembly language level Assembly code enables programs to be written using symbols instead of numbers Some advanced assembly languages have features similar to those in high-level languages (loops and if constructs) Compared with high-level language programs, assembly code programs have a relatively simple structure Possibly because early systems used punched cards for input, a typical assembly language is line-oriented, ie, not free-form like a high-level language Each line is one of three types * a symbolic machine language instruction (maybe with commentary) * commentary only * an assembler directive or "pseudo operation" The Assembler - so called because it assembles the pieces of program - translates symbols to numbers and outputs an object program The order of items in the object program may be different from their order in the source program Comp 162 Notes Page 4 of 19 February 11, 2013

5 Source Program Assembler Object Program In some Pep/8 systems, source programs have a pep extension and object files have a pepo extension (1) Symbolic instructions The typical format of a symbolic instruction (with optional components shown in square brackets) is: [ label ] opcode [operands] [ ; commentary ] Examples LOOP: LDA 0,i ; initialize counter BRGE END ; branch if sum > 0 STOP NEXT: ASLA ; now double it The following are typical symbolic instructions in the Pep/8 assembly language: LDA 0,i STRO Mesg4,d CHARO '\n',i CPA 0x3F1E,i STOP The table in Fig 52 is an expanded version of the table in Fig 46 It lists the instructions available to assembly language programmers In addition to the binary Instruction Specifier that we saw in Chapter 4, the table shows for each instruction, (1) the Mnemonic (symbolic opcode) that the assembler recognizes (2) whether the instruction is unary (one byte long) or non-unary (three bytes long) (3) which addressing modes are legal to use with this instruction (4) which of the four status bits might be changed (if any) by the action of the instruction Comp 162 Notes Page 5 of 19 February 11, 2013

6 If you compare Fig 52 with Fig 46 you will see there are a few subtle changes The five instructions listed as unimplemented opcode in chapter 4 now appear either as high-level input/output (deco, deci, stro) or as no-operation trap instructions (nop, nopn) (2) Comments In Pep/8, any text between semi-colon and end of line is commentary, thus ; this line is just comment ; the following instruction has commentary lda M,d ; get count of lines to output Writing good comments in a program is an art more on this later (3) Assembler directives / "Pseudo operations" An assembler directive is just an instruction to the assembler (translation program) to perform some action at assembly (translation) time In assembly languages it is a common convention for such directives to begin with a period, ie xxx yyy This makes it easy for the assembler to distinguish them from symbolic machine instructions These directives are sometimes called "pseudo operations" (Warford uses this term) because (apart from the period) they look like symbolic machine operations but are not really There is a list of the Pep/8 pseudo operations on Page 194 Most of them are concerned with reserving space in the program for data locations Thus we have block N word A byte B ascii/abcdefg/ ; reserve N bytes of space ; reserve a word initialized to A ; reserve a byte initialized to B ; initialize bytes with sequence of characters There is also which every program must have It marks the physical end of the source program the assembler does not read beyond this line Here are some approximate equivalencies between declarations in a high-level declarations and pseudo operations in Pep/8 Comp 162 Notes Page 6 of 19 February 11, 2013

7 int A; A: block 2 char B; B: block 1 int C = 50; C: word 50 char D = '%'; char E[] = "xyz"; D: byte '%' E: ascii xyz byte 0 OR E: ascii xyz\x00 int F [30]; F: block 60 char G [25]; G: block 25 In the case of string xyz, the extra zero byte ( \x00 ) acts as a string terminator used by the stro instruction Example Assembly code program The program in Fig 53 outputs Hi (without the quotes) to the screen CHARO 0x0007,d ;Output 'H' CHARO 0x0008,d ;Output 'i' STOP ASCII "Hi" END We will see later that other features of the assembly language let us improve on this program Note that END is the very last line and the STOP after the two instructions s the program and prevents it from running into the data Immediate Mode (see section 52) It is not necessary to have immediate mode Consider the following program that inputs a number then outputs the number that is 5 greater than the number input deci N,d ; get a number lda N,d ; load it into Register A adda five,d ; add the contents of a location containing 5 sta N,d ; overwrite the original number deco N,d ; and output updated quantity N: block 2 ; space for the number five: word 5 ; a location containing 5 Comp 162 Notes Page 7 of 19 February 11, 2013

8 We can store all constants that the program needs in their own memory locations like this But it is shorter (and a little faster) if we are able to use the number 5 as part of an instruction as in the following: deci N,d lda N,d adda 5,i ; add 5 to register immediate mode sta N,d deco N,d N: block 2 The ",i" in the adda instruction indicates immediate mode It indicates that 5 is the operand itself Contrast this with lda 5,d ; add contents of word at memory location 5 The ",d" here indicates direct mode - the 5 is the address of the operand (which must therefore be fetched using an additional read) Immediate mode is faster because we have one fewer memory read The equate directive Consider the following program fragment ; Program A lda limit,d cpx limit,d suba limit,d limit: word 19 Perhaps it is part of a registration program and the variable "limit" holds the largest number of units that a student can register for The following program (B) using immediate mode runs faster ; Program B lda 19,i cpx 19,i suba 19,i Comp 162 Notes Page 8 of 19 February 11, 2013

9 But program B has two disadvantages: (1) if we need to change the limit we have multiple edits to make; we may miss one and make the program inconsistent (2) the constant 19 appearing in the program does not indicate what it represents A solution that combines the readability and editability of program A with the speed of program B is the following ; Program C limit: equate 19 lda limit,i cpx limit,i suba limit,i The equate directive lets us associate a symbolic name with a value After assembly, programs B and C are identical Location of variable declarations Where do variables go in an assembly language program? To a certain extent it is a matter of programming style but we have to be sure that program execution cannot run into them Two possibilities are: (1) after STOP and before END <executable instructions go here> ; program will halt at this line A: word 3 B: block 4 C: word 17 (2) at the beginning of the program in which case we need to skip over them and have something like br main ; transfer control to instruction labeled main a: block 2 b: block 2 main: <first executable instruction> The br (branch) instruction does an unconditional transfer of control to the specified location Warford prefers style (2) in his example programs Comp 162 Notes Page 9 of 19 February 11, 2013

10 Here are four translations of the following pseudocode program int a=30, b=25, c; c = a+b; output (c); Two of the translations have errors Which? Program 1 Program 2 Program 3 Program 4 adda b,d sta c,d deco c,d a: word 30 b: word 25 c: block 2 a: word 30 b: word 25 c: block 2 adda b,d sta c,d deco c,d br main a: word 30 b: word 25 c: block 2 main: adda b,d sta c,d deco c,d adda b,d sta c,d deco c,d a: word 30 b: word 25 c: block 2 Program 1: is correct Program 2: halts at byte 0 when the program tries to execute a data location Program 3: is correct Program 4: fails to assemble because the assembler does not read anything after so does not see the definitions of symbols a, b and c Trap Instructions Instruction DECO, DECI and STRO exist at the assembly language level but not at the machine language level So what happens when the system encounters one during the running of a program? Answer - the system springs a "trap" which takes the following form (see Fig 439) - the user program is suspended - important data areas are saved on the system stack (registers, status bits) - control is transferred to the Trap Handler in the operating system - the operating system code takes appropriate action depending on the particular instruction Comp 162 Notes Page 10 of 19 February 11, 2013

11 - the data saved is restored - control is returned to the user program using the RETTR (return from trap) instruction Thus these three instructions are very slow compared with non-trap instructions Here is what appropriate action" means for the various instructions: DECI: uses CHARI to input characters Checks they form a legal integer Outputs an Error message if invalid characters are input DECO: converts number to string of digit characters, uses CHARO to output them STRO: uses CHARO to output a null-terminated string of characters Recall that we can set up a string in memory using the ascii directive How does STRO know the length of the string Pep/8 could use one of two ways: (a) a byte at the beginning of the string indicating length (b) an end-of-string marker It uses method (b) and the ASCII NUL byte (code 0) as the marker This is the same method that C uses to delimit strings We can set up a null-terminated string a couple of different ways msg: ascii "message" byte 0 or simply msg: ascii "message\x00" There are very few situations where a programmer needs to be aware that an instruction is a trapped instruction rather than a normal instruction In addition to the three instructions above, NOP and NOPa are also trapped These are no operation instructions; sometimes it is useful to have an instruction that doesn t do anything! Symbols in Pep/8 Identifiers: follow usual identifier rules (start with a letter, continue with letters, underscore or digits) but in Pep/8 they can be no more than 8 chars long Many assembly languages have similar length restrictions Pep/8 will give an error message rather than just using the first 8 characters longername: block 2;ERROR: Symbol longername cannot have more than eight characters Numbers: can be decimal 1234 or hex 0xFF8E (The hex notation is similar to some high-level languages) Comp 162 Notes Page 11 of 19 February 11, 2013

12 Characters: eg '*' (single quotes) '\n' '\t' '\x00' Strings: eg "Output follows\n" (double quotes) Ultimately, everything is bits We can manipulate the contents of memory in nonstandard ways Consider the following program this: stro this,d When run, this program outputs A Why? The translation of the program is When it runs it outputs the string starting at location 0 that terminates with a null (zero) bytes The first two bytes of the program in hex are The ASCII code for A is 41 (hex) Consider also the following self-modifying program that we saw a version of earlier ldbytea 0x70,i stbytea X,d lda 8,i X: suba 3,i sta N,d deco N,d N: block 2 When it runs, the program modifies the byte at X This is the opcode byte of the 4th instruction It changes it from 80 (SUB) to 70 (ADD) so the program outputs 11 not 5 Math operations in Pep/8 Multiplication If we are multiplying by a power of 2 then we just need a sequence of left shifts Thus, to compute N * 8 lda N,d asla asla asla Comp 162 Notes Page 12 of 19 February 11, 2013

13 In general we can accomplish multiplication using shifting and adding The following sequence computes M * 29 [ 29 is 11101, can you see a general pattern here? ] Division lda M,d ; M asla ; M * 2 adda M,d ; M * 3 asla ; M * 6 adda M,d ; M * 7 asla ; M * 14 asla ; M * 28 adda M,d ; M * 29 We can easily compute X/Y if Y is a power of 2 using right shifts If Y is not a power of 2, the required program is more complex For example, to compute P/16 lda P,d asra asra asra asra Modulus We can easily compute P%Q if P is positive and Q is a power of 2 For example the result if T % 8 is the rightmost 3 bits of T thus lda T,d anda 7,i In general, it is more difficult as the following table illustrates M N M%N M&(N-1) Comp 162 Notes Page 13 of 19 February 11, 2013

14 Simple arithmetic and assignment statement High-level language: M = N * 8 + T; Pep/8: lda N,d asla asla asla adda T,d sta M,d Compilers and Assemblers Both compilers and assemblers are translation programs Both use symbol tables but the compiler symbol table has to record information such as type and scope of the identifiers Compiler does type checking that an assembler does not do ( everything is bits ) Making Assembly Code Readable It is important to augment the source code of a program with commentary that lets a reader know what the program does and how it does it The key is to explain why an action is being taken rather than what the action is (the instruction already tells us what the action is) Consider the following two versions of a Pep/8 program to print a triangle of stars such as **** *** ** * The algorithm is Read(numrows) Repeat { Output Numrows stars Output a newline numrows = numrows -1; } until numrows=0 Comp 162 Notes Page 14 of 19 February 11, 2013

15 Version 1 deci m,d ; input m top: lda m,d sta n,d ; n = m top2: charo '*',i ; output a star lda n,d suba 1,i sta n,d ; n = n - 1 brne top2 ; inner loop charo '\n',i ; output a newline lda m,d suba 1,i sta m,d ; m = m - 1 brne top ; outer loop n: block 2 m: block 2 Here, the comments add little to our understanding of the program In many cases they just replicate the instruction A good comment will explain why an action is being done There is also room for improvement in the choice of identifiers and in adding a prompt when input is requested Version 2 ; program inputs m then prints a triangle of stars with ; m rows of stars The first row has m stars, the second ; has m-1 stars, the third has m-2 stars and so on ; stro prompt,d deci numrows,d ; number of rows to print top: lda numrows,d sta numonrow,d ; inner loop limit is same as rows left top2: charo '*',i lda numonrow,d suba 1,i sta numonrow,d ; number of stars left to print on line brne top2 ; branch if more to print on this line charo '\n',i ; no more so output newline character lda numrows,d suba 1,i sta numrows,d ; number of rows to print is decreased brne top ; branch if more rows to print numonrow: block 2 ; inner loop counter numrows: block 2 prompt: ascii Enter number of rows\x00 ; number of rows still to print Comp 162 Notes Page 15 of 19 February 11, 2013

16 Nine simple high-level language programs and their translations into Pep/8 1 High level language int a,b,c; input(a,b) c=a+b; output (c); Pep/8 deci a,d deci b,d adda b,d ; a + b sta c,d deco c,d a: block 2 b: block 2 c: block 2 2 High level language int a,c; input(a); c=a+5; output(c); Pep/8 deci a,d add five,i ; a + 5 sta c,d deco c,d a: block 2 c: block 2 five:equate 5 3 High level language Pep/8 int a,b,c; input (a,b); c=(a+b)/2; output (c); deci b,d adda b,d asra sta c,d deco c,d a: block 2 b: block 2 c: block 2 ; (a+b)/2 Comp 162 Notes Page 16 of 19 February 11, 2013

17 4 High level language int a; input(a); output (3*a+27); Pep/8 deci a,d asla ; 2a adda a,d ; 3a adda constant,i ; 3a+27 sta a,d ; used for result deco a,d a: block 2 constant:equate 27 5 High level language Pep/8 int a,b; input(a,b); output("the sum is "); output(a+b); deci a,d deci b,d adda b,d sta a,d ; a now a+b stro label,d deco a,d a: block 2 b: block 2 label:ascii "The sum is \x00" 6 High level language int a,b; input (a,b); output(a); output(" + " ); output(b); output(" = " ); output(a+b); Pep/8 deci a,d deci b,d adda b,d sta temp,d deco a,d stro plus,d deco b,d stro equals,d deco temp,d a: block 2 b: block 2 temp: block 2 plus: ascii " + \x00" equals:ascii " = \x00" ; for a+b Comp 162 Notes Page 17 of 19 February 11, 2013

18 7 High level language int a; input(a); a = a + a%4; output(a); Pep/8 deci a,d anda 3,i ; a%4 adda a,d ; a+a%4 sta a,d deco a,d a: block 2 8 High level language int score, exam1, exam2; const int bonus = 10; int main() { output ( Enter exam scores: ) input (exam1); input (exam2); score = (exam1+exam2)/2 + bonus; output( Your semester score is: ); output(score); } Pep/8 br main score: block 2 exam1: block 2 exam2: block 2 bonus: equate 10 main: stro prompt,d deci exam1,d deci exam2,d lda exam1,d adda exam2,d asra adda bonus,i sta score,d stro label,d deco score,d prompt:ascii Enter exam scores: \x00 label:ascii Your semester score is: \x00 Comp 162 Notes Page 18 of 19 February 11, 2013

19 9 High level language Pep/8 int A, B, C, result; int main() { output( Enter three integers: ); ; } input(a); input(b); input(c); result = (A/4) + (B%32) + (C*3) 24 output( Result is: ); output(result); stro prompt,d deci a,d deci b,d deci c,d asra asra sta result,d ; a/4 lda b,d anda 31,i adda result,d sta result,d ; a/4 + b%32 lda c,d asla adda c,d adda result,d suba 24,i sta result,d ; a/4 + b%32 + 3*c - 24 stro label,d deco result,d a: block 2 b: block 2 c: block 2 result:block 2 prompt:ascii Enter three integers:\x00 label: ascii Result is: \x00 Reading Chapter 5 This covers the basic properties of the Pep/8 assembly language and has examples of programs with no branching or loops Next we will look at the part of Chapter 6 that shows how we can implement if and while statements Comp 162 Notes Page 19 of 19 February 11, 2013

Wednesday, February 7, 2018

Wednesday, February 7, 2018 Wednesday, February 7, 2018 Topics for today The Pep/9 memory Four example programs The loader The assembly language level (Chapter 5) Symbolic Instructions Assembler directives Immediate mode and equate

More information

Wednesday, September 21, 2016

Wednesday, September 21, 2016 Wednesday, September 21, 2016 Topics for today More high-level to translations Compilers and Assemblers How assemblers work Symbol tables ILC Pass 1 algorithm, Error checking Pass 2 Immediate mode and

More information

Wednesday, September 20, 2017

Wednesday, September 20, 2017 Wednesday, September 20, 2017 Topics for today More high-level to Pep/9 translations Compilers and Assemblers How assemblers work Symbol tables ILC Pass 1 algorithm, Error checking Pass 2 Immediate mode

More information

Wednesday, February 15, 2017

Wednesday, February 15, 2017 Wednesday, February 15, 2017 Topics for today Before and after assembly: Macros, Linkers Overview of Chapter 6 Branching Unconditional Status bits and branching If statements While statements The V and

More information

Chapter. Assembly Language

Chapter. Assembly Language Chapter 5 Assembly Language Mappings The mapping from Asmb5 to ISA3 is one-toone The mapping from HOL6 to Asmb5 is oneto-many Symbols Defined by an identifier followed by a colon at the start of a statement

More information

Monday, February 16, 2015

Monday, February 16, 2015 Monday, February 16, 2015 Topics for today How assemblers work Symbol tables ILC Pass 1 algorithm, Error checking Pass 2 Immediate mode and equate Assembler variants: Disassembler, Cross assembler Macros

More information

Monday, October 17, 2016

Monday, October 17, 2016 Monday, October 17, 2016 Topics for today C functions and Pep/8 subroutines Passing parameters by reference Globals Locals Reverse Engineering II Representation of Booleans C Functions and Pep/8 Subroutines

More information

Wednesday, April 22, 2015

Wednesday, April 22, 2015 Wednesday, April 22, 2015 Topics for today Topics for Exam 3 Process management (Chapter 8) Loader Traps Interrupts, Time-sharing Storage management (Chapter 9) Main memory (1) Uniprogramming (2) Fixed-partition

More information

Monday, March 9, 2015

Monday, March 9, 2015 Monday, March 9, 2015 Topics for today C functions and Pep/8 subroutines Passing parameters by reference Globals Locals More reverse engineering: Pep/8 to C Representation of Booleans C Functions and Pep/8

More information

Wednesday, February 28, 2018

Wednesday, February 28, 2018 Wednesday, February 28, 2018 Topics for today C functions and Pep/9 subroutines Introduction Location of subprograms in a program Translating functions (a) Void functions (b) Void functions with parameters

More information

Low-level software. Components Circuits Gates Transistors

Low-level software. Components Circuits Gates Transistors QUIZ Pipelining A computer pipeline has 4 processors, as shown above. Each processor takes 15 ms to execute, and each instruction must go sequentially through all 4 processors. A program has 10 instructions.

More information

Extra-credit QUIZ Pipelining -due next time-

Extra-credit QUIZ Pipelining -due next time- QUIZ Pipelining A computer pipeline has 4 processors, as shown above. Each processor takes 15 ms to execute, and each instruction must go sequentially through all 4 processors. A program has 10 instructions.

More information

CSC 221: Computer Organization, Spring 2009

CSC 221: Computer Organization, Spring 2009 1 of 7 4/17/2009 10:52 AM Overview Schedule Resources Assignments Home CSC 221: Computer Organization, Spring 2009 Practice Exam 2 Solutions The exam will be open-book, so that you don't have to memorize

More information

QUIZ. Name all the 4 parts of the fetch-execute cycle.

QUIZ. Name all the 4 parts of the fetch-execute cycle. QUIZ Name all the 4 parts of the fetch-execute cycle. 1 Solution Name all the 4 parts of the fetch-execute cycle. 2 QUIZ Name two fundamental differences between magnetic drives and optical drives: 3 Solution

More information

QUIZ. Name all the 4 parts of the fetch-execute cycle.

QUIZ. Name all the 4 parts of the fetch-execute cycle. QUIZ Name all the 4 parts of the fetch-execute cycle. 1 Solution Name all the 4 parts of the fetch-execute cycle. 2 QUIZ Name two fundamental differences between magnetic drives and optical drives: 3 QUIZ

More information

Wednesday, April 19, 2017

Wednesday, April 19, 2017 Wednesday, April 19, 2017 Topics for today Process management (Chapter 8) Loader Traps Interrupts, Time-sharing Storage management (Chapter 9) Main memory (1) Uniprogramming (2) Fixed-partition multiprogramming

More information

Wednesday, March 12, 2014

Wednesday, March 12, 2014 Wednesday, March 12, 2014 Topics for today Solutions to HW #3 Arrays and Indexed Addressing Global arrays Local arrays Buffer exploit attacks Solutions to Homework #3 1. deci N,d < (a) N not defined lda

More information

Monday, October 24, 2016

Monday, October 24, 2016 Monday, October 24, 2016 Topics for today Arrays and Indexed Addressing Arrays as parameters of functions Multi-dimensional arrays Option A: Space-minimal solution Option B: Iliffe vectors Array bound

More information

Monday, October 26, 2015

Monday, October 26, 2015 Monday, October 26, 2015 Topics for today Indexed branching Implementation of switch statement Reusable subroutines Indexed branching It turns out that arrays are useful in translating other language constructs,

More information

Wednesday, September 13, Chapter 4

Wednesday, September 13, Chapter 4 Wednesday, September 13, 2017 Topics for today Introduction to Computer Systems Static overview Operation Cycle Introduction to Pep/9 Features of the system Operational cycle Program trace Categories of

More information

Wednesday, February 4, Chapter 4

Wednesday, February 4, Chapter 4 Wednesday, February 4, 2015 Topics for today Introduction to Computer Systems Static overview Operation Cycle Introduction to Pep/8 Features of the system Operational cycle Program trace Categories of

More information

Monday, March 6, We have seen how to translate void functions. What about functions that return a value such as

Monday, March 6, We have seen how to translate void functions. What about functions that return a value such as Monday, March 6, 2017 Topics for today C functions and Pep/9 subroutines Translating functions (c) Non-void functions (d) Recursive functions Reverse Engineering: Pep/9 to C C Functions and Pep/9 Subroutines

More information

Wednesday, September 27, 2017

Wednesday, September 27, 2017 Wednesday, September 27, 2017 Topics for today Chapter 6: Mapping High-level to assembly-level The Pep/9 run-time stack (6.1) Stack-relative addressing (,s) SP manipulation Stack as scratch space Global

More information

Wednesday, October 17, 2012

Wednesday, October 17, 2012 Wednesday, October 17, 2012 Topics for today Arrays and Indexed Addressing Arrays as parameters of functions Multi-dimensional arrays Indexed branching Implementation of switch statement Arrays as parameters

More information

Monday, November 7, Structures and dynamic memory

Monday, November 7, Structures and dynamic memory Monday, November 7, 2016 Topics for today Structures Structures and dynamic memory Grammars and Languages (Chapter 7) String generation Parsing Regular languages Structures We have seen one composite data

More information

Chapter. Computer Architecture

Chapter. Computer Architecture Chapter 4 Computer Architecture Figure 4.1 Input device Central processing unit Main memory Output device Bus Data flow Control Figure 4.2 Central processing unit () Status bits ( ) Accumulator ( ) Index

More information

UNIT-II. Part-2: CENTRAL PROCESSING UNIT

UNIT-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 information

Wednesday, April

Wednesday, April Wednesday, April 9. 2014 Topics for today Addressing mode summary Structures Structures and dynamic memory Grammars and Languages (Chapter 7) String generation Parsing Regular languages Summary of addressing

More information

A rubric for programming assignments

A rubric for programming assignments Fall 2012 Comp 162 Peter Smith A rubric for programming assignments Generally, half the points for a program assignment are for the Correctness of the program with respect to the specification. The other

More information

C Programming Language. Microcomputer Architecture and Interfacing Colorado School of Mines Professor William Hoff

C Programming Language. Microcomputer Architecture and Interfacing Colorado School of Mines Professor William Hoff C Programming Language 1 C C is better to use than assembly for embedded systems programming. You can program at a higher level of logic than in assembly, so programs are shorter and easier to understand.

More information

Objectives. 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++ 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 information

Chapter 2: Basic Elements of C++

Chapter 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 information

Monday, March 27, 2017

Monday, March 27, 2017 Monday, March 27, 2017 Topics for today Indexed branching Implementation of switch statement Reusable subroutines Indexed branching It turns out that arrays are useful in translating other language constructs,

More information

Expressions and Data Types CSC 121 Spring 2015 Howard Rosenthal

Expressions and Data Types CSC 121 Spring 2015 Howard Rosenthal Expressions and Data Types CSC 121 Spring 2015 Howard Rosenthal Lesson Goals Understand the basic constructs of a Java Program Understand how to use basic identifiers Understand simple Java data types

More information

Chapter 2: Basic Elements of C++ Objectives. Objectives (cont d.) A C++ Program. Introduction

Chapter 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 information

Wednesday, March 14, 2018

Wednesday, March 14, 2018 Wednesday, March 14, 2018 Topics for today Arrays and Indexed Addressing Arrays as parameters of functions Multi-dimensional arrays Option A: Space-minimal solution Option B: Iliffe vectors Array bound

More information

Objectives. In this chapter, you will:

Objectives. In this chapter, you will: 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 arithmetic expressions Learn about

More information

LOW-LEVEL PROGRAMMING LANAGUAGES AND PSEUDOCODE. Introduction to Computer Engineering 2015 Spring by Euiseong Seo

LOW-LEVEL PROGRAMMING LANAGUAGES AND PSEUDOCODE. Introduction to Computer Engineering 2015 Spring by Euiseong Seo LOW-LEVEL PROGRAMMING LANAGUAGES AND PSEUDOCODE Introduction to Computer Engineering 2015 Spring by Euiseong Seo Where are we? Chapter 1: The Big Picture Chapter 2: Binary Values and Number Systems Chapter

More information

EDIABAS BEST/2 LANGUAGE DESCRIPTION. VERSION 6b. Electronic Diagnostic Basic System EDIABAS - BEST/2 LANGUAGE DESCRIPTION

EDIABAS BEST/2 LANGUAGE DESCRIPTION. VERSION 6b. Electronic Diagnostic Basic System EDIABAS - BEST/2 LANGUAGE DESCRIPTION EDIABAS Electronic Diagnostic Basic System BEST/2 LANGUAGE DESCRIPTION VERSION 6b Copyright BMW AG, created by Softing AG BEST2SPC.DOC CONTENTS CONTENTS...2 1. INTRODUCTION TO BEST/2...5 2. TEXT CONVENTIONS...6

More information

Wednesday, February 19, 2014

Wednesday, February 19, 2014 Wednesda, Februar 19, 2014 Topics for toda Solutions to HW #2 Topics for Eam #1 Chapter 6: Mapping High-level to assembl-level The Pep/8 run-time stack Stack-relative addressing (,s) SP manipulation Stack

More information

C How to Program, 7/e by Pearson Education, Inc. All Rights Reserved.

C How to Program, 7/e by Pearson Education, Inc. All Rights Reserved. C How to Program, 7/e This chapter serves as an introduction to data structures. Arrays are data structures consisting of related data items of the same type. In Chapter 10, we discuss C s notion of

More information

Bits, Words, and Integers

Bits, Words, and Integers Computer Science 52 Bits, Words, and Integers Spring Semester, 2017 In this document, we look at how bits are organized into meaningful data. In particular, we will see the details of how integers are

More information

2.2 THE MARIE Instruction Set Architecture

2.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 information

Memory Addressing, Binary, and Hexadecimal Review

Memory Addressing, Binary, and Hexadecimal Review C++ By A EXAMPLE Memory Addressing, Binary, and Hexadecimal Review You do not have to understand the concepts in this appendix to become well-versed in C++. You can master C++, however, only if you spend

More information

C How to Program, 6/e by Pearson Education, Inc. All Rights Reserved.

C How to Program, 6/e by Pearson Education, Inc. All Rights Reserved. C How to Program, 6/e 1992-2010 by Pearson Education, Inc. 1992-2010 by Pearson Education, Inc. 1992-2010 by Pearson Education, Inc. This chapter serves as an introduction to the important topic of data

More information

Monday, March 13, 2017

Monday, March 13, 2017 Monday, March 13, 2017 Topics for today Arrays and Indexed Addressing Global arrays Local arrays Buffer exploit attacks Arrays and indexed addressing (section 6.4) So far we have looked at scalars (int,

More information

Low-Level Programming Languages and Pseudocode

Low-Level Programming Languages and Pseudocode Chapter 6 Low-Level Programming Languages and Pseudocode Chapter Goals List the operations that a computer can perform Describe the important features of the Pep/8 virtual machine Distinguish between immediate

More information

Practical Malware Analysis

Practical Malware Analysis Practical Malware Analysis Ch 4: A Crash Course in x86 Disassembly Revised 1-16-7 Basic Techniques Basic static analysis Looks at malware from the outside Basic dynamic analysis Only shows you how the

More information

UNIT- 3 Introduction to C++

UNIT- 3 Introduction to C++ UNIT- 3 Introduction to C++ C++ Character Sets: Letters A-Z, a-z Digits 0-9 Special Symbols Space + - * / ^ \ ( ) [ ] =!= . $, ; : %! &? _ # = @ White Spaces Blank spaces, horizontal tab, carriage

More information

Programming for Engineers Introduction to C

Programming for Engineers Introduction to C Programming for Engineers Introduction to C ICEN 200 Spring 2018 Prof. Dola Saha 1 Simple Program 2 Comments // Fig. 2.1: fig02_01.c // A first program in C begin with //, indicating that these two lines

More information

COMPUTER ORGANIZATION & ARCHITECTURE

COMPUTER ORGANIZATION & ARCHITECTURE COMPUTER ORGANIZATION & ARCHITECTURE Instructions Sets Architecture Lesson 5a 1 What are Instruction Sets The complete collection of instructions that are understood by a CPU Can be considered as a functional

More information

William 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 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 information

Chapter 6 Programming the LC-3

Chapter 6 Programming the LC-3 Chapter 6 Programming the LC-3 Based on slides McGraw-Hill Additional material 4/5 Lewis/Martin Aside: Booting the Computer How does it all begin? We have LC-3 hardware and a program, but what next? Initial

More information

Microprocessors & Assembly Language Lab 1 (Introduction to 8086 Programming)

Microprocessors & Assembly Language Lab 1 (Introduction to 8086 Programming) Microprocessors & Assembly Language Lab 1 (Introduction to 8086 Programming) Learning any imperative programming language involves mastering a number of common concepts: Variables: declaration/definition

More information

DEPARTMENT OF MATHS, MJ COLLEGE

DEPARTMENT OF MATHS, MJ COLLEGE T. Y. B.Sc. Mathematics MTH- 356 (A) : Programming in C Unit 1 : Basic Concepts Syllabus : Introduction, Character set, C token, Keywords, Constants, Variables, Data types, Symbolic constants, Over flow,

More information

LESSON 1. A C program is constructed as a sequence of characters. Among the characters that can be used in a program are:

LESSON 1. A C program is constructed as a sequence of characters. Among the characters that can be used in a program are: LESSON 1 FUNDAMENTALS OF C The purpose of this lesson is to explain the fundamental elements of the C programming language. C like other languages has all alphabet and rules for putting together words

More information

Monday, September 28, 2015

Monday, September 28, 2015 Monda, September 28, 2015 Topics for toda Chapter 6: Mapping High-level to assembl-level The Pep/8 run-time stack (6.1) Stack-relative addressing (,s) SP manipulation Stack as scratch space Global variables

More information

CPS122 Lecture: From Python to Java last revised January 4, Objectives:

CPS122 Lecture: From Python to Java last revised January 4, Objectives: Objectives: CPS122 Lecture: From Python to Java last revised January 4, 2017 1. To introduce the notion of a compiled language 2. To introduce the notions of data type and a statically typed language 3.

More information

Fundamental of Programming (C)

Fundamental of Programming (C) Borrowed from lecturer notes by Omid Jafarinezhad Fundamental of Programming (C) Lecturer: Vahid Khodabakhshi Lecture 3 Constants, Variables, Data Types, And Operations Department of Computer Engineering

More information

the SAP-2 I. Intro cmpt-150-arc Sections 8-8, 8-9, 9-4, 9-5, 9.6, We ll do this in bits and pieces, doing the beginning of each section first.

the SAP-2 I. Intro cmpt-150-arc Sections 8-8, 8-9, 9-4, 9-5, 9.6, We ll do this in bits and pieces, doing the beginning of each section first. I. Intro the SAP-2 cmpt-150-arc Sections 8-8, 8-9, 9-4, 9-5, 9.6, 9.8 1. We ll do this in bits and pieces, doing the beginning of each section first. 1. The SAP-2 adds a lot of functionality to the SAP-1

More information

Programming for Engineers Arrays

Programming for Engineers Arrays Programming for Engineers Arrays ICEN 200 Spring 2018 Prof. Dola Saha 1 Array Ø Arrays are data structures consisting of related data items of the same type. Ø A group of contiguous memory locations that

More information

Expressions and Data Types CSC 121 Fall 2015 Howard Rosenthal

Expressions and Data Types CSC 121 Fall 2015 Howard Rosenthal Expressions and Data Types CSC 121 Fall 2015 Howard Rosenthal Lesson Goals Understand the basic constructs of a Java Program Understand how to use basic identifiers Understand simple Java data types and

More information

19 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 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 information

Special Section: Building Your Own Compiler

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 information

Monday, April 14, 2014

Monday, April 14, 2014 Monday, April 14, 2014 Topics for today Grammars and Languages (Chapter 7) Finite State Machines Semantic actions Code generation - Overview Analysis Algorithm 1: evaluation of postfix Algorithm 2: infix

More information

Wednesday, September 6, 2017

Wednesday, September 6, 2017 Wednesday, September 6, 2017 Topics for today Arithmetic operations and status bits Logical operators Introduction to bigger bases Encoding characters Coding in general Status bits We saw last time that

More information

Number Systems for Computers. Outline of Introduction. Binary, Octal and Hexadecimal numbers. Issues for Binary Representation of Numbers

Number Systems for Computers. Outline of Introduction. Binary, Octal and Hexadecimal numbers. Issues for Binary Representation of Numbers Outline of Introduction Administrivia What is computer architecture? What do computers do? Representing high level things in binary Data objects: integers, decimals, characters, etc. Memory locations (We

More information

sarm User Guide Note that a space must appear before the operation field because any word beginning in the first column is a label

sarm User Guide Note that a space must appear before the operation field because any word beginning in the first column is a label sarm User Guide The sarm is program that implements an experimental CPU simulator. It is called experimental because it is not yet complete, and it also incorporates facilities that are not conventionally

More information

EE 109 Lab 8a Conversion Experience

EE 109 Lab 8a Conversion Experience EE 109 Lab 8a Conversion Experience 1 Introduction In this lab you will write a small program to convert a string of digits representing a number in some other base (between 2 and 10) to decimal. The user

More information

Write "Nell" Write "N" Write "e" Write "l" Write "l" Write "N" Write 4E (hex) Write "e" W rite 65 (hex) Write "l" W rite 6C (hex)

Write Nell Write N Write e Write l Write l Write N Write 4E (hex) Write e W rite 65 (hex) Write l W rite 6C (hex) Chapter 7 Exercises 1. What does it mean when we say that a computer is a programmable device? Programmable means that data and instructions are logically the same and are stored in the same place. The

More information

reply db y prompt db Enter your favourite colour:, 0 colour db 80 dup(?) i db 20 k db? num dw 4000 large dd 50000

reply db y prompt db Enter your favourite colour:, 0 colour db 80 dup(?) i db 20 k db? num dw 4000 large dd 50000 Declaring Variables in Assembly Language As in Java, variables must be declared before they can be used Unlike Java, we do not specify a variable type in the declaration in assembly language Instead we

More information

Monday, November 9, 2015

Monday, November 9, 2015 Monday, November 9, 2015 Topics for today Grammars and Languages (Chapter 7) Finite State Machines Semantic actions Code generation - Overview nalysis lgorithm 1: evaluation of postfix lgorithm 2: infix

More information

Copyright 2000 N. AYDIN. All rights reserved. 1

Copyright 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 information

The 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: 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 information

Chapter 2 Basic Elements of C++

Chapter 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 information

Physics 306 Computing Lab 5: A Little Bit of This, A Little Bit of That

Physics 306 Computing Lab 5: A Little Bit of This, A Little Bit of That Physics 306 Computing Lab 5: A Little Bit of This, A Little Bit of That 1. Introduction You have seen situations in which the way numbers are stored in a computer affects a program. For example, in the

More information

Computer Architecture and System Software Lecture 02: Overview of Computer Systems & Start of Chapter 2

Computer Architecture and System Software Lecture 02: Overview of Computer Systems & Start of Chapter 2 Computer Architecture and System Software Lecture 02: Overview of Computer Systems & Start of Chapter 2 Instructor: Rob Bergen Applied Computer Science University of Winnipeg Announcements Website is up

More information

CHAPTER ASSEMBLY LANGUAGE PROGRAMMING

CHAPTER 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 information

Full file at

Full file at Java Programming: From Problem Analysis to Program Design, 3 rd Edition 2-1 Chapter 2 Basic Elements of Java At a Glance Instructor s Manual Table of Contents Overview Objectives s Quick Quizzes Class

More information

CS112 Lecture: Primitive Types, Operators, Strings

CS112 Lecture: Primitive Types, Operators, Strings CS112 Lecture: Primitive Types, Operators, Strings Last revised 1/24/06 Objectives: 1. To explain the fundamental distinction between primitive types and reference types, and to introduce the Java primitive

More information

CS311 Lecture: The Architecture of a Simple Computer

CS311 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 information

Review 1/2 MIPS assembly language instructions mapped to numbers in 3 formats. CS61C Negative Numbers and Logical Operations R I J.

Review 1/2 MIPS assembly language instructions mapped to numbers in 3 formats. CS61C Negative Numbers and Logical Operations R I J. CS61C Negative Numbers and Logical Operations cs 61C L7 Number.1 Lecture 7 February 10, 1999 Dave Patterson (http.cs.berkeley.edu/~patterson) www-inst.eecs.berkeley.edu/~cs61c/schedule.html Review 1/2

More information

Starting with a great calculator... Variables. Comments. Topic 5: Introduction to Programming in Matlab CSSE, UWA

Starting with a great calculator... Variables. Comments. Topic 5: Introduction to Programming in Matlab CSSE, UWA Starting with a great calculator... Topic 5: Introduction to Programming in Matlab CSSE, UWA! MATLAB is a high level language that allows you to perform calculations on numbers, or arrays of numbers, in

More information

Monday, April 9, 2018

Monday, April 9, 2018 Monday, April 9, 208 Topics for today Grammars and Languages (Chapter 7) Finite State Machines Semantic actions Code generation Overview Finite State Machines (see 7.2) If a language is regular (Type 3)

More information

Machine 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 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 information

Lecture 5 Assembly Programming: Arithmetic

Lecture 5 Assembly Programming: Arithmetic CPE 390: Microprocessor Systems Spring 2018 Lecture 5 Assembly Programming: Arithmetic Bryan Ackland Department of Electrical and Computer Engineering Stevens Institute of Technology Hoboken, NJ 07030

More information

Numerical Computing in C and C++ Jamie Griffin. Semester A 2017 Lecture 2

Numerical Computing in C and C++ Jamie Griffin. Semester A 2017 Lecture 2 Numerical Computing in C and C++ Jamie Griffin Semester A 2017 Lecture 2 Visual Studio in QM PC rooms Microsoft Visual Studio Community 2015. Bancroft Building 1.15a; Queen s W207, EB7; Engineering W128.D.

More information

The C++ Language. Arizona State University 1

The C++ Language. Arizona State University 1 The C++ Language CSE100 Principles of Programming with C++ (based off Chapter 2 slides by Pearson) Ryan Dougherty Arizona State University http://www.public.asu.edu/~redoughe/ Arizona State University

More information

Semester Transition Point. EE 109 Unit 11 Binary Arithmetic. Binary Arithmetic ARITHMETIC

Semester Transition Point. EE 109 Unit 11 Binary Arithmetic. Binary Arithmetic ARITHMETIC 1 2 Semester Transition Point EE 109 Unit 11 Binary Arithmetic At this point we are going to start to transition in our class to look more at the hardware organization and the low-level software that is

More information

17. Instruction Sets: Characteristics and Functions

17. 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 information

Wednesday, March 29, Implementation of sets in an efficient manner illustrates some bit-manipulation ideas.

Wednesday, March 29, Implementation of sets in an efficient manner illustrates some bit-manipulation ideas. Wednesday, March 29, 2017 Topics for today Sets: representation and manipulation using bits Dynamic memory allocation Addressing mode summary Sets Implementation of sets in an efficient manner illustrates

More information

QUIZ: What value is stored in a after this

QUIZ: What value is stored in a after this QUIZ: What value is stored in a after this statement is executed? Why? a = 23/7; QUIZ evaluates to 16. Lesson 4 Statements, Expressions, Operators Statement = complete instruction that directs the computer

More information

Page. No. 1/15 CS201 Introduction to Programmming Solved Subjective Questions From spring 2010 Final Term Papers By vuzs Team

Page. No. 1/15 CS201 Introduction to Programmming Solved Subjective Questions From spring 2010 Final Term Papers By vuzs Team Page. No. 1/15 CS201 Introduction to Programmming Solved Subjective Questions From spring 2010 Final Term Papers By vuzs Team Question No: 1 ( Marks: 2 ) Write a declaration statement for an array of 10

More information

LAB A Translating Data to Binary

LAB A Translating Data to Binary LAB A Translating Data to Binary Create a directory for this lab and perform in it the following groups of tasks: LabA1.java 1. Write the Java app LabA1 that takes an int via a command-line argument args[0]

More information

Course Schedule. CS 221 Computer Architecture. Week 3: Plan. I. Hexadecimals and Character Representations. Hexadecimal Representation

Course Schedule. CS 221 Computer Architecture. Week 3: Plan. I. Hexadecimals and Character Representations. Hexadecimal Representation Course Schedule CS 221 Computer Architecture Week 3: Information Representation (2) Fall 2001 W1 Sep 11- Sep 14 Introduction W2 Sep 18- Sep 21 Information Representation (1) (Chapter 3) W3 Sep 25- Sep

More information

CS102: Variables and Expressions

CS102: Variables and Expressions CS102: Variables and Expressions The topic of variables is one of the most important in C or any other high-level programming language. We will start with a simple example: int x; printf("the value of

More information

CS112 Lecture: Variables, Expressions, Computation, Constants, Numeric Input-Output

CS112 Lecture: Variables, Expressions, Computation, Constants, Numeric Input-Output CS112 Lecture: Variables, Expressions, Computation, Constants, Numeric Input-Output Last revised January 12, 2006 Objectives: 1. To introduce arithmetic operators and expressions 2. To introduce variables

More information

n NOPn Unary no operation trap U aaa NOP Nonunary no operation trap i

n NOPn Unary no operation trap U aaa NOP Nonunary no operation trap i Instruction set Instruction Mnemonic Instruction Addressing Status Specifier Mode Bits 0000 0000 STOP Stop execution U 0000 0001 RET Return from CALL U 0000 0010 RETTR Return from trap U 0000 0011 MOVSPA

More information

Instruction : A command to the microprocessor to perform a given task on specified data. Each instruction has two parts

Instruction : A command to the microprocessor to perform a given task on specified data. Each instruction has two parts Lecture 4 Instruction : A command to the microprocessor to perform a given task on specified data. Each instruction has two parts One part is the task to be performed, called operation code or opcode in

More information

CSCI 2212: Intermediate Programming / C Chapter 15

CSCI 2212: Intermediate Programming / C Chapter 15 ... /34 CSCI 222: Intermediate Programming / C Chapter 5 Alice E. Fischer October 9 and 2, 25 ... 2/34 Outline Integer Representations Binary Integers Integer Types Bit Operations Applying Bit Operations

More information