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

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

1st Semester 83-84 - Date: 24/10/83 - Time allowed: 2 hours

Rafi Allameh

Q1

System time can be set using function ah=2D of int 21h. CH is hour (0-23) , CL is minutes (0-59), DH seconds and DL hundredths of seconds. Write a program for inputting the time using function 0A in the hh:mm format and storing it in location time. Convert the input string into an integer in a Far proc named integer . Then by giving the above registers the correct value (DL=DH=0) set system time. Use bitwise operations where possible. (4)

Q2

a) Write a program to convert the contents of AX register to its BCD equivalent. Do the conversion in “convert proc far”, taking into account the sign of the number. Use bitwise operations where possible. (2)

b) Write convert proc far  in a separate file to the main program.(1)

c) What are the stages of generating main.exe if the main proc is in main.asm and convert in procs.asm. (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 and ‘A’ s in this string ( taking into account the first and last characters ) and using function 09 display the message “number of a’s and 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)

b) Using a diagram show the way the data is stored in data and stack segments and also indicate the offset of each data unit.

Q4

a) Does the object code of an interrupt affect the volume of the calling program? Please explain. (0.5)

b) Why is the source of script programs transferred to the client in the Internet?(0.5)

Q5

a) What is the denary equivalent of the floating number C4642000  (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 ob -1?(0.5)

Q6

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

What is the effect of sar ah,1 with AH=81h 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’ aa dw ? bb dw   250,10,-1 x db 5 dup(16) 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,aa+1 push ax=  50 push ax mov ax=B8 mov ax,0 inc ax= 40 l1: inc ax cmp al=3C cmp al,5 jne=75 jne l2 mov cx=8B0E mov cx,bb+2 loop=E2 loop l1 ret=CB l2: ret main endp codesg ends end main

Q8

With reference to Q7 will mov ax,aa  execute faster or mov ax,0 ? Explain using the stages of execution of instructions. (0.5)