Top Banner
By Tien Phung CS 147 Dr. Sin-Min Lee
23

By Tien Phung CS 147 Dr. Sin-Min Lee. High-level Languages Assembly Languages Machine Languages.

Dec 20, 2015

Download

Documents

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: By Tien Phung CS 147 Dr. Sin-Min Lee. High-level Languages Assembly Languages Machine Languages.

By Tien PhungCS 147Dr. Sin-Min Lee

Page 2: By Tien Phung CS 147 Dr. Sin-Min Lee. High-level Languages Assembly Languages Machine Languages.

• High-level Languages

• Assembly Languages

• Machine Languages

Page 3: By Tien Phung CS 147 Dr. Sin-Min Lee. High-level Languages Assembly Languages Machine Languages.

• Highest level of abstraction• Platform-independent: same program code can be converted and run on computer with different microprocessors and operating system without modification.• C ++, Java, Fortran

Page 4: By Tien Phung CS 147 Dr. Sin-Min Lee. High-level Languages Assembly Languages Machine Languages.

• Lower level of abstraction.• Not platform-independent.• Backward compatible.• Can directly manipulate the data stored in a microprocessor’s interval components.

Page 5: By Tien Phung CS 147 Dr. Sin-Min Lee. High-level Languages Assembly Languages Machine Languages.

•Contain binary values

•Instruction is read and executed directly by microprocessor.

•Platform-specific: each microprocessor has its own machine language.

Page 6: By Tien Phung CS 147 Dr. Sin-Min Lee. High-level Languages Assembly Languages Machine Languages.

•High-level Languages

•Assembly Languages

Compiled

Assembled

Page 7: By Tien Phung CS 147 Dr. Sin-Min Lee. High-level Languages Assembly Languages Machine Languages.

Compilation process for HLL

High-level languageprogram (C++, Fortran, etc.)

Compiler for PentiumWindows PC

Compiler for G4Power Mac Computer

Compiler for SPARC UNIX workstation

Other Pentiumobject files

Pentiumobject code

Other G4object files

G4object code

OtherSPARCobject files

SPARCobject code

Pentium linker G4 linker SPARC linker

Pentiumexecutable file

WindowsPentium PC

G4executable file

G4Power Mac

SPARCExecutable file

SPARCUNIX workstation

Page 8: By Tien Phung CS 147 Dr. Sin-Min Lee. High-level Languages Assembly Languages Machine Languages.

Process for assembly language programs.

Assembly LanguageProgram for processor X

Assembler for processor X

Processor Xobject code

Process X linker

Processor Xexecutable file

Computer with processor X

Other processor X object file

Page 9: By Tien Phung CS 147 Dr. Sin-Min Lee. High-level Languages Assembly Languages Machine Languages.

• Data Transfer Instructions

• Data Operation Instructions

• Program Control Instructions

Page 10: By Tien Phung CS 147 Dr. Sin-Min Lee. High-level Languages Assembly Languages Machine Languages.

• Do not modify data, only copy value to its destination.

• Main operation: move data from one place to another * Load data from memory into microprocessor. * Store data from microprocessor into memory. * Move data within the microprocessor. * Input data to the microprocessor. * Output data from the microprocessor.

Page 11: By Tien Phung CS 147 Dr. Sin-Min Lee. High-level Languages Assembly Languages Machine Languages.

• Modify their data value• Arithmetic instructions: add, subtract, multiply and divide.• Logic instruction: AND, OR, XOR, or complement a single value.• Shift instruction: shift the bits of data value to either left or right.

Page 12: By Tien Phung CS 147 Dr. Sin-Min Lee. High-level Languages Assembly Languages Machine Languages.

• Use jump or branch to go to another part of the program. (jr $ra)

• Conditional calls and returns bne $t0, $t1, endloop

• Software and hardware interrupts• Exception or traps • Half-instruction: stop executing instruction

Page 13: By Tien Phung CS 147 Dr. Sin-Min Lee. High-level Languages Assembly Languages Machine Languages.

• Integer < Unsigned 0 to 2n - 1Signed -2 n-1 to 2 n-1 - 1

• Floating Point

• Boolean < True = non-zeroFalse = zero

• Characters: * Stored as binary values * Encoded using ASCII, EBCDIC, UNICODE.

Page 14: By Tien Phung CS 147 Dr. Sin-Min Lee. High-level Languages Assembly Languages Machine Languages.

• Direct Mode

• Indirect Mode

• Immediate Mode

• Implicit Mode

Page 15: By Tien Phung CS 147 Dr. Sin-Min Lee. High-level Languages Assembly Languages Machine Languages.

a) Direct Mode 0: LDAC 5 instruction gets data from location 5 5: 10 stores value in CPU

b) Indirect Mode 0: LADC @ 5 instruction gets address from location 5 5: 10 then gets data from location 10 10: 20 stores value in CPU

Page 16: By Tien Phung CS 147 Dr. Sin-Min Lee. High-level Languages Assembly Languages Machine Languages.

c) Immediate Mode 0: LDAC #5 stores value from instruction in CPU

d) Implicit Mode 0: LDAC instruction gets value from stack stack store value in CPU

Page 17: By Tien Phung CS 147 Dr. Sin-Min Lee. High-level Languages Assembly Languages Machine Languages.

• Instruction code: assembly language instruction converted to machine code as binary value (0 and 1)

• Opcode needs 4 bits• Operand needs 2 bits

• A microprocessor may be designed to work with instructions that specify 3, 2, 1 or 0 operands.

Page 18: By Tien Phung CS 147 Dr. Sin-Min Lee. High-level Languages Assembly Languages Machine Languages.

2 bits 2 bits 2 bits4 bits

2 bits 2 bits4 bits

2 bits

4 bits

4 bits

opcode operand #1

opcode

opcode

opcode

operand #2

operand #3

operand #1

operand #2

operand

ADD A,B,C (A=B+C)1010 00 01 10

MOVE A,B (A=B) 1000 00 01ADD A,C (A=A+C) 1010 00 10

LOAD B (Acc=B) 0000 01ADD C (Acc=Acc+C) 1010 10STORE A (A=Acc) 0001 00

PUSH B (Stack=B) 0101PUSH C (Stack=C,B) 0110ADD (Stack=B+C) 1010POP A (A=Stack) 1100

Page 19: By Tien Phung CS 147 Dr. Sin-Min Lee. High-level Languages Assembly Languages Machine Languages.

• Need more instructions to accomplish the same task.• Hardware implement the microprocessor become less complex as the number of operand decreases.• Instructions code use fewer bits.• Microprocessor execute instruction more quickly.

Page 20: By Tien Phung CS 147 Dr. Sin-Min Lee. High-level Languages Assembly Languages Machine Languages.

• Completeness: Does the instructions set have all of the instruction a program needs to perform its required task?

• Orthogonality: No overlap or perform the same function.

• Good Instruction <Minimize overlap between instructions

Provide programmersnecessary functions with less instructions.

Page 21: By Tien Phung CS 147 Dr. Sin-Min Lee. High-level Languages Assembly Languages Machine Languages.

• Large effect on performance of CPU • CPU retrieve data from its registers more quickly than from memory.

• Speed up program execution.

Page 22: By Tien Phung CS 147 Dr. Sin-Min Lee. High-level Languages Assembly Languages Machine Languages.

Concerning Question About ISA Design

• Does this processor have to be backward compatible with other microprocessor?

• What types and size of data will the microprocessor deal with?

• Are interrupts needed?

• Are conditional instruction needed? Flag: zero, carry, sign

Page 23: By Tien Phung CS 147 Dr. Sin-Min Lee. High-level Languages Assembly Languages Machine Languages.