You are on page 1of 3

Chapter 5 

1. Every macro must start with directive MACRO and end with directive
ENDM. 2. name: WORK_HOUR 
 body: MOV AL,40 ;WEEKLY HRS  
 ADD AL,OVRTME_HR ;TOTAL HRS WORKED  

 dummy argument: OVRTME_HR 

4. What is the total value in register DX and AX after invoking the following
macro? WAGES MACRO SALARY, OVERTIME, BONUSES 
;TOTAL WAGES = SALARY + OVERTIME + BONUSES 
SUB AX, AX ;CLEAR 
MOV DX, AX ;AX AND DX 
ADD AX, SALARY 
ADD AX, OVERTIME 
ADC DX, 0 ;TAKE CARE OF CARRY 
ADD AX, BONUSES 
ADC DX, 0 
ENDM 
The macro is invoked as 
WAGES 60000, 25000, 3000 

AX = 57C0 
DX = 0001 
5. In 4., in the body of the macro, dummies were used as they are listed from left to right. 
Can they be used in any order? Rewrite the body (leave the dummies alone) by adding 
OVERTIME first. 
-The order of using the operands does not matter: 
ADD AX,OVERTIME  
ADD AX,SALARY 

8. Fill in the blanks for the following macro to add an array of bytes. Some blank might 
not need to be filled. 
SUMMING MACRO COUNT, VALUES 
LOCAL AGAIN 
;this macro adds an array of byte size alements 
;ax will hold the total sum
MOV CX, COUNT ;size of array 
MOV SI, OFFSET VALUES ;load offset address of array SUB AX,
AX ;clear ax 
AGAIN: ADD AL, [SI] 
ADC AH, 0 ;add bytes and takes care of carries INC SI ;point to
next byte 
LOOP AGAIN ;continue until finish 
ENDM  
9. Invoke and run the macro above for the following data 
In the data segment: 
DATA1 DB 89, 75, 98, 91, 65 
SUM1DW ? 
DATA2 DB 86, 69, 99, 14, 93, 99, 54, 39 
SUM2DW ? 
DATA3 DB 10 DUP (99) 
SUM3DW ? 

13. Using INT 33H, write and test an Assembly language program to check the presence 
of a mouse in a PC. If a mouse driver is installed, it should state the number of buttons it 
supports. If no mouse driver is installed, it should state this. 

TITLE PROBLEM 13 

DISPLAY MACRO STRING 


MOV AH,09H 
MOV DX,OFFSET STRING 
INT 21H 
ENDM 
.MODEL STACK 
.DATA 
MSG1 DB 'THERE IS A MOUSE INSTALLED IN THIS PC $’ MSG2
DB ‘AND IT HAS’ 
BUTTON DB ? , ’BUTTON $’ 
MSG3 DB 'THIS PC HAS NO MOUSE $' 
.CODE 
MAIN PROC FAR 
MOV AX,@DATA 
MOV AX,0 
INT 33H 
CMP AX,0 
JZ OVER
DISPLAY MSG1 
OR BL,30H 
MOV BUTTON,BL 
DISPLAY MSG2 
JMP EXIT 
OVER: DISPLAY MSG3 EXIT:
MOV AH,4CH INT 21H 
MAIN ENDP 
END MAIN

You might also like