Basic Java
Compiler Compiler
Instruction Set Architecture
Assembly Language Byte Code
HW HW HW
Implementation 1 Implementation 2 Implementation N
1
Instruction Representation Simple Instruction Format
• In machine code each instruction has a • Following is a 16 bit instruction format
unique bit pattern
• For human consumption a symbolic
representation is used (assembly language)
• Opcodes are represented by abbreviations,
called mnemonics indicating the operation
— ADD, SUB, LDA, BRP, ...
• In an assembly language, operands can also • So...
—What is the maximum number of instructions
be represented as following
in this processor?
—ADD A,B (add contents of B and A and save
—What is the maximum directly addressable
the result into A)
memory size?
2
Two Address Machine (2) Two Address Machine (3)
• a.k.a. Memory-Memory Machine • a.k.a. Load-Store Instruction Set or
• Another possibility do stuff in memory! Register-Register Instruction Set
• These machines have registers used to • Typically can only access memory using
compute memory addresses load/store instructions
• 2 addresses (One address doubles as
operand and result) • Example: a = b + c;
• Example: a = b + c;
3
Types of Operand Pentium Data Types
4
Data Transfer Arithmetic
• Need to specify • Basic arithmetic operations are...
—Source —Add
—Subtract
—Destination
—Multiply
—Amount of data —Divide
—Increment (a++)
• May be different instructions for different —Decrement (a--)
—Negate (-a)
movements
—Absolute
• Or one instruction and different addresses • Arithmetic operations are provided for...
—Signed Integer
—Floating point?
—Packed decimal numbers?
5
An example To send the two characters in a word
6
Transfer of Control Branch Instruction
• Branch
—For example: brz 10 (branch to 10 if result is
zero)
• Skip
—e.g. increment and skip if zero
—ISZ Register1
—Branch xxxx
—ADD A
• Subroutine call
—c.f. interrupt call
Types of Types of
Operation Operation
7
Pentium Operation
CPU Actions for Various Types of Operations Types
8
PowerPC
Operation Types PowerPC Operation Types
9
Representing Floats Representing Strings
• Float F = 15213.0; • Strings in C • char S[6] = "15213";
Linux/Alpha F Sun F
—Represented by array of characters
00 46
B4 6D
—Each character encoded in ASCII format
6D B4 – Standard 7-bit encoding of character set
46 00 – Character “0” has code 0x30
+ Digit i has code 0x30+i Linux/Alpha S Sun S
—String should be null-terminated 31 31
IEEE Single Precision Floating Point Representation 35 35
– Final character = 0
Hex: 4 6 6 D B 4 0 0 32 32
Binary: 0100 0110 0110 1101 1011 0100 0000 0000 • Compatibility 31 31
15213: 1110 1101 1011 01 —Byte ordering is not an issue 33 33
00 00
– Data are single byte quantities
Not same as integer representation, but consistent across machines —Text files generally platform independent
Can see some relation to integer representation, but not obvious – Except for different conventions of line termination
character(s)!
10