LC-3 and Assembly code (2).  Minh Nguyen,  Tutorials:  Office hours:

Slides:



Advertisements
Similar presentations
Computer Science 210 Computer Organization Strings, I/O, and Trap Service Routines.
Advertisements

MIPS assembly. Review  Lat lecture, we learnt  addi,  and, andi, or, ori, xor, xori, nor,  beq, j, bne  An array is stored sequentially in the memory.
Chapter 7 Introduction to LC-3 Assembly Language Assembly Language Assembly Process Using the Editor & Simulator for Assembly Language Programming.
SPIM and MIPS programming
More on Assembly CS 210 Tutorial 4. Detail of Echo program entry main.enter; import "../IMPORT/callsys.h"; block main uses CALLSYS { code { public enter:
1 Lecture-2 CSIT-120 Spring 2001 Revision of Lecture-1 Introducing Computer Architecture The FOUR Main Elements Fetch-Execute Cycle A Look Under the Hood.
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.
Chapter 9 Overview Traps mechanism & RET Subroutines & JSR & JSRR & RET Interrupt mechanism & RTI.
Chapter 6 Programming in Machine Language The LC-3 Simulator
1 Lecture-2 CS-120 Fall 2000 Revision of Lecture-1 Introducing Computer Architecture The FOUR Main Elements Fetch-Execute Cycle A Look Under the Hood.
Introduction to LC-3 Assembly Language
Overview Projects The Assembly Process Programmed I/O Interrupt Driven I/O.
Chapter 8 Overview Programmed I/O Introduction to Interrupt Driven I/O Project 3.
Chapter 8 I/O Programming Chapter 9 Trap Service Routines Programmed I/O Interrupts Interrupt Driven I/O Trap Service Routines.
Chapters 4 & 5: LC-3 Computer Architecture Machine Instructions Assembly language Programming in Machine and Assembly Language.
The von Neumann Model – Chapter 4 COMP 2620 Dr. James Money COMP
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 Computing Systems from bits & gates to C & beyond Chapter 5 The LC-3 Instruction Set Architecture ISA Overview Operate instructions Data.
ORDER OF CONTENT AND INSTRUCTIONS A program in its simplest form usually contains three kinds of activity:  INPUT : The program asks the user for some.
End of unit assessment Challenge 1 & 2. Course summary So far in this course you have learnt about and used: Syntax Output to screen (PRINT) Variables.
Lecture 161 Lets examine a SPIM program in detail. io.asm This program is a simple routine which demonstrates input/output using assembly code. SPIM.
© GCSE Computing Candidates should be able to:  describe the characteristics of an assembler Slide 1.
The von Neumann Model – Chapter 4 COMP 2620 Dr. James Money COMP
Spring 20067W. Rhett Davis with minor modification by Dean Brock UNCA ECE 406Slide 1 ECE 406 Design of Complex Digital Systems Lecture 11: Data Converter,
Integers/Characters Input/Output Integers and Characters Input/Output System Calls. syscall Trap Handler Services for Integers and Characters Read Integer,
Compsci 210 Tutorial Five.
Computer Science 210 Computer Organization
Computer Science 210 tutorial 5
Introduction to Computer Engineering
Chapter 7 Assembly Language
Chapter 9 TRAP Routines and Subroutines
Chapter 7 & 9.2 Assembly Language
Computer Science 210 Computer Organization
Compsci 210 Tutorial Four.
Computer Science 210 Computer Organization
Integers/Characters Input/Output
CHAPTER 6: The Little Man Computer
Computer Science 210 Computer Organization
Chapter 7 Assembly Language
Chapter 9 TRAP Routines and Subroutines
Chapter 7 LC-2 Assembly Language.
Chapter 6 Programming.
Computer Science 210 Computer Organization
Chapter 9 TRAP Routines and Subroutines
Introduction to Computer Engineering
Computer Science 210 Computer Organization
Computer Science 210 Computer Organization
MIPS coding.
Computer Science 210 Computer Organization
Chapter 7 Assembly Language
Chapter 9 TRAP Routines and Subroutines
TRAP Routines Subroutines Privileged Instructions
Chapter 9 TRAP Routines and Subroutines
Chapter 7 LC-2 Assembly Language.
Chapter 6 Programming.
Chapter 7 Assembly Language
Chapter 9 TRAP Routines and Subroutines
Chapter 7 Assembly Language
TRAP Routines Privileged Instructions Subroutines
Chapter 9 TRAP Routines and Subroutines
Introduction to Computer Engineering
Some Assembly (Part 2) set.html.
Chapter 9 TRAP Routines and Subroutines
Chapter 9 TRAP Routines and Subroutines
Introduction to Computer Engineering
Chapter 7 Assembly Language
Chapter 9 TRAP Routines and Subroutines
Presentation transcript:

LC-3 and Assembly code (2)

 Minh Nguyen,  Tutorials:  Office hours:

 After tutorial 4, you have learnt ◦ how to install LC-3 simulator ◦ Edit LC-3 assembly codes in editor ◦ Run simple programs ◦ Debug LC-3 by using Step over button  Run over tutorial 4 quickly once more time if needed.

 chapter7_code: 7.1.asm  What s the program doing? ◦ Program multiplies an integer by the constant 6. ◦ Before execution, an integer must be stored in NUMBER. ◦ Result stored in R3  Operations used: ◦ Ld $(register), VariableName ;load value to register from memory ◦ And $(register), $(register), #(decimalNumber) ;bitwise operation ◦ BRp Label ;branch (goto) to a Label in memory if register is positive

 Input and output: ◦ Get characters from keyboard to memory/register ◦ Print characters from memory/register to screen  Try running GetC.asm ◦ Program does: get 1 input from keyboard and print that out to screen.  Operations for input/output can be used: ◦ Getc ◦ Out ◦ In ◦ Puts

 GetC ◦ It takes a character from keyboard ◦ Store it in Register R0 (ascii value)  Out ◦ It takes ascii value stored in R0 ◦ Print the correspondent character out to screen  In ◦ It prints out a line ask user to input ◦ It takes a character from keyboard ◦ Store it in Register R0 (ascii value)  Puts ◦ It prints out a String ◦ Look at printString.asm

 By getC and Out, you can input 1 character and output 1 character at a time. In order to input and output more, you need loops.  Loops can be created by using Br (branch operation)  BR {n|z|p} Label  BRn branch to Label if register is negative  BRz branch to Label if register is zero  BRp branch to Label if register is positive   BRzp, BRzn, BRpn…  BRnzp branch without any condition  Clearer explanation: 3_Instructions 3_Instructions

 BR.asm  Example1.asm  Example2.asm  Others

 Exercise.asm  Input a number from 0 to 9  Print out all the number from 0 to that number  Skeleton code in exercise.asm  Example: ◦ Input: 4 ◦ Output: