The Little Man Computer



Similar documents
Exemplar Work for SAMs. Units A452 and A453

OAMulator. Online One Address Machine emulator and OAMPL compiler.

Notes on Assembly Language

what operations can it perform? how does it perform them? on what kind of data? where are instructions and data stored?

High level code and machine code

MACHINE ARCHITECTURE & LANGUAGE

VB.NET Programming Fundamentals

In this Chapter you ll learn:

Chapter 7 Assembly Language

LC-3 Assembly Language

ASSEMBLY LANGUAGE PROGRAMMING (6800) (R. Horvath, Introduction to Microprocessors, Chapter 6)

Compilers I - Chapter 4: Generating Better Code

TIMING DIAGRAM O 8085

1 Description of The Simpletron

The 104 Duke_ACC Machine

Comp 255Q - 1M: Computer Organization Lab #3 - Machine Language Programs for the PDP-8

1 Classical Universal Computer 3

Chapter 2 Topics. 2.1 Classification of Computers & Instructions 2.2 Classes of Instruction Sets 2.3 Informal Description of Simple RISC Computer, SRC

High-Level Programming Languages. Nell Dale & John Lewis (adaptation by Michael Goldwasser)

Sources: On the Web: Slides will be available on:

PROBLEMS (Cap. 4 - Istruzioni macchina)

Figure 1: Graphical example of a mergesort 1.

Central Processing Unit Simulation Version v2.5 (July 2005) Charles André University Nice-Sophia Antipolis

25 Integers: Addition and Subtraction

8085 INSTRUCTION SET

Introduction to Turing Machines

Playing with Numbers

Introduction. What is an Operating System?

EZ DUPE DVD/CD Duplicator

Stack machines The MIPS assembly language A simple source language Stack-machine implementation of the simple language Readings:

BASIC COMPUTER ORGANIZATION AND DESIGN

Administrative Issues

CS101 Lecture 26: Low Level Programming. John Magee 30 July 2013 Some material copyright Jones and Bartlett. Overview/Questions

Advanced Computer Architecture-CS501. Computer Systems Design and Architecture 2.1, 2.2, 3.2

PART B QUESTIONS AND ANSWERS UNIT I

CS 141: Introduction to (Java) Programming: Exam 1 Jenny Orr Willamette University Fall 2013

Introduction to Java

Visual Logic Instructions and Assignments

An Introduction to Assembly Programming with the ARM 32-bit Processor Family

Fall 2006 CS/ECE 333 Lab 1 Programming in SRC Assembly

EE282 Computer Architecture and Organization Midterm Exam February 13, (Total Time = 120 minutes, Total Points = 100)

Debugging. Common Semantic Errors ESE112. Java Library. It is highly unlikely that you will write code that will work on the first go

Exercises for Design of Test Cases

TETRIX Add-On Extensions. Encoder Programming Guide (ROBOTC )

9 Control Statements. 9.1 Introduction. 9.2 Objectives. 9.3 Statements

1. Convert the following base 10 numbers into 8-bit 2 s complement notation 0, -1, -12

MICROPROCESSOR AND MICROCOMPUTER BASICS

Summary of the MARIE Assembly Language

CHAPTER 11: Flip Flops

An Introduction to Number Theory Prime Numbers and Their Applications.

Chapter 7D The Java Virtual Machine

CPU Organisation and Operation

X86-64 Architecture Guide

Instruction Set Architecture (ISA)

We will use the accumulator machine architecture to demonstrate pass1 and pass2.

Name: Class: Date: 9. The compiler ignores all comments they are there strictly for the convenience of anyone reading the program.

MICROPROCESSOR. Exclusive for IACE Students iacehyd.blogspot.in Ph: /422 Page 1

Computer Architecture Lecture 2: Instruction Set Principles (Appendix A) Chih Wei Liu 劉 志 尉 National Chiao Tung University

PROGRAMMABLE LOGIC CONTROLLERS Unit code: A/601/1625 QCF level: 4 Credit value: 15 OUTCOME 3 PART 1

Boolean Expressions, Conditions, Loops, and Enumerations. Precedence Rules (from highest to lowest priority)

Moving from CS 61A Scheme to CS 61B Java

Instruction Set Architecture. or How to talk to computers if you aren t in Star Trek

CPU performance monitoring using the Time-Stamp Counter register

Lecture Outline. Stack machines The MIPS assembly language. Code Generation (I)

Exceptions in MIPS. know the exception mechanism in MIPS be able to write a simple exception handler for a MIPS machine

Symbol Tables. Introduction

CS 3719 (Theory of Computation and Algorithms) Lecture 4

1. a procedure that you perform frequently. 2. Create a command. 3. Create a new. 4. Create custom for Excel.

Registers & Counters

Here is a diagram of a simple computer system: (this diagram will be the one needed for exams) CPU. cache

ChE-1800 H-2: Flowchart Diagrams (last updated January 13, 2013)

Introduction to Theory of Computation

Chapter 5 Instructor's Manual

a storage location directly on the CPU, used for temporary storage of small amounts of data during processing.

Chapter 6: Programming Languages

8051 MICROCONTROLLER COURSE

GRID SEARCHING Novel way of Searching 2D Array

Translating C code to MIPS

2. Capitalize initial keyword In the example above, READ and WRITE are in caps. There are just a few keywords we will use:

The AVR Microcontroller and C Compiler Co-Design Dr. Gaute Myklebust ATMEL Corporation ATMEL Development Center, Trondheim, Norway

Computer organization

Keil C51 Cross Compiler

(Refer Slide Time: 00:01:16 min)

COMP 356 Programming Language Structures Notes for Chapter 10 of Concepts of Programming Languages Implementing Subprograms.

SATA Blu-ray/DVD/CD Duplicator Controller

Instruction Set Design

Contents Contents 1 The Voice Mail System VMS Operating your Mailbox with VMS

3515ICT Theory of Computation Turing Machines

Describe the process of parallelization as it relates to problem solving.

Microprocessor & Assembly Language

Addressing The problem. When & Where do we encounter Data? The concept of addressing data' in computations. The implications for our machine design(s)

MATH 140 Lab 4: Probability and the Standard Normal Distribution

Comp Computer Organization Lab 07 The HACK Assembly Language

Microcontroller Systems. ELET 3232 Topic 8: Slot Machine Example

Flowchart Techniques

Chapter 1. Computation theory

ETEC 2301 Programmable Logic Devices. Chapter 10 Counters. Shawnee State University Department of Industrial and Engineering Technologies

C Compiler Targeting the Java Virtual Machine

Introduction to MIPS Programming with Mars

PROBLEMS #20,R0,R1 #$3A,R2,R4

Transcription:

The Little Man Computer The Little Man Computer - an instructional model of von Neuman computer architecture John von Neuman (1903-1957) and Alan Turing (1912-1954) each independently laid foundation for today s computers - the stored program computer von Neuman Turing

Components of Little Man 901 100 storage locations indexed 0 thru 99 - each can store a 3 digit integer a unique 3 digit storage location called calculator or accumulator a 2 digit instruction location counter an inbox that can contain a 3 digit number an outbox that can contain a 3 digit number 00 09 accumulator instruction counter 90 99 Memory/Storage locations Inbox Outbox

A Little Man Program Consists of instructions placed in memory starting at position 00. An instruction is a 3 digit integer left digit an operation code 0 to 9 - telling what type of action to take right 2 digits 0 to 99 indicate memory position Instructions are of various sorts : some take information from inbox and place in the accumulator - such information called input some take information in the accumulator and place in outbox - such information called output some interact with information in accumulator

Little Man Operations operation mnemonic code description Input INP 901 info in inbox accumulator Output OUT 902 info in accumulator outbox Store STA 3xx info in accumulator location xx Load LDA 5xx info in location xx accumulator Add ADD 1xx info in location xx added to info in accumulator Subtract SUB 2xx info in location xx subtracted from info in accumulator Branch BRA 6xx reset program location indicator to location xx Branch if 0 BRZ 7xx if info in accumulator = 000, reset program location to xx Branch if 0 BRP 8xx if info in accumulator 0, reset program location to xx Halt END 0 stop program execution Data definition DAT used to define memory locations for storing data

Construction of Little Man Program The source code of a little man program is a list of mnemonic instructions. The collection of mnemonic instructions constitute the assembly language for Little Man programs The source code is compiled by a background program called the compiler The compiler places equivalent numeric 3 digit instruction codes sequentially in memory - could be done manually and must be done manually without computer implementation of the Little Man

Running a Little Man program Once compiled (an operation external to the program), the program is started by another operation external to the program called run Once started the first instruction in location 00 is executed and the instruction location counter is incremented from 0 to 1 The first Little Man instruction is often (but not always) an Input instruction - an outside agent puts information in the inbox for the input instruction to execute

Input operation (INP) The Input operation here - with 901 in location 00 takes 045 in the Inbox and places it in the accumulator increments the instruction counter from 0 to 1 00 09 901 0 4 5 1 accumulator instruction counter 0 4 5 90 99 Memory/Storage locations Inbox Outbox

Store operation (STA) The Store operation here - with 310 in location 01 takes 45 in the accumulator and places it in memory location 10 increments the instruction counter from 1 to 2 the accumulator retains its value 00 09 901 310 45 0 4 5 accumulator 2 instruction counter 0 4 5 90 99 Memory/Storage locations Inbox Outbox

A second Input operation A second input operation here - with 901 in location 02 waits for input takes new input 155 and put it in the accumulator increments the instruction counter from 2 to 3 00 09 901 310 901 45 1 5 5 accumulator 3 instruction counter 1 5 5 90 99 Memory/Storage locations Inbox Outbox

Add operation (ADD) An add operation is performed with a 110 in memory location 03 the right 2 digits signify that the contents of location 10 are added to the accumulator giving value 200 the instruction counter from 3 to 4 00 09 901 310 901 110 45 2 0 0 accumulator 4 instruction counter 1 5 5 90 99 Memory/Storage locations Inbox Outbox

Out operation (OUT) The Out operation is accomplished here with a 902 in location 05 the contents accumulator is put in the outbox - contents of accumulator not changed the instruction counter is incremented from 4 to 5 00 09 901 310 901 110 902 45 2 0 0 accumulator 5 instruction counter 1 5 5 2 0 0 90 99 Memory/Storage locations Inbox Outbox

HALT operation The Halt operation is accomplished here with a 000 in location 06. It signifies the end of the program 00 09 901 310 901 110 902 OOO 45 2 0 0 accumulator 5 instruction counter 1 5 5 2 0 0 90 99 Memory/Storage locations Inbox Outbox

The sequence of instructions constructed was: 901 310 910 110 902 OOO constitutes a Little Man program whose function adds two numbers We call above the machine code of the Little Man program. Corresponding assembly code INP STA INP ADD OUT END FIRST DAT FIRST FIRST Identifies FIRST as data - the compiler then allocates a memory position called FIRST. Our program has FIRST = 10. The label FIRST identifies a position in memory. It happens to be the 10th postion.

Branching and Labels Branching instructions allow program to execute some instructions under one condition and other instructions under other conditions Example: diagram of decision process to determine greater of 2 numbers START input FIRST input SECOND SECOND > FIRST? Output SECOND Output FIRST STOP

To implement example in source code using Little Man mnemonics - there is notion of the label of an instruction to be branched to or the label of a data storage position The assembly code with explanation for the example is: LABEL CODE ARGUMENT DESCRIPTION INP input data = x to accumulator STA FIRST place accumulator data x in memory location defined by FIRST INP input data = y to accumulator STA SECOND place accumulator data y in location defined by SECOND SUB FIRST subtract data in First from data in accumulator i.e. y - x BRP SEC_BIG if accumulator data ( y-x) 0, branch to SEC_BIG instruction LDA FIRST otherwise x < y, so load the value x in FIRST to accumulator OUT output the value x BRA END_PROG go to the end instruction SEC_BIG LDA SECOND here y x - so load value y in SECOND to accumulator OUT output the value y END_PROG HLT end the program FIRST DAT declare the data region labeled FIRST SECOND DAT declare the data region labeled SECOND

The assembly code with corresponding machine code in right column INST # LABEL CODE ARGUMENT MACHINE CODE 0 INP 901 1 STA FIRST 312 2 INP 901 3 STA SECOND 313 4 SUB FIRST 212 5 BRP SEC_BIG 809 6 LDA FIRST 512 7 OUT 902 8 BRA END_PROG 611 9 SEC_BIG LDA SECOND 513 10 OUT 902 11 END_PROG HLT OOO 12 FIRST DAT 13 SECOND DAT

Looping A loop is a fixed group of instructions which must be executed more than once dependent on a changing condition Condition Met? Yes NO Instructions in loop & increment condition Following Instructions

Looping Example - Little Man program that has output every odd number 99 INST # LABEL CODE ARG MACHINE CODE 0 INP 901 input first odd number = 1 1 LOOP SUB NUM 210 subtract 99 from value in accumulator 2 BRP END 807 if (value of accumulator - 99) 0, finished so go to END 3 LDA ODD 508 restore value of ODD to accumulator - was destroyed in #1 4 OUT 902 output value of accumulator = value of ODD 5 ADD TWO 109 add 2 to value of accumulator getting ODD + 2 6 BRA LOOP 601 Branch to instruction #1 - accumulator already set for next 7 END HALT OOO 8 TWO DAT 2 9 ODD DAT 1 Note that these 3 data declarations also declare values 10 NUM DAT 99

A second version of previous example - at instruction #3 subtraction gives positive numbers except when ODD = 101 INST # LABEL CODE ARG MACHINE CODE 0 INP 901 input first odd number = 1 1 LOOP STA ODD 311 put value of accumulator in ODD 2 LDA NUM 512 put 99 in accumulator 3 SUB ODD 211 subtract ODD from 99 4 BRP MORE 806 if value of accumulator 0 branch to MORE 5 END HLT otherwise stop 6 MORE LDA ODD 511 put value of ODD in accumulator 7 OUT 902 output value of ODD 8 ADD TWO 110 add 2 to value of accumulator - so it contains now ODD + 2 9 BRA LOOP 601 Branch to LOOP 10 TWO DAT 2 11 ODD DAT 1 Note that these 3 data declarations also declare values 12 NUM DAT 99

Playing with the Chen Little Man compiler My colleague Stephen Chen and his associate W.C.Cudmore have constructed a simulation of a Little Man compiler. Given Little Man assembly source code written with Little Man mnemonics, machine code is produced which can be executed Little Man Computer simulation Below are the two versions from the previous two slides - paste them into the simulation and run them. What is wrong with the first? Version 1 INP LOOP SUB NUM BRP END LDA ODD OUT ADD TWO BRA LOOP END HLT TWO DAT 2 ODD DAT 1 NUM DAT 99 Version 2 INP LOOP STA ODD LDA NUM SUB ODD BRP MORE END HLT MORE LDA ODD OUT ADD TWO BRA LOOP TWO DAT 2 ODD DAT 1 NUM DAT 99