Tutorial2
Tutorial2
EEE/ECE/INSTR F241
Microprocessors Programming and Interfacing
Tutorial 2
2. What will be the value of SP and IP after execution of following series of instructions?
3. write a program to multiply two 1-byte unsigned numbers without using the MUL instruction
4. write a program to divide two 1-byte numbers without using the DIV instruction. Store the
quotient in ch and remainder in cl.
5. You were given a task to design a small calculator program that uses subroutines to perform basic
arithmetic operations (addition, subtraction, multiplication). The operations were to be coded as: 0
→ addition, 1 → subtraction, 2 → multiplication. You wrote the following program. However, no
matter what code was given, the program always returned result of multiplication. What do you think
went wrong?
cmp al, 0
JE addcal
cmp al, 1
JE subcall
cmp al, 2
JE mulcall
addcall: call addfunc
subcall: call subfunc
mulcall: call mulfunc
6. Write a program for multiplication of 2 16-bit numbers that uses the stack to pass parameters to a
subroutine and uses the returned value in the main program. (Let operands be stored at 3000)
PUSH AX ; AX = 1234
PUSH BX ; BX = 5678
PUSH CX ; CX = 9ABC
Explain how can you store value of AX in DX without using the pop instruction?
8. Write a program to add two 32-bit numbers stored at consecutive memory locations starting from
1000H using 8086 and store the result in location starting from 3000H.