Personal tools
You are here: Home → Comp 150 Introduction to Computing → Course Materials → Pep/8 Materials → Pep/8 Quick Notes
Document Actions

Pep/8 Quick Notes

by Dr. William L. Honig — last modified 2010-11-21 03:55 PM

A quick introduction to Pep/8 machine code programming

Pep/8 – Quick Notes

 

Contains:

1.     Pep/8 architecture summary

2.     Pep/8 use and programming help

(current with Pep/8 version 8.1.3)

 

1.     Pep/8 Architecture Overview

 

Pep/8 is a virtual computer, similar to real world processors in your PC but simplified. Most would classify Pep/8 as a Complex Instruction Set (CISC) computer. 

 

Machine Code instructions of Pep/8:

            Instructions – 8 or 24 bits long

                        Op Code – 4 to 8 bits defines the instruction

                        39 instructions (different functions for the computer)

Instructions have two parts

                        Instruction Specifier always 8 bits

                                    Includes Op Code

                                    Sometimes a Register Specifier (1 bit)

                                    Sometimes an Addressing Mode (1 or 3 bits)

Operand Specifier 16 bits (optional)

 

Key parts of Pep/8:

            Registers (16 bits) for doing calculations (we will use A mostly)

                        A or Accumulator (Register Specifier= 0)

                        X or Index (Register Specifier=1)

Memory 65,536 bytes (64Kbytes actually 64Kibi)

            Addressed as 0000 to FFFF

Application programs address from 0000 to 0FFF (12 bits) with Immediate Mode

            Bottom of memory (largest numbers) is ROM for the OS

            A stack grows up (lower numbers) from on top of the OS   

Addressing Modes we will use

            Immediate (Addressing Mode=000 binary)

                        Operand Specifier is the 16 bits of data to be used

            Direct (Addressing Mode=001 binary)         

Operand Specifier is the 12 bit address of the 16 bits of data to be used

            Program Counter PC 16 bits

                        Address in memory of the next instruction to be executed

            Instruction Register (IR) 24 bits

Holds the instruction current being executed (instructions are brought from memory into the IR in the CPU when they are executed)

2.     Programming Machine Code

 

Download Pep/8 from http://code.google.com/p/pep8-1/

 

For Windows, unzip and run the .exe file.  See menu Help -> Writing Program -> Machine Language.

 

Enter code into the Object Code Window.  Menu File -> SaveObjectAs to save your machine code as a .pepo file.  Menu Build -> Load to put your program into memory.  If no errors Menu Build -> Execute to run it.  Use the Terminal I/O tab for any input or output.

 

I find it helpful to write machine code by hand in a table before entering it into the Object Code Window (the three bytes of the instruction go in the middle three columns):

 

Address

 

 

 

Notes

0000

 

 

 

 

0003

 

 

 

 

0006

 

 

 

 

0009

 

 

 

 

000C

 

 

 

 

000F

 

 

 

 

0012

 

 

 

 

0015

 

 

 

 

 

 

Useful Instructions (immediate and direct forms; register specifier 0 means A):

          C0 (Load into A Immediate)              C1 (Load into A from Address)

            00 (Stop)                                             E1 (Store A into Address)

            70 (Add to A Immediate)                   71 (Add contents of Address to A)

            80 (Subtract from A Immediate)        81 (Subtract Address contents from A)

            50 (Character Output Immediate)      51 (Character Output from Address)

            38 (Decimal Output Immediate)         39 (Decimal Output from Address)

            49 (Character Input to Address)         31 (Decimal Input to Address)

           

 

 

W.L.Honig, Loyola University Chicago, for Comp150, Fall 2010.  Pep8QuickNotes.doc

whonig@luc.edu

Version 1 (original)

« July 2027 »
Su Mo Tu We Th Fr Sa
123
45678910
11121314151617
18192021222324
25262728293031
 

Powered by Plone CMS, the Open Source Content Management System

This site conforms to the following standards: