Islamic Azad University, Central Branch, Faculty of Technology – Computer Dep.

Machine and Assembly Language Programming- Code:3672 – BSc Computer Eng.

2nd Semester 83-84 - Date: 7/4/84 - Time allowed: 2 hours

Rafi Allameh

Q1

A signed packed BCD number is stored in AX. Write a program to display the contents of AX on monitor. Store the converted  BCD number to ASCII in a location called adadbcd. To display the converted number use Function 09. Convert in tabdil proc near. Use bitwise operations.  (4)

 

Q2

a) Write a program for adding two 2 byte numbers a1 and a2 stored in data segment pushed into stack by the main program prior to calling proc add2 far ( proc for adding two numbers). Use BP to transfer the numbers to proc add2. (2)

 

b) Write the main and add2 procs in two different files.(0.5)

 

c) What are the stages of generating main.exe if the main proc is in main.asm and add2 in procs.asm. (0.5)

 

d) Using appropriate diagrams show the way the data is stored in data and stack segments, show location of SP and BP and also indicate the offset of each data unit. (1)

 

 

Q3

a) Write a program for inputting a line of string of with maximum of 80 characters using function 0A. Use repne and scasb to count the number of ‘a’ s in this string ( taking into account the first and last characters ) and using function 09 display the message “number of a’s  are=# #” on the screen. Convert the numbers into ASCII using proc itoa especially written for converting non-signed two figure numbers utilizing bitwise operations.(4)

 

Q4

a) Write the execution stages of push ax and pop ax. (1)

 

c) Why programs in assembly execute faster than equivalent programs in high level languages?(1)

 

Q5

a) What is the binary representation of -0.35 using  format below?  (1)

0

22

23

30

31

m

e'

s

m=mantissa, s= sign, b=number of bits allocated to e’ , e’= e+2b-1

 

b) what is the BCD representation of -1?(0.5)

 

Q6

What is the effect of test ah,20h with AH=61h on ZF?

What is the effect of neg ah with AH=80h on SF and OF?

What is the effect of sub ah,40h with AH=30h on CF? (1)

 

Q7

Write the object code and location counter for the following program (3)

 

datasg

segment

 

string

db ‘ABCDEF’

 

a2

dw   11111111b,00ffh

 

b2

dw   250,10,-1

 

x

dw  6 dup(‘AA’)

 

datasg

ends

 

 

 

 

codesg

segment

 

 

assume cs:codesg,ds:datasg

 

main

proc far

mov ax,seg datasg =B8 + Reserve 2 bytes for datasg

 

mov ax,seg datasg

mov ds,ax=8E D8

 

mov ds,ax

mov ax=A1

 

mov ax,b2+2

push ax=  50

 

push ax

mov ax=A1

l1:

mov ax,x

inc ax= 40

 

inc ax

cmp al=3C

 

cmp al,5

jne=75

 

jne l2

mov cx=8B0E

 

mov cx, a2+2

loop=E2

 

loop l1

mov ax=B8

 

mov ax,0

ret=CB

l2:

ret

 

main

endp

 

codesg

ends

 

 

end main

 

Q8

Which addressing mode is used for data type structures in assembly, explain. (0.5)