Interrupts are simply set of procedures. We’re using interrupts with INT
command. Before running an interrupt we have to store some data on stack to tell interrupt what we want to do.
MOV AH, 09H ;function number for outputing string to the monitor
LEA DX, STR ;store the string that we want to display
INT 21H ;run interrupt
This is an axample interrupt to display string.
This interrupt is looking to AH register. Let’s look at it’s functions:
It’s important to have $ in the end of the array.
When we press ENTER it stops recording data, after:
To be able to record array we have to declare buffer storage.
If we type something ZF becomes 0.
When we type something to keyboard AL stores typed character with ASCII format.
These interrupts are just examples, there are ton of interrupts we can use.
I want to show you how to use interrupts with a simple example. In this example I want to type some string and display it.
.MODEL SMALL
.STACK 64
.DATA
MESSAGE DB 'Type your string:', '$' ;welcome message
USER_INPUT DB 80 DUP('$') ;user input we want to store
NEWLINE DB 10,13,'$' ;move to new line after typing
.CODE
MOV AX, @DATA ;required stuff
MOV DS, AX
LEA SI, USER_INPUT
MOV AH, 09H
LEA DX, MESSAGE ;display welcome message
INT 21H
MOV AH, 0AH ;get pressed key
MOV DX, SI
INT 21H
MOV AH, 09H ;display new line
LEA DX, NEWLINE
INT 21H
MOV AH, 09H ;display typed string
LEA DX, USER_INPUT+2
INT 21H
MOV AH, 4CH ;terminate program
INT 21H
END ;exit
I'm writing a book to simplify Hugo and allow you to create your own theme just from scratch.
Join the waitlistBook a call with me and maybe we can combine our forces to make your project a reality.