assembly & machine languages

19
Assembly & Machine Languages A Brief Overview Jonathan- Lee Jones

Upload: leal

Post on 23-Feb-2016

63 views

Category:

Documents


0 download

DESCRIPTION

Assembly & Machine Languages. A Brief Overview. Jonathan-Lee Jones. Overview of the Module. What operations can a computer can perform The Pep/8 virtual machine Immediate and direct addressing modes Writing simple machine-language programs Machine language and assembly language - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Assembly & Machine Languages

Assembly & Machine LanguagesA Brief Overview

Jonathan-LeeJones

Page 2: Assembly & Machine Languages

Overview of the Module

• What operations can a computer can perform• The Pep/8 virtual machine• Immediate and direct addressing modes• Writing simple machine-language programs• Machine language and assembly language• Creating and running an assembly-language program• Writing simple programs using the Pep/8 virtual

machine • Concept of assembler instructions

Page 3: Assembly & Machine Languages

What operations can a computer can perform• Interact with I/O

– reading input – Writing output – reading the program (in

memory) – reading constant values (in

memory) – reading and writing variables

(in memory) • Executing instructions in

machine language

Page 4: Assembly & Machine Languages

Overview

Page 5: Assembly & Machine Languages

Differences between machine language and assembly language

Machine LanguageThe language made up of binary coded instructions built into the hardware of a particular computer and used directly by the computer

Page 6: Assembly & Machine Languages

Differences between machine language and assembly language

Machine LanguageThis is very hard to understand by a human. It is a series of numbers, originally binary, but hexadecimal is more common today.

Page 7: Assembly & Machine Languages

Differences between machine language and assembly language

Machine LanguageThis originated from the early days of computing, where there were limited mechanisms of input; such as punched cards and even just a series of dials and switches.

Page 8: Assembly & Machine Languages

Differences between machine language and assembly language

Assembly Language• A language that uses mnemonic codes to represent

machine-language instructions• Much easier for the human to understand and read –

though nowhere near as easy as high level languages.• Harder for the computer to read! Requires and

assembler to use. An assembler is program that reads each of the instructions in mnemonic form and translates it into the machine-language equivalent

Page 9: Assembly & Machine Languages

Machine Language• Machine language – The language

made up of binary coded instructions built into the hardware of a particular computer and used directly by the computer

• Every processor type has its own set of specific machine instructions.

• The relationship between the processor and the instructions it can carry out is completely integrated.

• Each machine-language instruction does only one very low-level task Typically we have one instruction per “word”

Types of Instruction• data movement data

processing – op-code – what

operation is required – source 1 – operand 1– source 2 – operand 2– destination

• flow control (jumps)

Page 10: Assembly & Machine Languages

Machine Language

Types of Instruction

Data Move(actually a copy not

a move)

Flow controlBranch (jump to

address)Conditional

Branch (tests values)

Subroutine CallsReturn(from Subroutine)

Data Processingop-code – what operation

is required source 1 – operand 1source 2 – operand 2

destination

Page 11: Assembly & Machine Languages

Machine Language

Processing instructions • How many bits required?

addresses of operands and results – assume a 32 bit address for

memorythis would allow for 232 bytes of addressable memorythis would need 96 bits for the addresses in an instruction

• lets suppose 16 bits for the op-code (216 instructions) Each instruction is 112 bits !!

0101101110010110111001101101110010110111001101101110010110111001011011100101101110010110111001011011100101101110

01011011100101101110011011011100101101110011011011100101101110010110111001011011100101101110010110111001011011100101101110010110111001101101110010110111001101101110010110111001011011100101101110010110111001011011100101101110010110111001011011100110110111001011011100110110111001011011100101101110010110111001011011100101101110010110111001011011100101101110011011011100101101110011011011100101101110010110111001011011100101101110010110111001011011100101101110010110111001101101110010110111001101101110010110111001011011100101101110010110111001011011100101101110010110111001011011100110110111001011011100110110111001011011100101101110010110111001011011100101101110010110111001011011100101101110011011011100101101110011011011100101101110010110111001011011100101101110010110111001011011100101101110010110111001101101110010110111001101101110010110111001011011100101101110010110111001011011100101101110010110111001011011100110110111001011011100110110111001011011100101101110010110111001011011100101101110010110111001011011100101101110011011011100101101110011011011100101101110010110111001011011100101101110010110111001011011100101101110010110111001101101110010110111001101101110010110111001011011100101101110010110111001011011100101101110010110111001011011100110110111001011011100110110111001011011100101101110010110111001011011100101101110010110111001011011100101101110011011011100101101110011011011100101101110010110111001011011100101101110010110111001011011100101101110010110111001101101110010110111001101101110010110111001011011100101101110010110111001011011100101101110010110111001011011100110110111001011011100110110111001011011100101101110010110111001011011100101101110010111101110

Page 12: Assembly & Machine Languages
Page 13: Assembly & Machine Languages

PEP/8 Virtual ComputerInstruction Format • Operation code – Specifies

which instruction is to be carried out

• Register specifier – Specifies which register is to be used (we will only use A for the moment)

• Addressing-mode specifier – Says how to interpret the operand part of the instruction

Page 14: Assembly & Machine Languages

PEP/8 Virtual ComputerSome Sample Instructions • 0000 Stop Execution• 1100 Load operand to A Register• 1110 Store contents of A Register into

operand• 0111 Add operand to A Register • 1000 Subtract operand to A Register • 01001 Input character to operand • 01010 Output character from

operand • Direct Addressing mode 000• Indirect addressing mode 001

1. 11000000 00000000000001112. 11000001 00000000000111113. 11100000 00000000000001114. 11000001 00000000000010105. 01110000 00000010000010106. 11000001 00000010000010107. 01001001 00000000000010108. 01010000 00000000010000019. 01010001 0000000000001010

Page 15: Assembly & Machine Languages

Programming in Assembly Language

Program in

assembly language

Input

Assembler

Program in

machinelanguage

Output

Page 16: Assembly & Machine Languages
Page 17: Assembly & Machine Languages

Problem: Display “Hello”

CHARO 0x0048,i; CHARO 0x0065,I;CHARO 0x006C,I; CHARO 0x006C,i; CHARO 0x006F,I; STOP.END

Page 18: Assembly & Machine Languages

Problem: Read and sum three values and print the sum

Page 19: Assembly & Machine Languages