Overview Review Trap Instruction Program in LC-3 machine language Use LC-3 Simulator.

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

PART 6 Programming 1.Decomposition 2.Three Constructs 3.Counting Example 4.Debugging.
The LC-3 – Chapter 7 COMP 2620 Dr. James Money COMP
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.
Overview Program in LC-3 machine language Use the Editor
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.
Chapter 9 Overview Traps mechanism & RET Subroutines & JSR & JSRR & RET Interrupt mechanism & RTI.
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.
Overview Intro to Project 2 - Serial I/O – RS232, USB Assembly Language Programming Using the LC-3 Simulator.
Introduction to LC-3 Assembly Language
Overview Projects The Assembly Process Programmed I/O Interrupt Driven I/O.
LC-3 Instruction Set Architecture
Chapters 4 & 5: LC-3 Computer Architecture Machine Instructions Assembly language Programming in Machine and Assembly Language.
The LC-3 – Chapter 7 COMP 2620 Dr. James Money COMP
TCSS 490A Topics in Computing & Software Systems “Introduction to Computer Systems”
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 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.
The LC-3 – Chapter 5 COMP 2620 Dr. James Money COMP
Chapter 6 Programming Adapted from slides provided by McGraw-Hill Companies Inc., modified by professors at University of Wisconsin-Madison.
Chapter 7 Assembly Language
Chapter 9 TRAP Routines and Subroutines
Chapter 7 & 9.2 Assembly Language
Computer Science 210 Computer Organization
COSC121: Computer Systems: Review
Chapter 7 Assembly Language
COSC121: Computer Systems
Introduction to Computer Engineering
Chapter 9 TRAP Routines and Subroutines
Chapter 5 The LC-3.
Introduction to Computer Engineering
LC-3 Details and Examples
Chapter 7 LC-2 Assembly Language.
Chapter 5 The LC-3 An Hong 2018 Fall
Chapter 6 Programming.
Computer Science 210 Computer Organization
Chapter 5 The LC-3.
Introduction to Computer Engineering
Introduction to Computer Engineering
Chapter 6 Programming.
Introduction to Computer Engineering
Chapter 7 Assembly Language
Chapter 9 TRAP Routines and Subroutines
Chapter 7 Assembly Language An Hong 2016 Fall
COSC121: Computer Systems
Chapter 9 TRAP Routines and Subroutines
Chapter 9 TRAP Routines and Subroutines
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 Review Trap Instruction Program in LC-3 machine language Use LC-3 Simulator

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

LC-3 Editor / Simulator Go to Authors Web page ( ) Download LC-3 (LC301.exe) LC-3 Edit LC-3 Simulate Review “Guide to Using the Windows Version of the LC-3 Simulator and LC-3 Edit”

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

Example 1: 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

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

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

x3200 Clear Accumulator (R2)R2 < A0 x3201 Add [R4] to AccumulatorR2 <- R2 + R x3202 Dec R5R5 <- R5 – B7F x3203 Do again if [R5] > 0BR p x FD x3204 StopHALT F025 Program to multiply [R4] x [R5] and place result in R2 Test on Simulator

Example 2 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

Example 2 – Sum integers form x3100 – x310B 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

Write a program to place the absolute value of the [R2] in R2 Sample program 4

Example 3 - # Occurrences of Inputted Char

Example 3 - # Occurrences of Inputted Char 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

Example 3 - # Occurrences of Inputted Char 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’)

Program to display absolute value of number in R2 (-99 >= [R2] >= 99) Write program

Program to display absolute value of number in R2 (-99 >= [R2] >= 99) Find absolute value ADD R2, R2, #0 ; set cc14A0 BRzp NOT R2, R294BF ADD R2, R2, #114A1 R5 will contain x30 (#48), the offset for ASCII numbers AND R5, R5, #05B60 ADD R5, R5, #151B6F ADD R5, R5, #31B63 Check for [R2] >9 AND R4, R4, #0 ; init high digit holder to zero5920 ADD R2, R2, #-1014B6 BRn ADD R4, R4, #11921 BR -40FFC ADD R3, R2, #10 ; save low digit16AA If high digit = 0, don't display it ADD R4, R4, #0 ; set CC1920 BRz Display high digit ADD R0, R4, R51105 TRAP x21F021 Display low digit Add R0, R3, R510C5 TRAP x21F021 Halt TRAP x25F025