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



Similar documents
1 Description of The Simpletron

Notes on Assembly Language

Chapter 7 Lab - Decimal, Binary, Octal, Hexadecimal Numbering Systems

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

CSI 333 Lecture 1 Number Systems

Oct: 50 8 = 6 (r = 2) 6 8 = 0 (r = 6) Writing the remainders in reverse order we get: (50) 10 = (62) 8

BASIC COMPUTER ORGANIZATION AND DESIGN

Instruction Set Architecture (ISA)

UNIVERSITY OF CALIFORNIA, DAVIS Department of Electrical and Computer Engineering. EEC180B Lab 7: MISP Processor Design Spring 1995

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

Section 1.4 Place Value Systems of Numeration in Other Bases

Today. Binary addition Representing negative numbers. Andrew H. Fagg: Embedded Real- Time Systems: Binary Arithmetic

Goals. Unary Numbers. Decimal Numbers. 3,148 is s 100 s 10 s 1 s. Number Bases 1/12/2009. COMP370 Intro to Computer Architecture 1

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

COMP 250 Fall 2012 lecture 2 binary representations Sept. 11, 2012

Computer Science 281 Binary and Hexadecimal Review

Instruction Set Design

In this Chapter you ll learn:

Computer Organization and Architecture

1.6 The Order of Operations

Basic Formulas in Excel. Why use cell names in formulas instead of actual numbers?

Base Conversion written by Cathy Saxton

The string of digits in the binary number system represents the quantity

Binary Adders: Half Adders and Full Adders

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

Embedded Systems. Review of ANSI C Topics. A Review of ANSI C and Considerations for Embedded C Programming. Basic features of C

MACHINE ARCHITECTURE & LANGUAGE

Section 4.1 Rules of Exponents

EE 261 Introduction to Logic Circuits. Module #2 Number Systems

The Hexadecimal Number System and Memory Addressing

Chapter 2. Binary Values and Number Systems

Lab Experience 17. Programming Language Translation

Digital System Design Prof. D Roychoudhry Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur

Useful Number Systems

Microprocessor & Assembly Language

ASSEMBLY PROGRAMMING ON A VIRTUAL COMPUTER

Comp Computer Organization Lab 07 The HACK Assembly Language

1 Classical Universal Computer 3

An Introduction to the ARM 7 Architecture

CDA 3200 Digital Systems. Instructor: Dr. Janusz Zalewski Developed by: Dr. Dahai Guo Spring 2012

Numbering Systems. InThisAppendix...

LC-3 Assembly Language

Introduction to MIPS Programming with Mars

Session 7 Fractions and Decimals

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

NUMBER SYSTEMS. 1.1 Introduction

Summary of the MARIE Assembly Language

Lab 1: Full Adder 0.0

Slope & y-intercept Discovery Activity

Creating Basic Excel Formulas

Visual Logic Instructions and Assignments

5. Tutorial. Starting FlashCut CNC

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

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

BINARY CODED DECIMAL: B.C.D.

UIL Computer Science for Dummies by Jake Warren and works from Mr. Fleming

Digital Design. Assoc. Prof. Dr. Berna Örs Yalçın

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

=

Model 288B Charge Plate Graphing Software Operators Guide

CSC 2405: Computer Systems II

The 104 Duke_ACC Machine

Two's Complement Adder/Subtractor Lab L03

CPU Organisation and Operation

Lecture 2 Mathcad Basics

Administrative Issues

MICROPROCESSOR AND MICROCOMPUTER BASICS

How to test and debug an ASP.NET application

Computer organization

Divide: Paper & Pencil. Computer Architecture ALU Design : Division and Floating Point. Divide algorithm. DIVIDE HARDWARE Version 1

TI-83/84 Plus Graphing Calculator Worksheet #2

Using Formulas, Functions, and Data Analysis Tools Excel 2010 Tutorial

The Little Man Computer

To convert an arbitrary power of 2 into its English equivalent, remember the rules of exponential arithmetic:

Memory Management Simulation Interactive Lab

DsPIC HOW-TO GUIDE Creating & Debugging a Project in MPLAB

CS101 Lecture 11: Number Systems and Binary Numbers. Aaron Stevens 14 February 2011

PART B QUESTIONS AND ANSWERS UNIT I

2011, The McGraw-Hill Companies, Inc. Chapter 3

Systems I: Computer Organization and Architecture

ELFRING FONTS UPC BAR CODES

The goal is to program the PLC and HMI to count with the following behaviors:

Unit 1 Number Sense. In this unit, students will study repeating decimals, percents, fractions, decimals, and proportions.

Direct Translation is the process of translating English words and phrases into numbers, mathematical symbols, expressions, and equations.

Section 1.5 Exponents, Square Roots, and the Order of Operations

PROBLEMS (Cap. 4 - Istruzioni macchina)

Decimal Number (base 10) Binary Number (base 2)

Training Simulator and Demo Software

SYSTEMS OF EQUATIONS AND MATRICES WITH THE TI-89. by Joseph Collison

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

Integers (pages )

Chapter 5 Instructor's Manual

PREPARATION FOR MATH TESTING at CityLab Academy

Math Workshop October 2010 Fractions and Repeating Decimals

CPU Organization and Assembly Language

An Introduction to MPLAB Integrated Development Environment

EC 362 Problem Set #2

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

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

Installing and using XAMPP with NetBeans PHP

Transcription:

Comp 255Q - 1M: Computer Organization Lab #3 - Machine Language Programs for the PDP-8 January 22, 2013 Name: Grade /10 Introduction: In this lab you will write, test, and execute a number of simple PDP-8 machine code programs. Because of its complexity and with the advent of assemblers (programs which translated assembly language program in to machine code) that simplified programming computers, machine code programming is not done anymore although there might be some pedagogical merit in having done it at least once. Part I - Overview: To start the PDP8 Emulator program click on Q:\Computer Science\Executables\PDP-8\PDP8Main.exe Note: The PDP-8 Emulator program can also be downloaded from the Web Links page of the course website. A. A brief tour of the PDP-8 Emulator Program Using the arrow keys to maneuver (no mouse) The Debug Screen registers, memory, command window The memory cursor Think base 8! Getting to Page 1: > p 200 MS-DOS file naming conventions (8 letters max; no embedded spaces) e.g.. h:\comp255\lab3pt01.pal 1

B. A Subset of PDP-8 Instructions (PDP-8 Lite) The programs to be written will be very simple and will only require a handful of machine code instructions. The eleven that we will use (four MRI and five op-code 7 instructions) are given below. Four MRI instructions (where xxx is indirect bit + memory page bit + 7 bit offset) 1xxx Twos Complement Add (TAD) - 12xx or 13xx aka Load 2xxx Increment and Skip on Zero (ISZ) - 22xx or 23xx 3xxx Deposit and Clear Accumulator (DCA) - 32xx or 33xx aka Store 5xxx unconditional Jump (JMP) - 52xx or 53xx Note: Two s Complement Add is also a Load command if the accumulator is first cleared (i.e. set to 0); likewise Deposit and Clear is the same as a (destructive) Store command as it stores the contents of the accumulator in memory while clearing the accumulator. Increment and Skip on Zero can be used as a loop command (see Part 3) or as a simple increment command (see Part 4) Seven op-code 7 micro-instructions 7300 Clear Accumulator and Link (CLA CLL) 7041 Complement Accumulator and Increment (CMA IAC or CIA); same as Negate Accumulator 7500 Skip next instruction on Minus Accumulator (SMA) 7440 Skip on Zero Accumulator (SZA) 7510 Skip next instruction on Positive (or zero) Accumulator (SPA) 7450 Skip on Non-zero Accumulator (SNA) 7402 Halt C. Determining MRI Operand Addresses: Although the PDP-8 has four addressing modes, we ll restrict ourselves to using current page (direct) addressing for our MRI instructions where the effective address is obtained by concatenating the page number of the address of the MRI instruction (bits 0...4) with the contents of the offset field of the instruction. This means the operand referenced by the MRI instruction is always on the same page as the instruction. op-code 0 1 o f f s e t +---+---+---+---+---+---+---+---+---+---+---+---+ Determining the offset value for an instruction from a known effective address is easy assuming current page addressing; simply convert the octal value into binary (12 bits) and use the last 7 (bits 5 11) for the offset value. Using current page addressing on page 1 has the added advantage that the right-most 3 digits of the MRI instruction is the actual address of the operand. This is true only for page 1. D. Placing Code in Memory PDP-8 programs have (at least) two segments: a data segment (a contiguous block of words where data is stored) and a code segment. It s important to separate the two as you don t want to execute your data and you don t want to operate on your code. The standard PDP-8 convention seems to be that code starts at location 0200o (beginning at the upper half page 1) and data goes somewhere below. We ll position data starting at location 0300o (beginning at the lower half of page 1). Since our initial programs are small, code and data will not overlap. For out first program we will write, test and execute a PDP-8 machine code program that adds two integers; specifically the program will sum 2 plus 3 and will look like the c program below. All addressing will be current page (direct) addressing. 2

int main() { int a = 2, b = 3, c; // declare variables c = a + b; } 1. Start by writing out the machine code for this program using the PDP-8 Machine Code Form. The code will be placed on page 1 beginning at address 0200 (all values are in octal); data will be placed on page 1 beginning at address 0300. 2 When you have written out the machine code, start the PDP-8 Emulator and go to the Debugger Screen to enter the machine code directly into the PDP-8 memory. Use the P command >P200 (enter) to place the memory cursor at address 0200 on page 1. You should see addresses 0200 through 0377 in the memory display (upper right). Enter the code from the PDP-8 Machine Code Form starting at address 0200. As you enter each 4 digit code hit (Enter). This will automatically advance the memory cursor. Use the arrow keys to move the cursor to address 0300 and enter the data values the same way. Before continuing check that the program and code/data you entered agrees with your code. 3. Trace (single step) the execution of this code by positioning the memory cursor on the location of the first instruction, address 0200 (this also sets the Program Counter to 0200) and use the Space Bar to single step through the code. Hit the Space Bar 5 times noting how the PC, AC, and IR registers change. 4. Enter different values for a and b and re-execute the program. Use the values below. 0300/0022 0301/0017 0302/0000 Position the memory cursor at location 0200 (i.e. set the PC equal to 0200) and hit the G (Go) key. What happened? Try it a third time with 0300/7776 0301/0002 0302/0000 Explain what happened? (Hint: Check the Link bit) E. Saving a copy of your machine code: Use the w - Write command (see below) to save your code to a file. Call your file h:\comp255\lab3pt01.obj. The code is saved in address/contents format (i.e. nnnn/mmmm). When saved, open your file using NotePad and print out a copy of the file. You can also attach comments to each line of machine code explaining what each line of machine code does. Be sure to attach your name and date as a comment. >w h:\comp255\lab3pt01.obj Note: The >l (load) command can read this file back into PDP-8 memory (use >l h:\comp255\lab3pt01.obj). Reset (clear) the memory first (use >r for reset) and try it. Verification #1: 3

Part 2 - Subtraction: Write a program to subtract b from a putting the result in c (i.e. c = a b). Since there is no PDP-8 subtract instruction we have to first negate b then add a to it (note the order). Again (using the common convention) we will place this code on page beginning at address 0200 for code. Data will be placed beginning at 0300 with a being stored at 0300, b at 0301, and c at 0302. Here is the logic 0200, clear accumulator and link load b negate b add a store result to c halt jump to 0200 Do the following 1. Clear (Reset) the PDP-8 memory (> R) and go to page 1 (> P 200) 2. Using a PDP-8 Machine Code Form write out the machine code. Locate a, b, and c at addresses 0300 0302. Feel free to choose convenient values for a and b making sure a is greater than b. Set c to 0. 3. Enter your code starting at address 0200 and the data at starting at address 0300 4. Trace (single step) the execution of this code. Position the memory cursor on the location of the first instruction, address 0200 and use the (Space Bar) to single step through the code. Hit the Space Bar 6 times noting how the PC, AC, and IR registers change. 5. Run Again: Using different values for a and b execute your program again. Enter the following values into a, b, and c. 0300/0017 0301/0023 0302/0000 Position the memory cursor at location 0200 (i.e. set the PC equal to 0200) and hit the G (Go) key. What happened? Is this answer correct? Think, what would a negative number look like? Explain what happened 5. Save a copy of your machine code:. Use the w - Write command (see below) to save your code to a file. Call your file lab3pt02.obj. The code is saved in address/content format (i.e. nnnn/mmmm). When saved, open your file using NotePad, attach name and date and print out a copy of the file Verification #2: 4

Part 3 - Multiplication using a Simple Counting Loop: On page 3.11 of The PDP-8 Emulator User's Manual there is a program that executes a simple counting loop. The program demonstrates how the ISZ and JMP instructions are used to control a loop although the loop itself (addresses 0204-0205) is empty. Write a program using a loop to multiply. The program will loop N times but to do so, the value in N is first negated and stored in a second location called Counter. The Increment and Skip on Zero increments the negative value in Count skipping over the Jump instruction when Counter equals 0. Here is the logic. 0200, Clear Accumulator and Link Deposit to P (and clear accumulator) Load Accumulator with N Negate Deposit to Counter (and clear accumulator) 0205, Add M into Accumulator Increment Counter and Skip on Zero Jump to 0205 Deposit to P (and clear accumulator) Halt Jump to 0200 Each step above is one machine code instruction. Do the following 1. Using a PDP-8 Machine Code Form write out the complete code first. Code should start at address 0200, data at address 0300. Allocate four words of memory for Counter, N, M, and P using memory locations 0300 0302 address/contents ; comment description 0300/0000 ; Counter 0301/0003 ; N = 3 0302/0005 ; M = 5 0303/0000 ; P 2. Go back to the PDP-8 simulator. Reset memory and go to page 1. > r > p 0200 3. Entering Your Code 4. Trace (single step) the execution of the code (remember your value are all in octal). What is 3*5 base 8? 5. Save a copy of your machine code file (>w lab3pt03b.obj) then use NotePad to added your name and date and to to print out a copy of your machine code to be handed in. Verification #3: 5

Part 4: Division Just as repeated addition can be used for multiplication, so can repeated subtract be used for division but it can t be a counting loop as was the case for multiplication (why?). To compute a divided by b you will need to declare five variables see below 0300/0077 ; a 0301/0013 ; b 0302/0000 ; mb minus b 0303/0000 ; q - quotient 0304/0000 ; r - remainder Here is the logic 0200, clear accumulator and link load b negate b store at mb (i.e. minus b) load a 0205, add mb recall it s negative skip on positive accumulator go to 0212 increment q Jump to 0205 0212, add b // restore the remainder Deposit to r Halt Jump to 0200 Do the following 1. Using a PDP-8 Machine Code Form write out the complete code first. Code starts at address 0200; data allocation starting at location 0300 is given above. 2. Reset/clear memory (> R), move to page 1 (>P 200). Enter the code 3. Execute your program verify that the correct quotient and remainder are found at locations 0303 and 0304. Save a copy of your machine code: Use the w - Write command (see below) to save your code to a file. Call your file lab3pt04.obj. The code is saved in address/content format (i.e. nnnn/mmmm). When saved, open your file using NotePad, attach name and date, and print out a copy of the file >w h:\comp255\lab3pt04.obj Verification #4: Hand In This lab assignment sheet Print outs of programs lab3pt02.obj, lab3pt03.obj and lab3pt04.obj 6