Docstoc

Machine Language Instructions - PDF

Document Sample
Machine Language Instructions - PDF Powered By Docstoc
					2/24/2009

Layered Approach
• Shows the layers of computer abstraction – from hardware to programmer • Computer system can be examined at various levels of abstraction • At higher levels, fewer details of the lower levels are observed and new functional details are observed, implemented at these levels • Every level of abstraction provides set of building blocks with which the next higher level can be constructed with more functionality • The principle of hiding information is important for system design, enhances modularity, correctness, security, usability of system
Faculty of Computing and Information Technology

Levels of Abstraction
Highest Level Applications High Level Language Processor (Compiler) System Call Interface Assembler, Linker, Loader Operating System Device Drivers Microprogramming (Device Controllers) Digital Logic Lowest Level Transistors and Wires

Faculty of Computing and Information Technology

Intel 8085 Processor
• Follows von Neumann architecture • An 8-bit processor, that is 8 data lines, where 1 byte of data can be transmitted at a time • Has 6 general purpose registers B, C, D, E, H, L, each with 8 bits and associated in pairs • One 8-bit accumulator • One 16-bit stack pointer • One 16-bit program counter • One PSW (8-bit) with 5 flags
• Zero (Z): set when the result of operation is zero, • Sign (S): set when the sign of result is negative,
Faculty of Computing and Information Technology 3

Intel Processor
• Parity (P): set when parity of bits in result is even • Carry (C): stores result of addition that results into a carry or subtraction or comparison that results in a borrow • Auxilliary carry (AC): carry in BCD arithmetic

• 16 address and data lines (address space given by 0 – 216 - 1) • 20 control lines (20 control signals) • The address and data share the same bus lines and must take turns to use them (time multiplexing). The address is sent first, then data is sent or received
Faculty of Computing and Information Technology

Machine Language Instructions
Address/Data (16 lines)

Control lines (20)

Bus control S     Z           AC          P           C Processor Status Word

Clock

Program Counter (16 bits) Stack Pointer (16 bits) Accumulator (8 bits) B (8 bits)          C (8 bits) D (8 bits)          E (8 bits) H (8 bits)          L (8 bits) ALU General purpose registers

• At the time of execution, all instructions are made up of sequence of bytes (combination of zeros and ones) • These are known as machine language instructions, because they are in 0’s and 1’s form that is understood by the computer • All other forms of programs, assemblers, high level languages must be reduced to machine level form before they are executed

Faculty of Computing and Information Technology

Faculty of Computing and Information Technology

1

2/24/2009

Instruction Formats
• The format of an instruction refers to the arrangement of the instruction in order to assign meaning to the various groups of bits • The instruction has a portion that specifies what the instruction is to do, known as the operation code (opcode) • The address or piece of data required by the instruction to complete its execution is the operand • Instructions therefore consist of opcodes and a number of operands • Most computers do not need more than 2 operands for a single instruction
Faculty of Computing and Information Technology

Instruction Formats
• Instructions requiring only one operand are single operation instructions, others are double operand instructions • A quantity taken from a location provides the source operand, and the location that is changed or where source operand is taken is called the destination • All instruction formats reserve the first bits of the instruction for atleast part of the opcode but vary considerably from one computer to another otherwise • The remaining bits designate the operands or their locations
Faculty of Computing and Information Technology

Instruction Formats
• Instructions vary in length from 1 to 3 or 6 bytes Examples: • Register to register transfer
0     1     0      0      0      1      1      1 Opcode Destination (register B) Source (register A)

Addressing Modes
• These are methods used to locate and fetch an operand from an internal CPU register or from a memory location Each processor has its own addressing modes • Immediate addressing: information is part of the instruction. instruction No addressing is needed to get the information
• Mostly used for quantities that are constants • They are 2 byte instructions where the operand is the second byte

• Load accumulator from memory
0     0     1     1     1     0     1     0 Low order  Address High Order Address

• Direct addressing: the address is part of the instruction • Register addressing: the operand is in the register
Faculty of Computing and Information Technology

Faculty of Computing and Information Technology

Addressing Modes
• And the register’s address is part of the instruction • Indirect addressing: the address is in the location whose address is specified as part of the instruction
• Location may be register (register indirect addressing) • Or a memory location For example, add the contents of register R1 to the memory location whose address is in register R2

Addressing Modes
• Primarily used to reference arrays or in relocating a program in memory

• Indexing: the process of incrementing or decrementing an address as the computer sequences through a set of consecutive or evenly spaced addresses
• Done by successively changing an address stored in a register called an index register that can be incremented or decremented

• Base addressing: the address is formed by adding the contents of a memory location or register to a number called a displacement, which is part of the instruction
Faculty of Computing and Information Technology

• Auto incrementing / decrementing: the index is automatically incremented bsy an instruction

Faculty of Computing and Information Technology

2

2/24/2009

Assembler Language
• Type of language closer to machine language instructions, that is, there is an assembler language instruction for each machine language instruction • An assembler is a program that converts Assembler language (translates the symbolic statements of an assembly language program) into machine instructions (code) • Assembler language is more convenient for a programmer than a machine language which uses binary representation • Assembler language is an example of a mnemonic machine language (uses symbols)
Faculty of Computing and Information Technology

Assembler Language
• The assembler language is machine dependent, specific to certain computer systems (or families of computer systems) There are two types of statements in Assembler language: • Instructions: which are translated into machine code by the assembler • Directives: which give directions to the assembler during the assembly process but are not translated into machine code Each symbolic statement occupies a single line and is associated with one machine instruction
Faculty of Computing and Information Technology

Assembler Language
• Mnemonics indicate the type of instruction • Character strings called symbols or identifiers represent addresses and perhaps numbers • Typical assembler instruction would be: MOV A, M • Typical assembler directive would be: COST: DS 1 • This directive causes the assembler to reserve a byte and associate a symbol COST to it Example: Given a problem ANS: = X + Y, the 8085 microprocessor would solve it as:
Faculty of Computing and Information Technology

Assembler Language
LDA X MOV B, A LDA Y ADD B STA ANS • Most instructions involve movement of instruction from one part of the computer to another • Computers do not work on entities in a flexible manner, e.g., for the ADD instruction, the second operand must be in the accumulator • All programs, whatever the language, involve inputting, processing and outputting
Faculty of Computing and Information Technology

Assembler Instruction Format
The general format is: Label: Mnemonic Operand, Operand, ;remarks Label: • Symbol assigned to the address of the first byte of the instruction in which it appears • It is optional, if present provides a symbolic name optional that can be used in branch instructions to branch to an instruction • If there is no label, there is no colon • All instructions must contain a mnemonic, which can be an opcode or directive
• The opcode specifies the symbolic name for an instruction
Faculty of Computing and Information Technology

Assembler Instruction Format
• The directive specifies commands about the way to assemble the program

• The presence of operands depends on the instruction • The operand specifies the data needed by a statement • If there is more than one operand, they are separated by commas • Remarks (or comments) are for documenting the program; they are optional
• They provide clear explanation for a statement

Faculty of Computing and Information Technology

3

2/24/2009

Examples
BRADDR:
Label

Assembler Instruction Format
• Load accumulator from memory: e.g., LDA NUM
Mnemonic Address of the operand to be loaded into memory

MOV
Mnemonic

A, M
Destination Operand Source Operand

• Register-to-register Transfer e.g., NOW: MOV B, D
Source Operand Label Mnemonic Destination Operand

• Transfer of immediate operand to a register: e.g., MVI E, 6 Show the mnemonic, destination register and immediate data • Conditional branch on non-zero branch: e.g., JNZ HERE
Mnemonic Branch condition Address

Faculty of Computing and Information Technology

Faculty of Computing and Information Technology

Assembler Instruction Format
• All instructions are 1, 2, or 3 bytes long • Instructions involving only register or register indirect addressing are 1 byte long • Those that involve I/O or immediate operands are 2 or 3 bytes long • Th working registers are A (accumulator), B, C, The ki i t ( l t ) B C D, E, H and L Register addresses:
B C D E 000 001 010 011
Faculty of Computing and Information Technology

Assembler Instruction Format
Register pairs:
BC DE HL 00 01 10

H L A

100 101 111

• The registers are sometimes considered in pairs of BC, DE and HL • Both registers in the pair have the same higher 2 bits in their registers

Faculty of Computing and Information Technology

4


				
DOCUMENT INFO
Shared By:
Categories:
Stats:
views:212
posted:5/25/2009
language:English
pages:4
Description: At the time of execution all instructions are in binary