Machine Language Instructions

Download Report

Transcript Machine Language Instructions

Alex Fok

Office Hours:
◦ Sunday 20-21
◦ 118 room, -1 floor, 37 Building
◦ Schedule by email by Saturday night


e-mail: [email protected]
ooVooID: alexfok


Course site www.cs.bgu.ac.il/~clang102
Course number: 37111671


Exam - 70%
6 homework assignments – 30%
◦ The assignments are individual
◦ Assignments submission

Weekly quiz
◦ Must receive 100 grade

The C Programming Language (second
edition - ANSI C), Brian W. Kernighan and
Dennis M. Ritchie, Prentice Hall, Inc., 1988








Introduction
Control Flow
Variables and Arrays
Functions
Recursion
Linked Lists
Files
Trees, math libraries



Execute Machine Language Commands
Machine Language – Instructions Set
Data presentation – everything is number


Everything is number
Bit (binary digit)
◦ On
◦ Off


-1
-0
Byte = 8 bits
16 bit, 32 bit, 64 bit, etc

Positive Integer
◦ 0x1
◦ 0x2
◦ 0x11
=1
=2
= 17
0
0
0
0
0
0
0
1
0
0
0
0
0
0
1
0
0
0
0
1
0
0
0
1


Store\Fetch Numbers in Memory Fields
Basic Math on Memory Fields:
◦ Add, subtract, multiple, divide



Compare Memory Fields
Bitwise operations
Execution flow control
◦ Jump to address



LOAD A in 555
ADD B to 555
STORE 555 in
1000
• 01111555
• 02311556
• 08471650



1-st Generation – Machine Language
2-nd Generation - Assembly
3-rd Generation C, C++, Pascal
◦ Java, C# - compiled to Bytecode for Virtual
Machines

4-th, 5-th Generation – Perl, JavaScript, VB,
ASP, etc

Different Problem Domains
◦
◦
◦
◦
◦
WEB
Communication-driven
User Interface
Data processing
Math Calculations
Input
Compilation Errors
Algorithm
Planning
Editing
Text File *.c
Compiling
+ Linking
Executable
File *.exe
Run Time Errors, Logical Errors
Program
Execution
Output
Begin
Read
Character
Is
<Enter>
?
NO
Print
Character
YES
End

Begin
◦ Read Character
◦ If (Character is <Enter>)
 Go to end
◦ Print Character
◦ Go to Read Character

End
I=I+1
Begin
Read
numbers A, B
I=0
if (A > B)
NO
Print I
End
YES
A=A-B

Begin
◦ Read 2 Numbers A, B
◦ I = 0;
◦ If (A > B)
 A=A–B
 I=I+1
◦ Print I
◦ Go to end

End
Input
Compilation Errors
Editing
source 1 *.c
source 2 *.c
Compiling
object 1 *.obj
object 2 *.obj
Linking
Executable
File *.exe
External
Libraries
Run Time Errors, Logical Errors
Program
Execution
Output




Editor
Compiler
Linker
Integrated Development environment
◦ MS VS, Eclipse, GNU emacs


Command Line Interpreter – OS dependent
Debugger


1972 by Dennis M. Ritchie at Bell Labs for
Unix Operating Systems
Available on wide range of platforms
◦ From embedded to supercomputers



1978 – first Kernighan & Ritchie book
1989 - American National Standards Institute
(ANSI) C – C89
International Organization for Standardization
(ISO) C - C90