Introduction to Computer Organization and Assembly Language

Download Report

Transcript Introduction to Computer Organization and Assembly Language

Introduction to Computer
Organization and Assembly
Language
Sheet 2
Question 1
Q1: Tell whether each of the following instructions is
legal or illegal.WD1 and WD2 are word variables,
and BT1 and BT2 are byte variables.
Question 1
A. ADD WD1,WD2 Illegal memory location & memory location
B. MOV AL,0AC3h Illegal out of range
C. MOV DS,BX
Legal
D. ADD 03,AL
Illegal the destination is a constant
E. MOV AH,WD2
Illegal operands are not of the same type
MOV BT1,BT2
G. MOV CS,SS
H. MOV DS,100h
I. MOV WD2,CS
J. MOV BT1,WD1
Illegal memory location & memory location
F.
Illegal segment register to segment register
Illegal constant to segment register
Legal segment register to memory location
Illegal memory location & memory location
Question 2
Q2: Using only MOV, ADD, SUB, INC, DEC, and
NEG, translate the following high-level language
assignment statements into assembly language. A,
B, and C are word variables.
Question 2
a. B = 3 * B + 2
MOV AX,B
ADD AX,B
ADD AX,B
ADD AX,2
MOV B,AX
b. B = A + C
MOV AX,A
ADD AX,C
MOV B,AX
Question 2
c. C = -(C + 1)
INC C
NEG C
d. A = C – B
MOV AX,C
SUB AX,B
MOV A,AX
Question 2
e. A = C - A – 1
MOV AX,C
SUB AX,A
DEC AX
MOV A,AX
Question 3
 Q3: Write assembly program that displays the
following “This Program is to swap content of two
memory locations”, and then define two variables
(BYTE1 and BYTE2) of type byte and uninitialized,
then write a transfer instruction that assign value
('A') in BYTE1 and value (45H) in BYTE2, then try
to swap the values.
Question 3
Question 3
Question 3