Computer Science 210 tutorial 5

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.
COMPSCI 210 Semester Tutorial 6 – Revision.
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:
LC-3 and Assembly code (2).  Minh Nguyen,  Tutorials:  Office hours:
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 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.
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
Dale & Lewis Chapter 5 Computing components. Let’s design a computer Generic CPU with registers −Program counter (PC) – 5 bits (size of addresses) −Instruction.
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
Chapter 8 Input/Output l I/O basics l Keyboard input l Monitor output l Interrupt driven I/O l DMA.
Introduction to Computing Systems from bits & gates to C & beyond Chapter 5 The LC-2 Instruction Set Architecture Operate instructions Data Movement instructions.
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.
Computer Architecture and Operating Systems CS 3230 :Assembly Section Lecture 3 Department of Computer Science and Software Engineering University of Wisconsin-Platteville.
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
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 Computer Organization
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.
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
Computer Science 210 Computer Organization
Chapter 7 LC-2 Assembly Language.
Chapter 6 Programming.
Computer Science 210 Computer Organization
Chapter 9 TRAP Routines and Subroutines
Computer Science 210 Computer Organization
Computer Science 210 Computer Organization
Computer Science 210 Computer Organization
Computer Science 210 Computer Organization
Computer Science 210 Computer Organization
Chapter 7 Assembly Language
Introduction to Computer Engineering
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.
Computer Architecture
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
Chapter 9 TRAP Routines and Subroutines
Chapter 9 TRAP Routines and Subroutines
Chapter 7 Assembly Language
Chapter 9 TRAP Routines and Subroutines
Presentation transcript:

Computer Science 210 tutorial 5 LC-3 and Assembly code (2)

Tutorial 4 revision 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.

Chapter 7.1 example (1) 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

7.1 example (2)

Input/output(1) Input and output: Try running GetC.asm 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

Input/output(2) GetC Out In Puts 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 Puts It prints out a String Look at printString.asm

Branch operation 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: http://www.lc3help.com/tutorials/Basic_LC- 3_Instructions

Run some Examples BR.asm Example1.asm Example2.asm Others

Exercise 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: 0 1 2 3 4