25
ACOE251 1 ACOE251/AEEC335 -Assembly Language for the 80X86/Pentium Intel Microprocessors Lecturer: Dr. Konstantinos Tatas

Useful Information

  • Upload
    mairi

  • View
    62

  • Download
    0

Embed Size (px)

DESCRIPTION

ACOE251/AEEC335 -Assembly Language for the 80X86/Pentium Intel Microprocessors Lecturer: Dr. Konstantinos Tatas. Useful Information. Instructor: Lecturer K. Tatas FRC building room 107 (subject to change) Office hours: TBA E-mail: [email protected] http://staff.fit.ac.cy/com.tk - PowerPoint PPT Presentation

Citation preview

Page 1: Useful Information

ACOE251 1

ACOE251/AEEC335 -Assembly Language for the 80X86/Pentium

Intel Microprocessors

Lecturer: Dr. Konstantinos Tatas

Page 2: Useful Information

ACOE251 2

Useful Information• Instructor: Lecturer K. Tatas

– FRC building room 107 (subject to change)– Office hours: TBA– E-mail: [email protected]– http://staff.fit.ac.cy/com.tk

• Prerequisites: ACOE161, ACSC182 (CoE)• Prerequisites: AEEE203, AEEE200 (EE)• Lectures/week: 3• ECTS: 5

Page 3: Useful Information

ACOE251 3

COURSE OBJECTIVES• introduce students to assembly language

programming. • By the end of the course students should be able to

– write, test and debug programs in x86 assembly language using assembler, debug and emulation software

– relate x86 assembly language with other processor assembly languages and high level languages.

Page 4: Useful Information

ACOE251 4

Course Outline• Introduction to Assembly Language: Computer organization –

Number and character representation - IBM PC programming model

• Directives - The MOV instruction – addressing modes• Arithmetic instructions• Logic, shift and rotate instructions• Interrupts, DOS and BIOS• The processor status and flags register• Flow control instructions• The stack - introduction to procedures• Software constructs• Arrays - addressing modes revisited

Page 5: Useful Information

ACOE251 5

Course Evaluation

• Exam: 60%• Coursework: 40%

– Test: 20%– Assignment 20%

Page 6: Useful Information

ACOE251 6

Course pre-requisites

Digital Logic, Computer Programming• Gates, flip-flops, truth tables, timing diagrams, etc.

– Computer number systems• decimal, hexadecimal, binary, octal• conversions, logical operations, computer arithmetic

– Computer data formats• ASCII, BCD

Page 7: Useful Information

ACOE251 7

ASSEMBLY LANGUAGE

• One-to-one relationship with machine language unlike high-level languages– Many lines of code even for simple programmes

• Requires at least some knowledge of the microprocessor architecture, memory structure and operating system

• Code not portable (source files will not run on a different architecture microprocessor)

Page 8: Useful Information

ACOE251 8

Why Learn/Use Assembly Language

• Efficient use of the main memory– Less memory required– Programs execute faster

• Avoid redundant instructions inserted by compilers.• Direct access to the hardware of the computer,

– Usually not supported by compilers.• Access to the microprocessor’s internal control registers. • For some processors such as DSP and micro-controllers

there is no (or limited) support by high level languages• Embedded systems have tight constraints on performance,

memory size and power consumption

Page 9: Useful Information

ACOE251 9

Revision on Basic Computer Architecture

CONTROL BUS

DATA BUS

ADDRESS BUS

MAIN MEMORY

ROM RAM I/PPORTS

O/PPORTS

PERIPHERALDEVICES

I/O INTERFACEUNIT

REGISTERS

CONTROLUNIT

ALU

CPU

Page 10: Useful Information

ACOE251 10

Revision on Numbering Systems

• Decimal - Binary - Hex conversion• Signed Numbers

– Signed Magnitude – One’s Complement –Two’s Complement– Hex signed numbers: 15’s and 16’s Complement

• Arithmetic Operations– Binary: Addition – Subtraction – Multiplication – Division– Hex: Addition – Subtraction – Multiplication – Division

• Logic Operations on bit vectors– AND, OR, XOR, NOT

• Ranges:– Unsigned byte: 0 to 255 Signed byte: -128 to +127– Unsigned word: 0 to 65,536 Signed word: -32,768 to +32,767– Unsigned doubleword: 0 to 4,294,967,295– Unsigned quadword: 0 to 18,446,744,073,709,551,615

Page 11: Useful Information

ACOE251 11

Conversion between number systems

• A. Binary to Decimal• B. Decimal to Binary• C. Hexadecimal to Decimal• D. Decimal to Hexadecimal• E. Binary to Hex• F. Hex to Binary

Page 12: Useful Information

ACOE251 12

Number Conversion

• Decimal to Binary25 to binary: Quotient | Remainder

25 / 2 12 1 LSB (Least Significant Bit)12 / 2 6 06 / 2 3 03/ 2 1 11/ 2 0 1 MSB (Most Significant Bit)

Page 13: Useful Information

ACOE251 13

Number Conversion II

• Binary to Decimal2

0

1

2

3

4

5

110101 Decimal

1 2 1 1 1

0 2 0 2 0

1 2 1 4 4

0 2 0 8 0

1 2 1 16 16

1 2 1 32 3253

Page 14: Useful Information

ACOE251 14

Hexadecimal System

• Hexadecimal System – Base 16• Used for representing binary numbers• Example: 100010010110 in hex is 896H• The hex system has 16 digits: 0 – 9, A, B, C, D, E and F.

Page 15: Useful Information

ACOE251 15

Decimal, Binary and Hex

Decimal Binary HEX0 0000 01 0001 12 0010 23 0011 34 0100 45 0101 56 0110 67 0111 7

Decimal Binary HEX8 1000 89 1001 9

10 1010 A11 1011 B12 1100 C13 1101 D14 1110 E15 1111 F

Page 16: Useful Information

ACOE251 16

Number Conversion III

• Binary to Hex:– Start from the right and group 4 bits at a time.– Replace each 4-bit binary number with its hex equivalent.

• Example: 100111110101 to hex– Group bits: 1001 1111 0101– Replace hex: 9 F 5

• Therefore: 100111110101 = 9F5 in hex.

Page 17: Useful Information

ACOE251 17

Number Conversion IV

• Hex to Binary:– Each hex digit is replaced with its 4-bit equivalent.– Leading zeros are dropped.

• Example: 29B to binary– 2 9 B– 0010 1001 1011

• 29B = 100011011 (dropping leading zeroes)

Page 18: Useful Information

ACOE251 18

Page 19: Useful Information

ACOE251 19

Representing Positive and Negative Numbers in Hex• Positive numbers - straight conversion to hex• Negative numbers are stored in two's complement form• To get the two's complement form of a number in hex:

– First: Represent the number as if it were positive– Second: Subtract it from FF(byte) or FFFF(word)– Third: Add 1

• Examples:-97 as a word is FFFF

-0061 FF9E + 1 FF9F = -97

-97 as a byte is FF -61 9E + 1 9F = - 97

Page 20: Useful Information

ACOE251 20

Interpreting Signed and Unsigned Bytes and Words in Memory as Decimal Numbers

• Unsigned– Straight translation from binary or hex to decimal

• Signed numbers– First determine the sign of the number by looking at its MSB. If its 0, its

positive and you can do a straight translation from binary or hex to decimal

– If its MSB is a 1, its negative and you must Re-complement it!– Since everything you see in memory will be expressed in hexadecimal,

you won't "see" the MSB. Instead, you will see a hex digit. Therefore, if the first hex digit of a signed word or a byte is 0 to 7, the number is positive. If the first hex digit of a signed word or a byte is 8 to F, the number is negative. Why?

Page 21: Useful Information

ACOE251 21

Homework - Number System ReviewConversion:1. Convert from decimal to binary

a. 43 b. 1672. Convert from binary to decimal

a. 1101100b b. 1100011b3. Convert from decimal to hexadecimal

a. 6242 b. 123214. Convert from hexadecimal to decimal

a. 4BFh b. A2F7h5. Convert from binary to hexadecimal

a. 110010011110b b. 100001011b6. Convert from hexadecimal to binary

a. FADh b. 265Ch c. BE98h

Page 22: Useful Information

ACOE251 22

Character Representation• Code chosen for IBM PC is the ASCII code

– 7 bit code – 27 or 128 possible values – stored in a byte

• 95 ASCII codes are printable (32 to 126)• 0 to 31 and 127 are used for control purposes• IBM PC uses an extended character set using an 8 bit code thus

in can represent 28 or 256 possible values• ASCII keyboard

– Each key pressed is stored in ASCII code– Today on IBM PC, each key is assigned a unique number called a scan

code to handle the many control and function keys in addition to the ASCII character keys

Page 23: Useful Information

ACOE251 23

ASCII Codes - Printable Characters

20 Space21 !22 ”23 #24 $25 %26 &27 ’28 (29 )2A *2B +2C ,2D -2E .2F /

30 031 132 233 334 435 536 637 738 839 93A :3B ;3C <3D =3E >3F ?

40 @41 A42 B43 C44 D45 E46 F47 G48 H49 I4A J4B K4C L4D M4E N4F O

60 `61 a62 b63 c64 d65 e66 f67 g68 h69 i6A j6B k6C l6D m6E n6F o

70 p 71 q72 r73 s74 t75 u76 v77 w78 x79 y7A z7B {7C |7D }7E ~ 7F Del

50 P51 Q52 R53 S54 T55 U56 V57 W58 X59 Y5A Z5B [5C \5D ]5E ^5F _

Page 24: Useful Information

ACOE251 24

Examples• How many bytes are required to represent the

following data:– Unsigned number 92d– Unsigned number 313d– Signed number +212d– Unsigned number 100100101b– 72H– 2A4H– HAVE A NICE DAY

• Represent the above data in hexadecimal form

Page 25: Useful Information

ACOE251 25

Homework: Data Representations Set 1ProblemsNote: Express all answers to problems 1-9 in HEXADECIMAL 1. How do you represent 221 as an unsigned byte? ___________ 2. How do you represent 110 as a signed byte? ___________ 3. How do you represent -92 as a signed byte? ___________ 4. How do you represent 62385 as an unsigned word? _______ 5. How do you represent 1600 as a signed word? ___________ 6. How do you represent -160 as a signed word? _________ 7. How do you represent +7523 as a character string?_________ 8. How do you represent -612 as a character string? _______ 9. How do you represent OOPS! as a character string? _______