Sunteți pe pagina 1din 4

COAL Assignment - 3

PMAS, Arid Agriculture University Rawalpindi


Barani Institute of Information Technology

Computer Organization & Assembly Language

ASSIGNMENT - 3

Submitted to
Sir Azeem

Submitted by
Name: Muhammad Usman
Roll No: 2016-ARID-0261
Class: MCS3 (E)

Submission Date: 17-March-2017

Muhammad Usman 2016-ARID-0261 1/4


COAL Assignment - 3

Chapter # 4
1. Which of the following names are legal in IBM PC assembly language?
a. TWO_WORDS LEGAL
b. ?1 LEGAL
c. TWO WORDS ILLEGAL (Contains illegal character space)
d. .@? LEGAL
e. $145 LEGAL
f. LET’S_GO ILLEGAL (Contains illegal character ‘ )
g. T= . ILLEGAL (Contains illegal character = )

2. Which of the following are legal numbers? If they are legal, tell whether
they are binary, decimal, or hex numbers.
a. 246 LEGAL DECIMAL
b. 246h LEGAL HEXA
c. 1001 LEGAL DECIMAL
d. 1,101 ILLEGAL
e. 2A3h LEGAL HEXA
f. FFFEh ILLEGAL (Must begin with digit)
g. 0Ah LEGAL HEXA
h. Bh ILLEGAL (Must begin with digit)
i. 1110b LEGAL BINARY

3. If it is legal, give data definition pseudo-ops to define each of the


following.
a. A word variable A initialized to 52
A DW 52
b. A word variable WORD1, uninitialized
WORD1 DW ?
c. A byte variable B, initialized to 25h
B DB 25h
d. A byte variable C1, uninitialized
C1 DB ?
e. A word variable WORD2, initialized to 65536
ILLEGAL (Too Long)
f. A word array ARRAY1, initialized to the 1st five +ve int (i.e. 1-5)
ARRAY1 DW 1,2,3,4,5
g. A constant BELL equal to 07h
BELL EQU 07h
h. A constant MSG equal to ‘THIS IS A MESSAGE$’
MSG EQU ‘THIS IS A MESSAGE$’

Muhammad Usman 2016-ARID-0261 2/4


COAL Assignment - 3

4. Tell whether each of the following instructions is legal or illegal. W1 and


W2 are words variables, and B1 and B2 are byte variables.
a. MOV DS, AX Legal
b. MOV DS, 1000h Illegal
c. MOV CS, ES Illegal
d. MOV W1, DS Legal
e. XCHG W1, W2 Illegal
f. SUB 5, B1 Illegal
g. ADD B1, B2 Illegal
h. ADD AL, 256 Illegal
i. MOV W1, B1 Illegal

5. 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.
a. A= B-A
MOV AX, B
SUB AX, A
MOV A, AX

b. A= -(A+1)
MOV AX, A
INC AX
NEG AX
MOV A, AX

c. C= A+B
MOV AX, A
ADD AX, B
MOV C, AX

d. B=3 x B +7
MOV AX, B
ADD AX, B
ADD AX, B
ADD AX, 7
MOV B, AX

e. A= B – A – 1
MOV AX, B
SUB AX, A
DEC AX
MOV A, AX

Muhammad Usman 2016-ARID-0261 3/4


COAL Assignment - 3

6. Write a code to show following outputs.


a. Using DATA segment (by using string)
b. Without using DATA segment (by using character instruction)

****** * * *
****** ** ** **
****** *** *** ***
.MODEL SMALL
.STACK 100H
.DATA
MSG DB "*$"
.CODE
MAIN PROC
MOV
AX,@DATA
MOV DS,AX
MOV AH,2

MOV DL,”*”
INT 21H

MOV DL,010
INT 21H
MOV DL,013
INT 21H
MOV DL,"*"
INT 21H
INT 21H

MOV DL,010
INT 21H
MOV DL,013
INT 21H
MOV DL,"*"
INT 21H
INT 21H
INT 21H

END MAIN
MAIN ENDP

Muhammad Usman 2016-ARID-0261 4/4

S-ar putea să vă placă și