Department of Computer and Information Science,
School of Science, IUPUI
Information Representation:
Machine Instructions Demo
Dale Roberts
xComputer Applet
xComputer applet – a java applet that simulates a simple
model computer (which is also called xComputer). The
model computer is discussed in Chapter 3 of The Most
Complex Machine. The xComputer consists of a Central
Processing Unit (CPU) and a main memory that holds
1024 sixteen-bit binary numbers. The CPU contains an
Arithmetic-Logic Unit (ALU) for performing basic
arithmetic and logical computations. It also contains
eight registers, which hold binary numbers that are
being used directly in the CPU's computations, a Control
circuit, which is responsible for supervising the
computations that the CPU performs, and a clock, which
drives the whole operation of the computer by turning
its single output wire on and off.
Dale Roberts
xComputer Instructions
xComputer uses 16 bits per instruction. 6 bits
are dedicated to the opcode, leaving 10 bits for
the operand.
The type of information stored in the operand is
dependent on the instruction being executed.
A listing of xComputer opcodes can be found at
The xComputer applet can be run from
Dale Roberts
Sample Opcodes
Assembly Name
000000 ADD
000001 SUB
Example Description
ADD 12 AC = AC + (12)
SUB 12 AC = AC – (12)
000010 AND
AND 12
Bitwise AND with
000011 OR
OR 12
Bitwise OR with
000100 NOT
Bitwise NOT of AC.
Parm ignored.
000101 SHL
000110 SHR
000111 INC
shift left 1 bit
001000 DEC
shift right 1 bit
(12) refers to the contents of address 12
Dale Roberts
Semantic Gap
Machine languages: Native tongue of a particular kind of computer.
instruction is a binary string. The code is used to indicate operations to be
performed and the memory cells to be addressed. This form is the easiest form for
computers to understand, but is the most difficult for a person to understand.
Assembly languages:
Again, specific to one type of computer. Uses
descriptive names for operations and data, e.g. “LOAD value”, “ADD delta”, “Store
value”. Assemblers translate this to machine language. Intermediate level.
Somewhat descriptive, but basically follow the machine instructions.
High-level languages:
Write program instructions called statements that
resemble a limited version of English. e.g. “value = value + delta”. Portable,
meaning it can be used on different types of computers without modification.
Compilers translate them to machine languages. Example are Fortran, Pascal,
COBOL, C, C++, Basic, etc.
Semantic gap between statements in a high-level language and
machine/assembly language. Each high level statement may represent many
hundreds of machine instructions. Compilers must bridge this gap.
Complex machine instruction computer try to reduce this gap by
implementing high-level language opcodes. This diminishes the semantic gap but
makes the machine instructions more complex, and therefore makes the CPU
circuitry more complex.
Dale Roberts
Real-life Example: Pentium 4.
The instruction set information for the Pentium 4 process can be found at
Dale Roberts
Pentium 4 ADD
Adds the first operand (destination operand) and the second operand
(source operand) and stores the result in the destination operand. The
destination operand can be a register or a memory location; the source
operand can be an immediate, a register, or a memory location.
(However, two memory operands cannot be used in one instruction.)
When an immediate value is used as an operand, it is sign-extended to
the length of the destination operand format. The ADD instruction
performs integer addition. It evaluates the result for both signed and
unsigned integer operands and sets the OF and CF flags to indicate a
carry (overflow) in the signed or unsigned result, respectively. The SF
flag indicates the sign of the signed result. This instruction can be used
with a LOCK prefix to allow the instruction to be executed atomically.
So you can see that the instructions are a little more complicated in real life than in
xComputer. But the same principles apply.
Dale Roberts
Pentium 4 Add (cont)
Dale Roberts
Several graphics and terms were obtained from Jonathan Michael Auld Central
Queensland University.
xComputer and its machine instructions were developed by David Eck.
Dale Roberts

Number Systems: Negative Integers and Floating Point