a) Consider the following ISR (Interrupt Service Routine). If you run this ISR in your 8086 kits, what would you observe?

MyISR:
MOV AL, 0x81
OUT 0, AL
IRET

b) If I want to run the above code as a subroutine, what would be the change I must make in it?

1 answer

a) If you run this ISR in your 8086 kits, you would observe that the ISR moves the value 0x81 into the AL register, then outputs the value of AL to port 0, and finally performs a return from the interrupt (IRET) instruction.

b) If you want to run the above code as a subroutine, you would need to remove the IRET instruction. The IRET instruction is used specifically for returning from an interrupt service routine. In a subroutine, you can simply end the code with a RET instruction, which will return to the calling code. So the updated code would be:
MySubroutine:
MOV AL, 0x81
OUT 0, AL
RET