Professional Documents
Culture Documents
Bài tập nhúng
Bài tập nhúng
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
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.