System Programming Lec 01

25
System Programming Week 1 By Ayesha Durrani

description

the description about computer programming from Peshawar university.

Transcript of System Programming Lec 01

Page 1: System Programming Lec 01

System Programming

Week 1By Ayesha Durrani

Page 2: System Programming Lec 01

Prerequisites for Course

• Computer Architecture• Deep understanding of Assembly language• Basic Number Systems– Binary, Hexadecimal, Decimal and Octal

Page 3: System Programming Lec 01

System programming

• System programming (or systems programming) is the activity of Computer Programming System Software.

• Application programming: aims to produce software which provides services to the user e.g. MS office

• System Programming: aims to produce software which provides services to the computer hardware

Page 4: System Programming Lec 01

Application Software Vs System Software (1)

• Application software: helps users solve particular problems

• In most cases, application software resides on the computer’s hard disk

• Application software includes packaged software such as word processing, spreadsheet, database, and programming languages such as BASIC, COBOL, C, Visual Basic etc.

Page 5: System Programming Lec 01

Application Software Vs System Software (2)

• Systems software– Controls operations of computer hardware– E.g. Operating systems– Operating system (OS): set of programs that

controls the computer hardware and acts as an interface with application programs

– interface between the application program and the hardware.

Page 6: System Programming Lec 01

Data Representation (1)

• Each numbering format, or system, has a base, or maximum number of symbols that can be

assigned to a single digit.

Page 7: System Programming Lec 01

Binary Integers

Binary Integers Binary numbers are base 2 numbers, in which each

binary digit (called a bit) is either 0 or 1 Bits are numbered sequentially starting at zero on

the right side and increasing toward the left. most significant bit (MSB), vs least significant bit

(LSB).

Page 8: System Programming Lec 01

Translating Binary Integers to Decimal

• For example, binary 00001001 is equal to 9. We calculate this value by leaving out terms equal to zero:

• The same calculation is shown by the following figure:

Page 9: System Programming Lec 01

Translating Decimal Integers to Binary

• repeatedly divide decimal integer by 2• Save each remainder as a binary digit.• translate decimal 37 to binary• The remainder digits, starting from the top

row, are the binary digits• Example next slide

Page 10: System Programming Lec 01

Example

• binary of 37 is 100101== 00100101 ?

Page 11: System Programming Lec 01

Integer Storage Sizes• basic storage unit for all data in an x86

computer is a byte.• Other storage sizes are:• Word (2 bytes), • doubleword (4 bytes),• and quadword (8 bytes).

Page 12: System Programming Lec 01

Large Measurements of Storage

• One kilobyte=210, or 1024 bytes.• One megabyte (1 MByte)=220 bytes.• One gigabyte (1 Gbyte) = 230bytes.• One terabyte (1 Tbyte) = 240 bytes• One petabyte = 250 bytes

• One exabyte=260 bytes• One zettabyte =270 bytes• One yottabyte = 280 bytes

Page 13: System Programming Lec 01

Hexadecimal Integers

• Why Hexadecimal Integers??• Large binary numbers are difficult to read• hexadecimal digits offer a convenient way to represent binary data.• Each digit in a hexadecimal integer represents

four binary bits called nibble• Base is 16

Page 14: System Programming Lec 01

Binary, Decimal, and Hexadecimal Equivalents

Page 15: System Programming Lec 01

Practice Exercise

• Convert the following binary to Hexadecimal• 01101010011110010100??

Page 16: System Programming Lec 01

Converting Hexadecimal to Decimal

• hexadecimal 3BA4 is equal to:• (3 x 163) + (11 x 162) + (10 x 161) (4 x 160), • or decimal 15,268.

Page 17: System Programming Lec 01

Converting Decimal to Hexadecimal

• To convert a decimal integer to hexadecimal, repeatedly divide the decimal value by 16

• retain each remainder as a hexadecimal digit.• Example 422 can be converted as:

• Result: 1A616

Page 18: System Programming Lec 01

Practice Exercise

Q1: What is the decimal representation of each of the following unsigned binary integers?

• 11111000• 11001010• 11110000Q2 What is the sum of each pair of binary integers?• 00001111 + 00000010• 11010101 + 01101011• 00001111 + 00001111

Page 19: System Programming Lec 01

Practice Exercise

Q3: What is the binary representation of the following hexadecimal numbers?

• E5B6AED7• B697C7A1• 234B6D92Q4: What is the unsigned decimal representation of each

hexadecimal integer?• 62• 1C9• 6A5B

Page 20: System Programming Lec 01

Boolean Operations

• A boolean expression involves a boolean operator and one or more operands.

• Each boolean expression implies a value of true or false.

• The set of operators includes the following: NOT: notated as ¬ or ~ AND: notated as ∧ OR: notated as ∨

Page 21: System Programming Lec 01

NOT operator

• The NOT operator is unary, and the other operators are binary.

• The NOT operation reverses a boolean value• written in mathematical notation as ¬ X,• The following truth table shows all the

possible outcomes:

Page 22: System Programming Lec 01

AND operation

• AND: The Boolean AND operation requires two operands:

• expressed using the notation X Y∧

Page 23: System Programming Lec 01

OR operation

• OR The Boolean OR operation requires two operands:

• expressed using the notation X Y.∨

Page 24: System Programming Lec 01

Practice Exercise

Q1: Create a truth table for the boolean function described by ¬ (A ∨ Β).

Q2: Create a truth table for the boolean function described by ( ¬ A ∧ ¬ B).

Page 25: System Programming Lec 01

• End lecture 01