You are on page 1of 6

COMSATS-Lancaster Dual Degree Programme

CIIT, 1.5KM Defence Road, Off Raiwind Road, Lahore.

Name

Ahmed Daud

Registration Number :

CIIT/DDP-FA10-BTE-002/LHR

Email

daud@live.lancs.ac.uk

Semester

Section

DDP

Department

Electrical Engineering

Course Title

Lab - Microprocessor Systems & Interfacing

Course Code

EEE342

Assignment Number :

Assignment Topic

Assembly Language Programming

Course Book

Assembly Language by Ytha Yu

Submission Date

February 27, 2013

Submitted To

Engr. Mr. Usman Rafique

1|Page

TABLE OF CONTENTS
QUESTION #

PAGE #

Q#1

Q#2

Q#3

References

2|Page

QUESTION NO. 1
Identify the incorrect instructions in the following code segment of 8086-88 assembly language.

SOLUTION:
MOV AX, BX

; COPY THE CONTENTS OF BX IN AX

MUL CX

; THE FIRST OPERAND IS ASSUMED TO BE IN AX

MOV DX, [45ABH]

; COPY THE CONTENT OF MEMORY LOCATION [45ABH] IN DX

MOV [256AH], DX

; CAN NOT ACCESS TWO MEMORIES AT THE SAME TIME

XCHG BX, [236]

; XCHNG IS WRONG ALSO NO CONSTANT ALLOWED.


; IT EXCHANGES THE CONTENTS OF REGISTERS OR MEMORY

MOV AX, 12H

; COPY 12H IN AX FOR DIVISION

DIV AL

; 8-BIT DIVISION USING DIV INSTRUCTION REQUIRES AX FOR DIVIDEND


; AND AN OPERAND FOR THE DIVISOR.

XOR [1256H], BX

; IT XOR MEMORY [1256H] AND BX AND STORE THE RESULT IN LOC [1256H]

MOV AX, 1234H

; LOAD THE NUMBER INTO A REGISTER, THEN USE THE NEG INSTRUCTION

NEG AX

; ONLY REGISTERS OR MEMORY LOCATION ALLOWED.


; NEG COMPUTES THE TWO'S COMPLEMENT

3|Page

QUESTION NO. 2
Write an 8086-88 assembly language program to convert the Celsius reading into the Fahrenheit
reading. Celsius reading is found in AL register and Fahrenheit reading is to be placed in AH register.

SOLUTION:
; We will convert Celsius to Fahrenheit using formula: f = c * 9 / 5 + 32.
ORG 100H
MOV BL, AL

; CELSIUS READING IS FOUND IN AL REGISTER.

MOV AL, 9

; COPY 9 IN AL.

IMUL BL

; MULTIPLY BL WITH AL I.E 9 AND STORE IN AL.

MOV BL, 5

; COPY 5 IN BL.

IDIV BL

; DIVIDE AL WITH BL AND STORE IN AL.

ADD AL, 32

; ADD 32 IN AL.

MOV AH, AL

; FAHRENHEIT READING IS TO BE PLACED IN AH REGISTER.

RET

; RETURN TO THE OPERATING SYSTEM.

4|Page

QUESTION NO. 3
Write an 8086-88 assembly language program that clears a specific bit in BX register. Number of the
bit which is to be cleared (from 0 to 15) is placed in AL. Program should clear only desired bit leaving
other bits unchanged.

SOLUTION:
MOV DX, 0001H

; COPY 1 IN DX.

MOV CL, AL

; AS ONLY IMMEDIATE BYTE OR CL CAN BE USED AS SECOND PARAMETER IN SHL.

SHL DX, CL

; SHL INSTRUCTION SHIFTS THE BITS IN DX TO CL TIMES LEFT.

NOT DX

; TAKE 1S COMPLEMENT OF DX I.E. INVERT THE BITS OF DX.

AND BX, DX

; AND BX WITH DX TO CLEAR AL BIT.

RET

; RETURN TO THE OPERATING SYSTEM.

ALTERNATE SOLUTION:
MOV DX, 0FFFEH
MOV CL, AL
ROL DX, CL
AND BX, DX

5|Page

REFERENCES
Assembly language programming and organization of the IBM PC by Ytha Y. Yu, Charles
Marut
The 80x86 IBM PC and compatible computers: Assembly language, design, and interfacing by
Muhammad Ali Mazidi, Janice Gillispie Mazidi
Assembly Language for Intel-Based Computers by Kip R. Irvine
The Intel Microprocessors: 8086/8088, 80186/80188, 80286, 80386, 80486, Pentium,
Pentium Pro, and Pentium II Processors : Architecture, Programming, and Interfacing by
Barry B. Brey
Assembly language programming for the Intel 80XXX family by William B. Giles
The 80x86 IBM PC and Compatible Computers (Vol 1 and Vol 2)
Microcomputer Systems: The 8086/8088 Family
Online Materials
Intel Developers website http://developer.intel.com
AIX-86 (8086) Datasheet
www.google.com
www.wikipedia.com
http://ocw.mit.edu/
http://see.stanford.edu/
http://mycourses.med.harvard.edu/public/

6|Page