Assembly language and Digital Circuit By Sahar Mosleh

Assembly language and Digital Circuit By Sahar Mosleh California State University San Marcos smosleh@csusm. edu Sahar Mosleh California State University San Marcos Page 1

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 2

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 3

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 4

• Any digit of this binary number is called bit 1000110010100000 • Each byte is 8 bits One bit One Byte = 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 Sahar Mosleh California State University San Marcos Page 5

• 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, Y add eax, 4 mov ebx, 3 imul ebx mov C, eax • Then assembler will translate this statement into binary instruction Sahar Mosleh California State University San Marcos Page 6

High-level language program (in C) void main() { C=(Y+4)*3; } C Compiler Assembly language program mov eax, Y add eax, 4 mov ebx, 3 imul ebx mov C, eax Assembler Binary machine language program Sahar Mosleh 0000100011100000100001 1000110000000000 100011110010000000100 101011001111001000000000111110000000001000 California State University San Marcos Page 7

Execution Cycle Instruction Fetch • Obtain instruction from program Instruction Decode • Determine what the instruction is Operand Fetch • Locate and obtain operand data Execute Result Store Next Instruction Sahar Mosleh • Perform the Execution • Deposit result in storage for later use • Determine successor instruction California State University San Marcos Page 8
- Slides: 8