Welcome to Cel Labs!

We've got some tasks lined up for you. I've left an 8041 microprocessor on your desk. This thing is state of the art.

  1. Choose a task by typing its name into the left modem.
  2. Connect your 8041 to the modems by clicking on the ports
  3. Write a program to solve the task. Consult your x67 Assembly Programming Manual for this.
8041
Assembly
Programming
Manual
8041
Assembly
Programming
Manual
Copyright © 1971, 1972 Simpel Corporation

Contents


  1. Concepts
    • Values
  2. Instruction Set

Concepts

Features

The 8041 microprocessor features the following components:

  • Two ports for input and output
  • One register for holding intermediate values
  • A display for editing code and observing its execution
  • Two buttons to control execution
The display holds a program that can be up to eight lines long. Each line of the program represents one instruction. You can begin execution by pressing the start button. Then every time you press the step button, the processor will execute one instruction and proceed to the next. Once the processor reaches the end of the program, it will return to the first instruction.

Each instruction begins with an opcode indicating which operation this is, followed by its operands, separated by spaces. The number and type of operands depends on the instruction. The different instructions are documented in the next section.

The instructions operate on values, which are numbers from -128 to 127. There are three types of operands:

  • A source, representing a value that the operation will take as input
  • A destination, representing a place where the operation will write a value
  • A label, representing a point in the program

There are three types of sources:

  • An immediate, which is a value written directly in the program. There are three ways to write an immediate:

    • In decimal, using the digits 0 through 9 and possibly a minus sign
    • In hexadecimal, beginning with a 0x prefix. The 16 hexadecimal digits are 0 through 9 followed by a through f.
    • In binary, beginning with a 0b prefix.
  • A port, indicated by writing the name shown next to the port
  • A register, indicated by writing the name of the register
A destination can be a port or a register, but not an immediate.

A register is a circuit that stores a value. The 8041 has one register, called ra. When the processor begins execution, the registers are initialized to hold the value 0. There is additionally the special register nil, which always holds the value 0. Any values written to nil are discarded.

A port allows the processor to communicate with other devices. When you read a value

from a port, the processor will block execution until a value is written to the connected port. Likewise, when you write a value to a port, execution will block until the value is read from the connected port.

A label is created by writing a name followed by a colon. The label can later be used as an operand by simply writing its name. As an example consider the following program which counts down from five, and then halts by entering an infinite loop:

  mov 5   ra

loop:
  mov ra  out
  sub 1   ra
  jnz ra  loop

stop:
  jmp stop

Instruction Set

Data Movement

mov <src> <dst>

Reads the value at <src> and writes it to <dst>.

Arithmetic

add <src> <dst>

Reads the value at <src> and adds it to the value at <dst>. This both reads and writes <dst>.

The rest of the arithmetic instructions follow a similar pattern, using <src> to update <dst>.

sub <src> <dst>

Subtracts <src> from <dst>.

Control Flow

jmp <label>

Jumps to <label>, so that execution will continue from there after this instruction.

jnz <src> <label>

Jumps to <label>, but only if <src> is non-zero.

simpel

SIMPEL CORPORATION, 3065 Bowers Avenue, Santa Clara, CA 95051 (617) 615-1613
more from Aaron

Tasks

cp

  • Reward: 1¢ / byte

The materials research group just bought some new tapes and they need help copying over their data. You can read the old tape through the `req` port, and then just write it as is to the `res` port. Should be a nice easy task to help you calibrate your equipment.

add

  • Reward: 10¢

The nuclear research group is running some simulations and they need help with compute. They'll write two numbers to `req` and they just need you to add them up and write the sum to `res`.

mul

  • Reward: 1$

They need help with multiplication too. This one's a little harder because your 8041 doesn't have a built in instruction to multiply two numbers. You're gonna have to implement the arithmetic yourself. I hear rumours that Simpel is gonna have a `mul` instruction on their next chip...

touppercase

  • Reward: 10$ / name

Yesterday HR asked Evan Conrad to leave the premises because they thought he didn't work here. He does of course work here. What happened, it turns out, was they searched for him in the new employee database as `CONRAD`, but he was in the system as `Conrad`, so he didn't come up. We're gonna fix this by converting every name in the database to uppercase.

The names are represented using the ASCII text encoding. This assigns each 7 bit number from 0 to 127 to a character. The first 32 characters from 0x00 to 0x1f are called the control characters, and they do not represent visible text. The remaining 96 characters from 0x20 to 0x7f include the lowercase letters, the uppercase letters, the digits, and all the standard punctuation that you can see on your

standard American keyboard. The only control character you need to know about for now is 0x00, the null byte. All of our systems here at Cel Labs represent a piece of text as a null-terminated string, which just means a sequence of non-null bytes with one null byte at the end.

Here's a table of all the ASCII characters:

0 1 2 3 4 5 6 7 8 9 a b c d e f
0x0-
0x1-
0x2- ! " # $ % & ' ( ) * + , - . /
0x3- 0 1 2 3 4 5 6 7 8 9 : ; < = > ?
0x4- @ A B C D E F G H I J K L M N O
0x5- P Q R S T U V W X Y Z [ \ ] ^ _
0x6- ` a b c d e f g h i j k l m n o
0x7- p q r s t u v w x y z { | } ~

Here we've put in visible substitutes for the control characters (0x00-0x1f) and delete (0x7f). 0x20 is space, that's why you can't see it. With our punchcard systems

when we make a mistake we punch out all the holes in that row to indicate that it should be ignored. With our digital systems we could just overwrite the mistake, but ASCII kept 0x7f (seven 1's in binary) as the delete character for compatibility.

For this task, you can read the names from `req` as ASCII null-terminated strings. Then replace every lowercase letter with the corresponding uppercase letter, and write the result to `res`, again as an ASCII null-terminated string. Any other characters should be passed through unaltered.

Microwave
Shed

Electronics Catalog – Fall 1972

Product Selection Guide

Microprocessors

Device Clock (Hz) Registers Ports Max LoC Extensions Price ($)
8041 1 2 8 0.01
8067 0.25 1 3 8 0.15
8069 2 2 3 10 B 1
80085 2 1 4 4 D
8008135 4 1 4 6 D

Device Clock (Hz) Registers Ports Max LoC
8041 1 2 8
80085 0.25 1 2 8
8008135 2 1 4 8

x67 Extensions

See the x67 Assembly Programming Manual for details on what features each extension adds.

B

The bit manipulation extension. See the x67 Assembly Programming Manual for details.

D

The 8067 Microcomputer is going to blow. your. mind.

You think you've seen a microcomputer before? Well you ain't seen jack. Do you have any idea how many transistors we fit in this bad boy? Yeah didn't think so. I'll tell you this much: it's a lot. And that's putting it nicely.

Free
Information
Service

To place an order, simply tick the box next to the name of the product you would like to purchase, and mail the card to us free of charge. A sales associate will be in touch to finalize details.

BUSINESS REPLY MAIL

NO POSTAGE NECESSARY IF MAILED IN U.S.A.
POSTAGE WILL BE PAID BY

Microwave Shed

P.O. BOX 7842
PHILADELPHIA, PA. 19101

Centipede.

This DP-11 got caught with its pants down.

It was forgetting to carry the one in the 64s place. Chances are you wouldn't have noticed; Inspector Kurt Kroner did.

There are 123,456 men at our Tainan factory with only one job: to inspect

DP-11s at each stage of production.

Every register is tested (spot checking won't do), every operation is fuzzed. DP-11s have been rejected for scratches barely visible to the eye.

We squash the centipedes; you get the caterpillars.