Presentation is loading. Please wait.

Presentation is loading. Please wait.

Microprocessor and Assembly Language

Similar presentations


Presentation on theme: "Microprocessor and Assembly Language"— Presentation transcript:

1 Microprocessor and Assembly Language
Lecture-1-Intrduction Muhammad Hafeez Department of Computer Science GC University Lahore

2 Today’s Agenda Introduction to Course Background-Prerequisites
Number System Memory

3 My Introduction Office: Room-103
Course Blog: csience1234.wordpress.com

4 Course Introduction Course Title: Microprocessor and Assembly Language
Course Code: CS-2207 Recommended Books: 8086 IBM-PC Assembly Language by M.A.Mazidi Intel Microprocessors Architecture, Programming and Interfacing by Bary B. Bray Assembly Language Programming and Organization of the IBM PC By Ytha Y. Yu, Charles Marut

5 Course Introduction Reference Material: Google It Taste It

6 Course Description This is a semester long course introducing fundamentals of a computer organization. Primarily the course focus on Assembly Language for the Intel x86 series of chips which is the heart of the IBM PC. Assembly Language is a link between microprocessor and High Level Language Write, Understand and Debug a Program written in Assembly Language Control I/O Devices

7 Course Prerequisites Digital Logic Design
Minimum familiarity with IBM PC and MS-DOS

8 Processor Understanding
Bottom-Up View Logic Gates (Transistors) Flip-Flops, Registers, Multiplexers, Decoders, Adders Memory, Processor, I/O Controllers Build Complete Computer System

9 Processor Understanding
Top-Down View A Programmer’s View Study tasks that processor executes to execute a HLL program Learn the Set of very basic steps processor performs – Instruction Set Can be Learned at Machine Level – difficult to understand Assembly Language Level – Symbolic equivalent to machine level instructions

10 Processor Understanding
Top-Down View Example, for the Intel Processor: MOV AL, 5 ;Assembly language ;Machine language

11 Motivation Link between High Level Language and Assembly
Assembler is developed for particular processor Reasons to Learns Assembly: In-depth understanding of assembly is required to understand device drivers Compiler Development and Code Optimization Helpful in working with Operating System and embedded systems A conceptual bridge between Abstraction of real world in (compiler) and microprocessor

12 Course Work and Grading
Quiz-05% Assignment-05% Term Project-10% Mid Term-20% Final Term-60% This is tentative distribution and liable to change under certain circumstances.

13 Attendance & Assignment Submission
80% attendance mandatory to qualify for final examination Assignments should be submitted on due date and time, no further extension shall be given. Assignments should be submitted in hard-copy on A4 paper with proper binding and titled in the format StudentFirstName-RollNo-CourseCode-Section-AssignmentNo e.g. kaleem-001BSCS14-CS2207-A-01

14 Number System Data Represented in Computer is in the form of digital signals (on-off) Best represented by Binary Number System (1-0) One binary digit is not enough to represent real world information Need at least 08 bits called a ‘Byte’; that is smallest addressable unit in modern computers For x86 following units are used 01 Byte = 08 Bits 01 Word = 02 Bytes 01 Double Word = 02 Words

15 Number System The contents of 1 bytes stored in computer memory needs ‘Interpretation’ For Example, the memory content , can be represented as Number 65 or Letter ‘A’ It is upto the programmer to provide interpretation

16 Number System A written number is only meaningful when we define its Base Hexadecimal 25 is written as 25h Binary 1010 is written as 1010b Decimal 1010 is written as 1010 or 1010d Significance of Bases to demonstrate quantity Larger base represent large quantities in fewer digits

17 Binary Number System Digits are 1 and 0 MSB – Most Significant Bit
1 = true 0 = false MSB – Most Significant Bit LSB – Least Significant Bit Bit Numbering:

18 Binary Number System Each digit (bit) is either 1 or 0
Each bit represents a power of 2: Every binary number is a sum of powers of 2

19 Converting Binary To Decimal
Weighted positional notation shows how to calculate the decimal value of each binary bit: Decimal Number = (Dn-1  2n-1) + (Dn-2  2n-2) (D1  21) + (D0  20) D = Binary Digit (1010)2 =1x23+0x22+1x21+0x20 = = (10)10

20 Converting Unsigned Decimal To Binary
Repeatedly divide the decimal integer by 2. Each remainder is a binary digit in the translated value:

21 Binary Arithmetic Binary Addition Binary Subtraction
Binary Multiplication Binary Division

22 Unsigned Integer Number Storage Size In Memory
Standard Sizes What is the Largest Number stored in 20 Bits

23 Hexadecimal Number System
Binary, Decimal and Hexadecimal Numbers

24 Hexadecimal Number System
Binary, Decimal and Hexadecimal Numbers

25 Converting Hexadecimal to Binary
Each Hexadecimal digit is equivalent to 4 Binary Digits Prove the same with repeated division method by 2

26 Converting Hexadecimal to Decimal
Multiply each digit by its corresponding power of 16: Decimal = (Dn-1  16n-1)+…+(D3  163) + (D2  162) + (D1  161) + (D0  160) Hex 1234 equals (1  163) + (2  162) + (3  161) + (4  160)= decimal 4,660. Hex 3BA4 equals (3  163) + (11 * 162) + (10  161) + (4  160)= decimal 15,268. Another way

27 Converting Hexadecimal values upto 8 digits

28 Converting Decimal to Hexadecimal
decimal 422 = 1A6 hexadecimal

29 Hexadecimal Addition Starting from LSB if sum of each two digits is greater than or equal to 16, divide it with 16, the quotient become carry digit and remainder become sum digit Carry will be 1 Important skill to do arithmetic in Hexadecimal for Assembly Language A B 78 6D 80 B5 21 / 16 = 1, rem 5

30 Hexadecimal Addition

31 Hexadecimal Subtraction
When a Borrow is required from the digit on left hand side, add sixteen (16) to the digit on right hand side Borrow will be 16 The address of var1 is The address of the next variable after var1 is A. How many bytes are used by var1? C6 75 A2 47 24 2E -1 = 21

32 Two Representations for Integers
The unsigned representation: in that case all the bits are used to represent a magnitude Can be positive number or Zero Signed Representation For What purpose signed number could be used? Can you recognize a number for even or odd by looking at bit pattern?

33 Signed Representations for Integers
The Singed Representation forms: Sign Magnitude Form Uses most significant bit of the word to represent the sign. 0 - Positive 1 - Negative. Rest of the number is encoded in magnitude part 37 = -37 = 6712 = -6712 = Can represent numbers from -32,767 to 32,767. But, two representations for zero: 0 = -0 = Arithmetic can be cumbersome.

34 Signed Representations for Integers
Sign Magnitude Form Uses most significant bit of the word to represent the sign. 0 - Positive 1 - Negative. Rest of the number is encoded in magnitude part 37 = -37 = 6712 = -6712 = Can represent numbers from -32,767 to 32,767. But, two representations for zero: 0 = -0 = Arithmetic can be cumbersome.

35 Signed Representations for Integers
1’s Compliment Form Negative number is stored as bit-wise complement of corresponding positive number. Leftmost bit of positive number is 0. That of negative number is 1. 196 = -196 = Can represent numbers from -32,767 to 32,767. Arithmetic is easier than sign-magnitude. But, still have two representations for zero: 0 = -0 = Add 5 and -5 using 1’s Complement and see the result?

36 Signed Representations for Integers
2’s Compliment Form Modern Method Positive number represented in same way as other two methods Negative number obtained by taking 1's Complement of positive number and adding 1. 6713 = 1's Comp = 2's Comp = Word integer can represent numbers from -32,768 to 32,767. -215  Byte integer can represent numbers from -128 to 127. -27  One version of zero: Find 2’s complement of 2’s complement of 6

37 Signed Representations for Integers
Represent -97d in 2’s Complement Form using 8 bits and 16 bits? Sol: Represent 97 in Hex Convert hex representation into binary Take 2’s complement of binary Convert into Hex … this how it is represented 5ABAH – 2A91H Use 2’s complement to solve it

38 Range of Signed Integers
MSB is reserved for Sign; this factor limits the range For Signed Representation; what largest value can be stored in 20 bits

39 Signed and Unsigned in Computer Memory to Decimal
To use a number in computer memory; we need to provide it either signed or unsigned interpretation How can we do that? Unsigned: Just convert binary to decimal, better to convert to hex and then to decimal Signed: If msb=0, convert like unsigned numbers, if msb=1, call the N number as –N, take 2’s complement and then convert to decimal, place – sign in front can be interpreted as 255 (unsigned) Or -1 (minus one) as signed Its upto the programmer to provide memory contents suitable interpretation for program

40 Signed and Unsigned in Computer Memory to Decimal

41 Signed and Unsigned in Computer Memory to Decimal

42 Signed and Unsigned in Computer Memory to Decimal
Any Observation in previous two slides? Computer memory contents are FE0CH, give it signed and unsigned representation?

43 Signed and Unsigned in Computer Memory to Decimal
Another Observation: From 0000H-7FFFH  Signed Number = Unsigned Numbers From 8000H-FFFFHSigned Number = Unsigned Number-65536 Can you Observe the same for Byte? Give FE0CH a singed and unsigned representation through this method?

44 Minimum and Maximum Values for Signed Numbers
MSB used to represent sign, fever bits left for magnitude representation For Example, a signed byte have Smallest Positive (0 in decimal) Largest Positive (127 in decimal) Smallest Negative (-128) Largest Negative (-1) First low byte is stored memory then high byte [Little Endian]

45 Character Representation Through Memory Contents
Each Character is represented with 7 bit Code called ASCII Character ASCII Code from 00H to 07FH Codes from 20H to 7EH are printable, rest of them are control code An extended character set is obtained by setting the most significant bit (MSB) to 1 (codes 80h to FFh) so that each character is stored in 1 byte

46 ASCII Character Set CR = Carriage Return
LF = Line Feed (Cursor Moved one line below) SPC = Blank Space

47 Text Files Using ASCII Character Set
Text Files contain printable and non-printable ASCII Characters Different OS represent non-printable characters (control characters) i.e. moving to cursor to start of line through different ways, Windows: <CR>+<LF> UNIX: <LF> MAC: <CR> Origin of problem when we move text files from one OS to other

48 Character Storage ASCII (0-127) Extended ASCII (0-255)
Uni-Code (0-65,535)

49 Questions ????????????????????????


Download ppt "Microprocessor and Assembly Language"

Similar presentations


Ads by Google