TCSS 490A Topics in Computing & Software Systems “Introduction to Computer Systems”

Slides:



Advertisements
Similar presentations
Chapter 7 Introduction to LC-3 Assembly Language Assembly Language Assembly Process Using the Editor & Simulator for Assembly Language Programming.
Advertisements

Chapter 7 Assembly Language. Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 7-2 Human-Readable Machine Language.
Introduction to Computer Engineering ECE/CS 252, Fall 2010 Prof. Mikko Lipasti Department of Electrical and Computer Engineering University of Wisconsin.
CS25410 Memory Machine Code. Common types of non-rotating memory (1) RAMRandom Access Memory In reality, read/write memory This is usually volatile, meaning.
Chapter 7 Assembly Language. Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 7-2 Human-Readable Machine Language.
Chapter 5 The LC-3.
Chapter 4 - ISA 1.The Von Neumann Model. 4-2 The Stored Program Computer 1943: ENIAC Presper Eckert and John Mauchly -- first general electronic computer.
LC-3 Computer LC-3 Instructions
S. Barua – CPSC 240 CHAPTER 5 THE LC-3 Topics Memory organization Registers Instruction set Opcodes.
LC-3 Assembly Language Programming Examples
CSS 372 Lecture 1 Course Overview: CSS 372 Web page Syllabus Lab Ettiquette Lab Report Format Review of CSS 371: Simple Computer Architecture Traps Interrupts.
Overview The Operate Instructions - ADD, AND, NOT The Data Movement Instructions - Load, Load Address, Store Example Using Operate & Data Movement The.
TCSS 371A Machine Organization. Getting Started Get acquainted Review syllabus Understand purpose, scope, and expectations of the course Discuss personal.
Some thoughts: If it is too good to be true, it isn’t. Success is temporary. It is hard work to make it simple. Knowing you did it right is enough reward.
Overview Review Trap Instruction Program in LC-3 machine language Use LC-3 Simulator.
LC-3 Instruction Set Architecture (Textbook’s Chapter 5)
Chapter 11-14, Appendix D C Programs Higher Level languages Compilers C programming Converting C to Machine Code C Compiler for LC-3 Please return breadboards.
Chapter 5 The LC-3 LC-3 Computer Architecture Memory Map
Chapter 6 Programming in Machine Language The LC-3 Simulator
Introduction to LC-3 Assembly Language. LC-3 Assembly Language Syntax Each line of a program is one of the following: –an instruction –an assember directive.
Choice for the rest of the semester New Plan –assembler and machine language –Operating systems Process scheduling Memory management File system Optimization.
Chapter 9 & 10 Subroutines and Interrupts. JSR Instruction: JSR offset (11 bit) xxxxxxxxxxx [PC ]  R7, JMP Offset Jump to Subroutine at offset.
Chapters 5 - The LC-3 LC-3 Computer Architecture Memory Map
Overview Intro to Project 2 - Serial I/O – RS232, USB Assembly Language Programming Using the LC-3 Simulator.
Introduction to LC-3 Assembly Language
Chapter 11-12, Appendix D C Programs Higher Level languages Compilers C programming Converting C to Machine Code C Compiler for LC-3.
Chapter 9 Trap Routines & RET Subroutines (or Functions) & JSR & JSRR & RET.
Chapter 11-12, Appendix D C Programs Higher Level languages Compilers C programming Converting C to Machine Code C Compiler for LC-3.
Overview Projects The Assembly Process Programmed I/O Interrupt Driven I/O.
TCSS 372A Computer Architecture. Getting Started Get acquainted (take pictures) Review Web Page (
LC-3 Instruction Set Architecture
Chapters 4 & 5: LC-3 Computer Architecture Machine Instructions Assembly language Programming in Machine and Assembly Language.
Overview von Neumann Model Components of a Computer Some Computer Organization Models The Computer Bus An Example Organization: The LC-3.
Introduction to Computer Engineering CS/ECE 252, Spring 2007 Prof. Mark D. Hill Computer Sciences Department University of Wisconsin – Madison.
Chapter 5 The LC-3. Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 5-2 Instruction Set Architecture ISA.
Assembly Language.
Introduction to Computing Systems and Programming Assembly Language.
The LC-3 – Chapter 7 COMP 2620 Dr. James Money COMP
Chapter 7 Assembly Language. Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Our Bag of Tricks so far Control.
Introduction to Computing Systems from bits & gates to C & beyond Chapter 5 The LC-2 Instruction Set Architecture Operate instructions Data Movement instructions.
Introduction to Computer Engineering CS/ECE 252, Fall 2007 Prof. Mark D. Hill Computer Sciences Department University of Wisconsin – Madison.
Introduction to Computing Systems from bits & gates to C & beyond Chapter 5 The LC-3 Instruction Set Architecture ISA Overview Operate instructions Data.
Chapter 5 The LC Instruction Set Architecture ISA = All of the programmer-visible components and operations of the computer memory organization.
Chapter 5 The LC-3. Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 5-2 Data Movement Instructions Load --
Computer Science 210 Computer Organization Overview of Assembly Language.
Introduction to Computer Engineering ECE/CS 252, Fall 2010 Prof. Mikko Lipasti Department of Electrical and Computer Engineering University of Wisconsin.
The LC-3. Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 5-2 Instruction Set Architecture ISA = All of the.
Chapter 7 Assembly Language. 7-2 Human-Readable Machine Language Computers like ones and zeros… Humans like symbols… Assembler is a program that turns.
Chapter 5 The LC Instruction Set Architecture ISA = All of the programmer-visible components and operations of the computer memory organization.
Introduction to Computing Systems and Programming The LC-2.
Chapter 7 Assembly Language
Chapter 9 TRAP Routines and Subroutines
Chapter 7 & 9.2 Assembly Language
COSC121: Computer Systems: Review
Chapter 7 Assembly Language
Chapter 9 TRAP Routines and Subroutines
Chapter 5 The LC-3.
The LC-3 Instruction Set Architecture Data Movement instructions
LC-3 Details and Examples
Chapter 9 TRAP Routines and Subroutines
Chapter 5 The LC-3.
Introduction to Computer Engineering
Chapter 9 TRAP Routines and Subroutines
Chapter 9 TRAP Routines and Subroutines
Chapter 7 Assembly Language
Chapter 9 TRAP Routines and Subroutines
Chapter 9 TRAP Routines and Subroutines
Chapter 9 TRAP Routines and Subroutines
Chapter 5 The LC-3.
Presentation transcript:

TCSS 490A Topics in Computing & Software Systems “Introduction to Computer Systems”

What do we want to do tonight ? First: Get acquainted Review the syllabus Understand the scope, purpose, and expectations of the course Check out our textbook Visit our Laboratory (CP 206C)

What do we want to do tonight ? Second: Discuss the levels of abstraction involved in a computer solution to problem Discuss major Numeric Data Types Develop expertise in working with various numeric bases especially base 10, base 2 (binary), and base 16 (hexidecimal) Become proficient converting numbers from one base to another Become proficient with 2’s complement arithmetic Understand round off error, sign extension, and overflow Understand representation of floating point numbers Understand Binary Logic

The levels of abstraction involved in a computer solution to problem Problem Algorithm Language Machine Architecture Microarchitecture Circuits Devices Electron or light flow

Develop expertise in working with various numeric bases Base 10 Base 2 (binary) Base 16 (hexidecimal) Others ?

Become proficient converting numbers from one base to another Base 10 to binary Binary to Base 10 Base 10 to Hexidecimal Hexidecimal to Base 10 Binary to Hexidecimal Hexidecimal to Binary Others ?

Major Numeric Data Types Unsigned Integers Signed Integers 2’s Complement Integers Floating Point Numbers

Become proficient with 2’s complement arithmetic (See Text Figure 2.1) Signed Binary Integers 1’s Complement Binary Integers 2’s complement Binary Integers

Binary Arithmetic Unsigned add & subtract 2’s complement add & subtract

Understand round off error, sign extension, and overflow overflow sign extension Binary fractions (the binary point) round off error

Understanding Floating Point Numbers IEEE Standard sign (1 bit), exponent (8 bits), fraction (23 bits) (-1)**sign x 1.fraction x 2**exponent-127 1<= exponent <= 254

ASCII (7 bit or extended) UNICODE (16 bit) See ASCII table See UNICODE table

Binary Logic NOT AND (NAND) OR (NOR) XOR Truth tables DeMorgan’s Theorem

What do we want to do tonight ? ( Second Week) Introduce logic circuits Relay logic MOS semiconductors Inverter Nor Gate Nand Gate Combinational Logic Decoders Full Adder PLA’s MUX – Multiplexers

What do we want to do tonight ? Storage Devices SR Flip-Flops D Latch Flip Flops J/K Master Slave Flip Flops Registers Addressing Finite State Machines State Diagrams

The LC-3 as a von Neumann machine

Data Path of the LC-3

The Instruction FORMAT Operation code Input Operand(s) Output Operand(s) ADDRESSING MODES Register PC-relative Base + Offset (Base relative) Immediate Indirect

Operate Instructions Only three operations: ADD, AND, NOT Source and destination operands are registers

ADD/AND (Register)

NOT (Register) Note: Src and Dst could be the same register.

ADD/AND (Immediate) Note: Immediate field is sign-extended.

Data Movement Instructions Load -- read data from memory to register –LD: PC-relative mode [0010 DR PCoffset9] –LDI: indirect mode [1010 DR PCoffset9] –LDR: base+offset mode [0110 DR BaseR offset6] Store -- write data from register to memory –ST: PC-relative mode [0011 DR PCoffset9] –STI: indirect mode [1011 DR PCoffset9] –STR: base+offset mode [0111 DR BaseR offset6] Load effective address – address saved in register –LEA: immediate mode [1110 DR PCoffset9]

LD (PC-Relative)

ST (PC-Relative)

LDI (Indirect)

STI (Indirect)

LDR (Base+Offset)

STR (Base+Offset)

LEA (Immediate)

Branch Instruction BR [0000 nzp PCoffset9] Branch specifies one or more condition codes If the set bit is specified, the branch is taken: –PC is set to the address specified in the instruction –Target address is made by adding SEXT(IR[8:0]) to the PC If the branch is not taken: - the next sequential instruction (PC) is executed.

BR ///////////// /////+ SEXT

Jump Instruction JMP BaseR [ BaseR ] Jump is an unconditional branch -- always taken. Base –Address is contents of the register –Allows any target address.

TRAP Calls a service routine, identified by 8-bit “trap vector.” When routine is done, PC is set to the instruction following TRAP. vectorroutine x23input a character from the keyboard x21output a character to the monitor x25halt the program

Example 1: Multiply This program multiplies two unsigned integers in R4 and R5. x x x x x clear R2 add R4 to R2 decrement R5 R5 = 0? HALT No Yes R2 <- 0 R2 <- R2 + R4 R5 <- R5 – 1 BRzp x3201 HALT

Example AddressInstructionComments x30F R1  PC – 3 = x30F4 x30F R2  R = x3102 x30F M[PC - 5]  R2 M[x30F4]  x3102 x30F R2  0 x30FA R2  R2 + 5 = 5 x30FB M[R1+14]  R2 M[x3102]  5 x30FC R3  M[M[x30F4]] R3  M[x3102] R3  5 Opcode

Using Branch Instructions Compute sum of 12 integers. Numbers start at location x3100. Program starts at location x3000. R1  x3100 R3  0 R2  12 R2=0? R4  M[R1] R3  R3+R4 R1  R1+1 R2  R2-1 NO YES

Sample Program AddressInstructionComments x R1  x3100 x R3  0 x R2  0 x R2  12 x If Z, goto x3009 x Load next value to R4 x Add to R3 x Increment R1 (pointer) X Decrement R2 (counter) x Goto x3004

Flow Chart

Program (1 of 2) AddressInstructionComments x R2  0 (counter) x R3  M[x3102] (ptr) x Input to R0 (TRAP x23) x R1  M[R3] x R4  R1 – 4 (EOT) x If Z, goto x300E x R1  NOT R1 x R1  R1 + 1 X R1  R1 + R0 x If N or P, goto x300B

Program (2 of 2) AddressInstructionComments x300A R2  R2 + 1 x300B R3  R3 + 1 x300C R1  M[R3] x300D Goto x3004 x300E R0  M[x3013] x300F R0  R0 + R2 x Print R0 (TRAP x21) x HALT (TRAP x25) X3012Starting Address of File x ASCII x30 (‘0’)

Filled arrow = info to be processed. Unfilled arrow = control signal.

Three Basic Constructs There are three basic ways to decompose a task:

LC-3 Assembly Language Syntax Each line of a program is one of the following: –an instruction –an assember directive (or pseudo-op) –a comment Whitespace (between symbols) and case are ignored. Comments (beginning with “;”) are also ignored. An instruction has the following format: LABEL OPCODE OPERANDS ; COMMENTS optionalmandatory

An Assembly Language Program ; ; Program to multiply a number by the constant 6 ;.ORIGx3050 LDR1, SIX LDR2, NUMBER ANDR3, R3, #0; Clear R3. It will ; contain the product. ; The inner loop ; AGAINADDR3, R3, R2 ADDR1, R1, #-1; R1 keeps track of BRpAGAIN; the iteration. ; HALT ; NUMBER.BLKW1 SIX.FILLx0006 ;.END

Assembler Directives Pseudo-operations –do not refer to operations executed by program –used by assembler –look like instruction, but “opcode” starts with dot OpcodeOperandMeaning.ORIG addressstarting address of program.END end of program.BLKW nallocate n words of storage.FILL nallocate one word, initialize with value n.STRINGZ n-character string allocate n+1 locations, initialize w/characters and null terminator

Trap Codes LC-3 assembler provides “pseudo-instructions” for each trap code, so you don’t have to remember them. CodeEquivalentDescription HALTTRAP x25 Halt execution and print message to console. INTRAP x23 Print prompt on console, read (and echo) one character from keybd. Character stored in R0[7:0]. OUTTRAP x21 Write one character (in R0[7:0]) to console. GETCTRAP x20 Read one character from keyboard. Character stored in R0[7:0]. PUTSTRAP x22 Write null-terminated string to console. Address of string is in R0.

Sample Program Count the occurrences of a character in a file. Remember this?

Char Count in Assembly Language (1 of 3) ; ; Program to count occurrences of a character in a file. ; Character to be input from the keyboard. ; Result to be displayed on the monitor. ; Program only works if no more than 9 occurrences are found. ; ; Initialization ;.ORIGx3000 ANDR2, R2, #0; R2 is counter, initially 0 LDR3, PTR; R3 is pointer to characters GETC; R0 gets character input LDRR1, R3, #0; R1 gets first character ; ; Test character for end of file ; TESTADDR4, R1, #-4; Test for EOT (ASCII x04) BRzOUTPUT; If done, prepare the output

Char Count in Assembly Language (2 of 3) ; ; Test character for match. If a match, increment count. ; NOTR1, R1 ADDR1, R1, R0; If match, R1 = xFFFF NOTR1, R1; If match, R1 = x0000 BRnpGETCHAR; If no match, do not increment ADDR2, R2, #1 ; ; Get next character from file. ; GETCHARADDR3, R3, #1; Point to next character. LDRR1, R3, #0; R1 gets next char to test BRnzpTEST ; ; Output the count. ; OUTPUTLDR0, ASCII; Load the ASCII template ADDR0, R0, R2; Covert binary count to ASCII OUT; ASCII code in R0 is displayed. HALT; Halt machine

Char Count in Assembly Language (3 of 3) ; ; Storage for pointer and ASCII template ; ASCII.FILLx0030 PTR.FILLx4000.END

Program to find number of negative numbers 1. Initialize Registers 2. Get next data 3. If sign is negative, increment count 4. Update data pointer 5. If not done, go to Store result 7. Halt

Program to find number of negative numbers 1.Initialize Registers R0 = Counter of neg numbers R1 = Sign Mask R2 = Number of Data words R3 = Ptr to Data R4 = Data buffer 2. Get next data Load R4 with (R3) 3. If sign is negative, increment count AND Sign Mask with Data, Inc R0 if not zero 4. Update data pointer Inc R3 Dec R2 5. If not done, go to 2. IF Positive go to Store result Store R0 in location pointed to by result pointer 7. Halt

Program to find number of negative numbers.ORIG x3000 ; ; Initialze Registers ; AND R0, R0, #0; Clr counter of negative numbers LD R1, MASK; Set sign bit mask ADD R2, R0, #10; Set # of Data words LD R3, PTR_DATA; Set Data Ptr ; ; Loop to check words ; LOOP LDR R4, R3, #0; Fetch data word AND R4, R4, R1; Test for sign bit BRz NEXT; ADD R0, R0, #1; Inc counter if negative NEXT ADD R3, R3, #1; Inc Data Ptr ADD R2, R2, #-1; Dec # of Data words left BRp LOOP ; ; Store Result ; STI R0, PTR_RESULT; Store result in 4010 HALT ; ; Data ; MASK.FILL x8000 PTR_DATA.FILL x3020 PTR_RESULT.FILL x3040.END

Assembly Language Instructions 1)Move data Instructions Reg  Reg ADD, AND Reg  Memory LD, LDR, LDI Memory  Reg ST, STR, STI Clear REG AND LOAD ADDRESS LEA 1)Computation – Arithmetic and Logic Arithmetic ADD LOGIC AND, NOT, (SHIFT) 2)Program Control – support IF, WHEN, DO BR JMP 3)Subroutines (& Methods) - Pass Parameters – by value, by reference, Stack JSR JSRR RET 4)Trap – operating system support - Stack TRAP RET 5)Interrupts – Status Reg / Hardware does the “call”. Priorities, PSR, Supervisor Stack RTI

Addressing 1)Register – operand is in a register 2)Immediate (or literal) – operand is in IR[5:0] 3)PC Relative – operand is in PC+IR[8:0]ext or PC+IR[10:0]ext 4)Base + Offset – operand is in BaseReg or BaseReg+IR[5:0] 5)Indirect – operand address is at PC+IR[8:0]

Hardware 1)Arithmetic and Logic Unit – Nominally 2 operands 2)Memory - Memory Address Register (MAR) & Memory Data Register (MDR) 3)Registers (R0-R7) – Convention R0, R5, R6, R7 4)Program Counter (PC) – Incremented after instruction fetch! 4)Instruction Register (IR) – Hold Instruction being executed 5)Processor Status Register (PSR) – Privileged, Priority, CC’s 6)Stack Pointer Storage Regs – Saved.SysStackPtr & Saved.UserStackPtr 7)I/O Devices Device Data Register(s) Device Status Register(s) – Ready Bit, Intr Enable Bit, Priority?

Traps 1)Execute TRAP “vector” - Operating System Service Routines 2)Trap Vectors are at memory locations [0000:00FF] 3)Trap Vectors contain addresses of Trap Service Routines 4)(PC) is loaded into R7 5)Address of Trap Service Routine loaded into PC 6)Service Routine Program executed 7)Trap service routine program ends with an RET ( (R7) loaded into PC)

Subroutines 1)Execute JSR or JSRR - Call Subroutine or Method 2)Location of Subroutine is “in” the Instruction 4)(PC) stored in R7 5)Address from JSR or JSRR is loaded into PC 6)Subroutine is executed R0 possibly contains passed parameter (or address) Stack may contain passed parameters (or addresses) R5 may be used to return error message Ro possibly contains return parameter (or address) Stack may contain return parameters (or addresses) 7)Subroutine program ends with an RET ( (R7 loaded into PC) How does this mechanism support recursion?

Interrupts 1)Enable Interrupts by setting “intr enable” bit in Device Status Reg 2)When device ready bit is set and the priority is higher than the priority of the presently running program (and execution of an instruction is complete) the processor initiates the interrupt 4)The Processor saves the “state” of the program The Processor goes into Privileged Mode PSR bit 15 cleared Priority level is set (likely established by the interrupting device) The CC’s are cleared (R6) is stored in USP.saved register The Supervisor Stack Ptr is loaded into R6 The (PC) and the (PSR) are PUSHED onto the Supervisor Stack The contents of the other registers are not saved. Why? 5)The Processor Loads the PC from the Interrupt vector (vectors in 100:1FF) 6)Interrupt Service Routine is executed Ends with an RTI 7)The stored user PSR, PC, and R6 are reloaded and the next instruction executed (POPS top of stack into PC)

Higher Level Languages High Level Languages give us: Symbolic Names Expressions Libraries of functions/subroutines Abstraction of underlying hardware Readability Structure – help keep bugs out

First C Program /* * Program Name : countdown, our first C program * * Description : This program prompts the user to type in * a positive number and counts down from that number to 0, * displaying each number along the way. */ /* The next two lines are preprocessor directives */ #include #define STOP 0 /* Function : main */ /* Description : prompt for input, then display countdown */ int main() { /* Variable declarations */ int counter; /* Holds intermediate count values */ int startPoint; /* Starting point for count down */ /* Prompt the user for input */ printf("===== Countdown Program =====\n"); printf("Enter a positive integer: "); scanf("%d", &startPoint); /* Count down from the input number to 0 */ for (counter = startPoint; counter >= STOP; counter--) { printf("%d\n", counter); } return 0 }

Compiling C

Terms Pre processor directives #define #include Header Files Data Types int char double Scope Local Global Variable initiation

Scope #include int globalVar = 2; /* This variable is global */ int main() { int localVar = 3; /* This variable is local to main */ printf("Global %d Local %d\n", globalVar, localVar); { int localVar = 4; /* Local to this sub-block */ printf("Global %d Local %d\n", globalVar, localVar); } printf("Global %d Local %d\n", globalVar, localVar); return 0 }

Another program #include int main() { int amount; /* The number of bytes to be transferred */ int rate; /* The average network transfer rate */ int time; /* The time, in seconds, for the transfer */ int hours; /* The number of hours for the transfer */ int minutes; /* The number of mins for the transfer */ int seconds; /* The number of secs for the transfer */ /* Get input: number of bytes and network transfer rate */ printf("How many bytes of data to be transferred? "); scanf("%d", &amount); printf("What is the transfer rate (in bytes/sec)? "); scanf("%d", &rate); /* Calculate total time in seconds */ time = amount / rate; /* Convert time into hours, minutes, seconds */ hours = time / 3600; /* 3600 seconds in an hour */ minutes = (time % 3600) / 60; /* 60 seconds in a minute */ seconds = ((time % 3600) % 60); /* remainder is seconds */ /* Output results */ printf("Transfer Time : %dh %dm %ds\n", hours, minutes, seconds); return 0 }

Another program /* Include the standard I/O header file */ #include int inGlobal; /* inGlobal is a global variable because */ /* it is declared outside of all blocks */ int main() { int inLocal; /* inLocal, outLocalA, outLocalB are all */ int outLocalA; /* local to main */ int outLocalB; /* Initialize */ inLocal = 5; inGlobal = 3; /* Perform calculations */ outLocalA = inLocal & ~inGlobal; outLocalB = (inLocal + inGlobal) - (inLocal - inGlobal); /* Print out results */ printf("outLocalA = %d, outLocalB = %d\n", outLocalA, outLocalB); return 0 }

Another program #include #define RADIUS 15.0 /* This value is in centimeters */ int main() { const double pi = ; double area; double circumference; /* Calculations */ area = pi * RADIUS * RADIUS; /* area = pi*r^2 */ circumference = 2 * pi * RADIUS; /* circumference = */ /* 2*pi*r */ printf("Area of a circle with radius %f cm is %f cm^2\n", RADIUS, area); printf("Circumference of the circle is %f cm\n", circumference); return 0 }

Another program int main() { char nextChar; /* Next character in address */ int gotAt = FALSE; /* Indicates if was found */ int gotDot = FALSE; /* Indicates if Dot. was found */ printf("Enter your address: "); do { scanf("%c", &nextChar); if (nextChar == gotAt = TRUE; if (nextChar == '.' && gotAt == TRUE) gotDot = TRUE; } while (nextChar != ' ' && nextChar != '\n'); if (gotAt == TRUE && gotDot == TRUE) printf("Your address appears to be valid.\n"); else printf("Your address is not valid!\n"); return 0 }

Another program #include #define FALSE 0 #define TRUE 1 int main() { char nextChar; /* Next character in address */ int gotAt = FALSE; /* Indicates if was found */ int gotDot = FALSE; /* Indicates if Dot. was found */ printf("Enter your address: "); do { scanf("%c", &nextChar); if (nextChar == gotAt = TRUE; if (nextChar == '.' && gotAt == TRUE) gotDot = TRUE; } while (nextChar != ' ' && nextChar != '\n'); if (gotAt == TRUE && gotDot == TRUE) printf("Your address appears to be valid.\n"); else printf("Your address is not valid!\n"); return 0 }

Another program #include #define FALSE 0 #define TRUE 1 int main() { char nextChar; /* Next character in address */ int gotAt = FALSE; /* Indicates if was found */ int gotDot = FALSE; /* Indicates if Dot. was found */ printf("Enter your address: "); do { scanf("%c", &nextChar); if (nextChar == gotAt = TRUE; if (nextChar == '.' && gotAt == TRUE) gotDot = TRUE; } while (nextChar != ' ' && nextChar != '\n'); if (gotAt == TRUE && gotDot == TRUE) printf("Your address appears to be valid.\n"); else printf("Your address is not valid!\n"); return 0 }

Another program ; Program to compute z = x * Y ; (R5) -> X, (R5)-1 -> Y ; ANDR0, R0, #0; RO <= 0 LDRR1, R5, #0; load value of x LDRR2, R5, #-1; load value of y BRzDONE; if y is zero, we're done BRpLOOP; if y is positive, start mult ; y is negative NOT R1, R1 ADD R1, R1, #1; R1 <= -x NOTR2, R2 ADDR2, R2, #1; R2 <= -y (-y is positive) LOOPADDR0, R0, R1; Multiply loop ADDR2, R2, #-1; The result is in R2 BRpLOOP DONESTR R0, R5, #-2; z = x * Y