Upload
ira-griffin
View
213
Download
0
Embed Size (px)
Citation preview
Sahar Mosleh California State University San Marcos Page 1
Assembly language and
Digital Circuit
By
Sahar Mosleh
California State University San [email protected]
Sahar Mosleh California State University San Marcos Page 2
The Goal
• In this course, we are learning
• Some basic principals of computer architecture applied to Intel IA-32
• Basic Boolean logic and how it applies to programming and computer hardware.
• Memory management of IA-32 using real mode, protected mode and virtual mode.
• How a compiler translate High level language statement to assembly.
• How implement arithmetic expressions, loops, and logical structures with assembly.
• You may also learn about data representation, including signed and unsigned integers, real numbers, and character.
Sahar Mosleh California State University San Marcos Page 3
Programming Languages Overview
• A program is written in a high level programming language - not English or other natural languages.
• Different levels of languages are:
• Machine Language: Operates data in terms of 0's and 1's.• Lowest level commands understood by a particular
machine.
• Assembly Language: it consist of operation names and data address. It works as middle ware between machine language and high level language.
• High-level language: higher level readable statements that can be translated into various Machine Languages.
• If a program written in a high level language, and can be understood by various compilers without modification, then it is PORTABLE.
• An organization called ANSI contributes to standardizing languages and thus making them more portable.
Sahar Mosleh California State University San Marcos Page 4
Below Your Program
• To speak to your machine, you need to send electronic signals.
• The easiest signal is on/off
• The two symbols for these two signals are 0 and 1.
• We commonly think of machine language as binary numbers which are base 2.
• Example of binary number
1000110010100000
• The above binary code tells the computer to add two numbers
Sahar Mosleh California State University San Marcos Page 5
• Any digit of this binary number is called bit
1000110010100000• Each byte is 8 bits
• Any collection of 0 and 1 which can make a binary number is a command or instruction that your computer understands
• The system program that translates a command such as
add eax, 10
To machine language ( binary code )
1000110010100000
Is called an Assembler
One bit One Byte = 8 bits
Sahar Mosleh California State University San Marcos Page 6
• An example of a high level language in C/C++ for adding two numbers is:
void main(){
C = ( Y + 4 ) * 3 ;}
• Another system program called Compiler will compile these high level language to assembly language statement which is
mov eax, Yadd eax, 4mov ebx, 3imul ebxmov C, eax
• Then assembler will translate this statement into binary instruction
Sahar Mosleh California State University San Marcos Page 7
void main(){
C = ( Y + 4 ) * 3 ;}
mov eax, Yadd eax, 4mov ebx, 3imul ebxmov C, eax
0000000010001110000110000010000110001100011000100000000000000000100011001111001000000000000001001010110011110010000000000000000000000011111000000000000000001000
C Compiler
Assembler
High-level language program (in C)
Assembly language program
Binary machine language program
Sahar Mosleh California State University San Marcos Page 8
Execution Cycle
• Obtain instruction from program
• Determine what the instruction is
• Deposit result in storage for later use
• Perform the Execution
• Locate and obtain operand data
• Determine successor instruction
Instruction Fetch
Instruction Decode
Operand Fetch
Execute
Result Store
Next Instruction