Overview Program in LC-3 machine language Use the Editor

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

The LC-3 – Chapter 6 COMP 2620 Dr. James Money COMP
PART 6 Programming 1.Decomposition 2.Three Constructs 3.Counting Example 4.Debugging.
The LC-3 – Chapter 7 COMP 2620 Dr. James Money COMP
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 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
LC-3 Assembly Language Programming Examples
Overview The Operate Instructions - ADD, AND, NOT The Data Movement Instructions - Load, Load Address, Store Example Using Operate & Data Movement The.
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 5 The LC-3 LC-3 Computer Architecture Memory Map
Chapter 6 Programming in Machine Language The LC-3 Simulator
Chap 4 & 5 LC-3 Computer LC-3 Instructions Chap 4 Homework – due Monday October 27 Chap 5 Homework – due Wednesday October 29 Project 2 Designs (Working.
Introduction to LC-3 Assembly Language
LC-3 Instruction Set Architecture
Chapters 4 & 5: LC-3 Computer Architecture Machine Instructions Assembly language Programming in Machine and Assembly Language.
Computer Science 210 s1c Computer Systems Semester 1 Lecture Notes James Goodman (revised by Robert Sheehan) Credits: “McGraw-Hill” slides prepared.
Introduction to Computing Systems and Programming Assembly Language.
The LC-3 – Chapter 7 COMP 2620 Dr. James Money COMP
Introduction to Computer Engineering ECE/CS 252, Fall 2010 Prof. Mikko Lipasti Department of Electrical and Computer Engineering University of Wisconsin.
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 --
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.
SSST: CS130 F. Hadziomerovic
Chapter 6 Programming. Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 6-2 Solving Problems using a Computer.
The LC-3 – Chapter 5 COMP 2620 Dr. James Money COMP
The LC-3 – Chapter 5 COMP 2620 Dr. James Money COMP
Introduction to Computing Systems and Programming The LC-2.
Introduction to Computing Systems and Programming Programming.
Computer Science 210 s1c Computer Systems Semester 1 Lecture Notes James Goodman (revised by Robert Sheehan) Credits: “McGraw-Hill” slides prepared.
Computer Science 210 Computer Organization Machine Language Instructions: Control.
Chapter 6 Programming Adapted from slides provided by McGraw-Hill Companies Inc., modified by professors at University of Wisconsin-Madison.
Compsci 210 Tutorial Five.
Introduction to Computer Engineering
Chapter 7 Assembly Language
Chapter 7 & 9.2 Assembly Language
Chapter 7 Assembly Language
COSC121: Computer Systems
Introduction to Computer Engineering
Chapter 5 The LC-3.
LC-3 Details and Examples
Chapter 7 LC-2 Assembly Language.
Chapter 6 Programming.
Chapter 5 The LC-3.
Introduction to Computer Engineering
Computer Science 210 Computer Organization
Introduction to Computer Engineering
Chapter 7 Assembly Language
Introduction to Computer Engineering
Chapter 6 Programming.
COSC121: Computer Systems
Chapter 7 Assembly Language
Introduction to Computer Engineering
Chapter 7 Assembly Language
Chapter 7 Assembly Language An Hong 2016 Fall
COSC121: Computer Systems
Introduction to Computer Engineering
Introduction to Computer Engineering
Introduction to Computer Engineering
Introduction to Computer Engineering
Chapter 6 Programming.
Chapter 7 Assembly Language
Chapter 5 The LC-3.
Presentation transcript:

Overview Program in LC-3 machine language Use the Editor Use LC-3 Simulator Trap Instruction

LC-3 Editor / Simulator Go to Authors’ Web page: Download: http://www.mhhe.com/patt2 Download: LC-3 Simulator – Win or Unix - (LC-3 Edit, LC-3 Simulate) LC-3 Simulator Lab Manual

Sum of 12 Integers Compute sum of 12 integers. Numbers start at location x3100. Program starts at location x3000. R1  x3100 R3  0 (Sum) R2  12(count) R2=0? R4  M[R1] R3  R3+R4 R1  R1+1 R2  R2-1 NO YES Write program

Sum integers from x3100 – x310B Address Instruction Comments x3000 1 1 1 0 0 0 1 0 1 1 1 1 1 1 1 1 R1  x3100 x3001 0 1 0 1 0 1 1 0 1 1 1 0 0 0 0 0 R3  0 x3002 0 1 0 1 0 1 0 0 1 0 1 0 0 0 0 0 R2  0 x3003 0 0 0 1 0 1 0 0 1 0 1 0 1 1 0 0 R2  12 x3004 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 1 If Z, goto x300A x3005 0 1 1 0 1 0 0 0 0 1 0 0 0 0 0 0 Load next value to R4 x3006 0 0 0 1 0 1 1 0 1 1 0 0 0 1 0 0 Add to R3 x3007 0 0 0 1 0 0 1 0 0 1 1 0 0 0 0 1 Increment R1 (pointer) X3008 0 0 0 1 0 1 0 0 1 0 1 1 1 1 1 1 Decrement R2 (counter) x3009 0 0 0 0 1 1 1 1 1 1 1 1 1 0 1 0 Goto x3004

The Add program in “binary” 0011000000000000 ;start x3000 1110001011111111 ;R1=x3100 0101011011100000 ;R3=0 0101010010100000 ;R2=0 0001010010101100 ;R2=R2+12 0000010000000101 ;If z goto x3009 0110100001000000 ;Load next value into R4 0001011011000100 ;R3=R3+R4 0001001001100001 ;R1=R1+1 0001010010111111 ;R2=R2-1 0000111111111010 ;goto x3004

The Add program in “hex” 3000 ;start x3000 E2FF ;R1=x3100 56E0 ;R3=0 54A0 ;R2=0 14AC ;R2=R2+12 0405 ;If z goto x3009 D840 ;Load next value into R4 16C4 ;R3=R3+R4 1261 ;R1=R1+1 14BF ;R2=R2-1 0FFA ;goto x3004

The Add program Data (hex) 3100 ; Begin data at x3100 3107 ; Loc x3100 2819 0110 0310 1110 11B1 0019 0007 0004 0000 0000 ; Loc x310B

LC3Edit Load the program into LC3Edit - Store it as prog.bin for a binary file, or Store it as prog.hex for a hex file - Create a prog.obj file with the Editor Load the data into LCEdit - Store it as data.bin for a binary file, or Store it as data.hex for a hex file - Create a data.obj file with the Editor

LC-3 Simulator Open LC-3 Simulator - Load prog.obj - Load data.obj - Set breakpoint(s) - Step through program

TRAP Calls a service routine, identified by 8-bit “trap vector.” When routine is done, PC is set to the instruction following TRAP. vector routine x23 input a character from the keyboard x21 output a character to the monitor x25 halt the program

TRAPS

Add HALT to “Add” program Add HALT statement and run program without breakpoint(s)

Example : Multiply Write program to Multiply two unsigned integers in R4 and R5

Example : Multiply This program multiplies two unsigned integers in R4 and R5. clear R2 add R4 to R2 decrement R5 R5 = 0? HALT No Yes Write program

Program to multiply [R4] x [R5] and place result in R2 x3200 Clear Accumulator (R2) R2 <- 0 x3201 Add [R4] to Accumulator R2 <- R2 + R4 x3202 Dec R5 R5 <- R5 – 1 x3203 Do again if [R5] > 0 BR p x3201 x3204 Stop HALT

Program to multiply [R4] x [R5] and place result in R2 Code program

Program to multiply [R4] x [R5] and place result in R2 x3200 Clear Accumulator (R2) R2 <- 0 0101 010 010 1 00000 54A0 x3201 Add [R4] to Accumulator R2 <- R2 + R4 0001 010 010 0 00 100 1484 x3202 Dec R5 R5 <- R5 – 1 0001 101 101 1 11111 1B7F x3203 Do again if [R5] > 0 BR p x3201 0000 001 111111101 03FD x3204 Stop HALT 1111 0000 00100101 F025 Test on Simulator

Write a program to place the absolute value of the [R2] in R2 How do we compute A = - A if we don’t have have a subtract instruction?

Example - # Occurrences of Inputted Char

Example - # Occurrences of Inputted Char Program (1 of 2) Address Instruction Comments x3000 0 1 0 1 0 1 0 0 1 0 1 0 0 0 0 0 R2  0 (counter) x3001 0 0 1 0 0 1 1 0 0 0 0 1 0 0 1 0 R3  M[x3102] (ptr) x3002 1 1 1 1 0 0 0 0 0 0 1 0 0 0 1 1 Input to R0 (TRAP x23) x3003 0 1 1 0 0 0 1 0 1 1 0 0 0 0 0 0 R1  M[R3] x3004 0 0 0 1 1 0 0 0 0 1 1 1 1 1 0 0 R4  R1 – 4 (EOT) x3005 0 0 0 0 0 1 0 0 0 0 0 0 1 1 1 0 If Z, goto x300E x3006 1 0 0 1 0 0 1 0 0 1 1 1 1 1 1 1 R1  NOT R1 x3007 0 0 0 1 0 0 1 0 0 1 1 0 0 0 0 1 R1  R1 + 1 X3008 0 0 0 1 0 0 1 0 0 1 0 0 0 0 0 0 R1  R1 + R0 x3009 0 0 0 0 1 0 1 0 0 0 0 0 1 0 1 1 If N or P, goto x300B

Example - # Occurrences of Inputted Char Program (2 of 2) Address Instruction Comments x300A 0 0 0 1 0 1 0 0 1 0 1 0 0 0 0 1 R2  R2 + 1 x300B 0 0 0 1 0 1 1 0 1 1 1 0 0 0 0 1 R3  R3 + 1 x300C 0 1 1 0 0 0 1 0 1 1 0 0 0 0 0 0 R1  M[R3] x300D 0 0 0 0 1 1 1 0 0 0 0 0 0 1 0 0 Goto x3004 x300E 0 0 1 0 0 0 0 0 0 0 0 1 0 0 1 1 R0  M[x3013] x300F 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 R0  R0 + R2 x3010 1 1 1 1 0 0 0 0 0 0 1 0 0 0 0 1 Print R0 (TRAP x21) x3011 1 1 1 1 0 0 0 0 0 0 1 0 0 1 0 1 HALT (TRAP x25) X3012 Starting Address of File x3013 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 ASCII x30 (‘0’)