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 high level language compiler translate statement from their language to assembly. • How high level language implement arithmetic expressions, loops, and logical structures at the machine level • 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 • These days we use natural language to communicate with computers. This language is called High Level Programming language. 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

• Famous programming high level languages are: Pascal, C, Ada, Basic, Cobol, Fortran, and C++ (LISP and PROLOG for Artificial Intelligent) • Different languages have their strengths and weaknesses. • some are good for math • some for engineering • some for business • some make calculations easy • some make modifications easy and • some are more readable and easier to learn than the others. • High level languages have evolved in terms of readability, error checking, expressibility, efficiency, modularity, and portability. Sahar Mosleh California State University San Marcos Page 8

• In brief, we can categorize the programs as follows: • System Software: • They provide services that are commonly useful like Compilers, Operating Systems and Assembler • Operating System supervise running other programs and manage and organize the resources of the system so that the programs run more efficiently • Application Software: • This is software that is used for computer users. Examples include: Text Editor, some of Microsoft products, … Sahar Mosleh California State University San Marcos Page 9

What is inside the Computer? ? Sahar Mosleh California State University San Marcos Page 10

Underlying Hardware • If we open the box containing the computer we see a thin board called mother board. This board is composed of three pieces • Input/Output (I/O) Devices: • Keyboard, mouse (input devices) • Screen, printer (output devices) • Memory: • It is where the programs are kept when they are running. It also contains data required by the running program • Processor: • The active part of the board that follows instructions like adding numbers, testing numbers, etc… Sahar Mosleh California State University San Marcos Page 11

Components of Processor • Processors contain two main components: • Data. Path unit: • It performs the arithmetic operations • Control Unit: • It tells the Data. Path, memory, I/O devices what to do according to the wishes of the instruction of the program • The processor • gets instruction and data from memory, • input writes data to memory and output reads data from memory, • control sends the signals that determine the operations of the Data. Path, memory, input and output Sahar Mosleh California State University San Marcos Page 12

Three Classic Components of the Computer Processor/CPU Input Control Memory Data. Path Sahar Mosleh California State University San Marcos Output Page 13

• Processor (Intel Pentium Pro) is located at the right-upper edge of the board • The memory is contained in two small of board that are perpendicular to the mother board in the middle. Parallel/ serial Audio/ MIDI Four ISA Card Slots Four PCI Card Slots Four SIMM Slots Two IDE Connectors Sahar Mosleh Processor • The rest of board are connectors for external I/O devices. • These connectors are audio/MIDI and parallel/Serial at the top edge, four PCI card slots below them, four ISA card slots to the left and two IDE connectors on the lower right • These cards connect the board to printer, speakers, local area networks, disks, so on. California State University San Marcos Page 14

Memory Types Volatile Memory Types: • DRAM: • Dynamic Random Access Memory (Main Memory) • holds programs, data, and computed results • you can read from and write to • It is volatile (power failure can cause the loss of data) • Slower, cheaper, larger memory, further from processor. • Cache: • Cache memory consists of small, fast memory that acts as a buffer for DRAM • Fast (expensive , small) memory close to processor Sahar Mosleh California State University San Marcos Page 15

Non-volatile Memory Types: • ROM: • Read Only Memory: • “how do boot” part of the operating system is in ROM; tells the processor to read from the disk into RAM) • Capacity: usually much smaller than RAM • Disks: • Can read and write but slow in spinning (10, 000 to 10, 000 times slower than RAM) • capacity: usually much bigger than RAM (e. g. gigabytes) • the only moving part of the computer • some save backup copies every night • Magnetic tapes (sequential access): • can be used for long term backup storage. Sahar Mosleh California State University San Marcos Page 16

Memory Size: • • How do we measure the size of the Memory? How many bytes can be stored on the hard disk? Your diskettes? How do we say how big your files are? • Numbers and characters are stored in terms of 0's and 1's. • (i. e. if you were to look directly inside the memory in the raw form, all you see are 0's and 1's) • • • Bit = 0 or 1 (Binary System) Byte = 8 bits = can represent a character KB = one kilo bytes = 210 bytes = 1024 bytes MB = one mega bytes = 1024 KB GB = one giga byte = 1 K mega byte Sahar Mosleh California State University San Marcos Page 17

Processor and Caches Processor Datapath Registers Internal Caches Control External Caches To main Memory Sahar Mosleh California State University San Marcos Page 18

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 19
- Slides: 19