Hello, im reading a tutorial about masm but i got stuck with some questions. Cause i dont really understand what the functions mean. It does explain them, but it doesnt really makes it clear for me, so i was hoping someone here can clarify it for me.
Its about a little code like this


.MODEL SMALL
.CODE
M1: MOVE AH,08H
INT 21H
CMP AL,30H
JB M1
CMP AL,39H
JA M1
MOV DL,AL
MOV AH,02H
INT 21H
JMP M1
END


M1: MOV AH, 08H //I know what M1 is, but what does this line exactly do? I also know that 08H waits for the keyboard input, but what i dont understand is why MOV AH, 08H whats happening here?

INT 21H //Im still not sure what INT 21H is for, it explains it very unclear for me.

CMP AL,30H //
JB M1 //I know that these 2 lines check if something is pressed below the hexvalue 30H right? But why is it using AL again? And does JB always mean "smaller then"?

CMP AL,39H //
JA M1 //Same here again, and does JA always means "bigger then"?

MOV DL,AL //now why is it using DL, what does DL mean? And why is it MOVing DL into AL?

MOV AH,02H //This means that its MOVing AH into 02H so it can be printed on the screen right?

INT 21H //why is it calling INT 21H again?

JMP M1
END //This will never be reached cause of the JMP M1, (jump back to the label M1.

Well these are the question im stuck with, i know that its quite alot but i was hoping that someone here can explain it to me.
A book can only explain it one way, but a person can explain it in more ways. Thats why i came here.
Thanks for any help.
Posted on 2005-02-12 11:25:00 by w00
MOV AH, 8 loads 8 into the AH register. INT pushes the flags, the CS register and the address of the next instruction on the stack, and loads the new IP and CS from the words at the address specified by the vector number shifted left by 2 bits when in real mode. In DOS, INT 21h is the entry point of most system services. A service number is read from AH. Service 8 reads characters typed on the keyboard. The ASCII code that corresponds to the pressed key or keys is returned in AL.
JB tests the carry flag, which is set by CMP when the first operand is smaller than the second. JA jumps if the C and Z flags are off. MOV DL, AL copies AL into DL. MOV AH, 2 loads 2 into AH, and the second INT 21h causes the character code in DL to be written on the screen. END is not an instruction. It tells MASM that the program ends. It can also be used to indicate the entry point.
Posted on 2005-02-12 11:47:41 by Sephiroth3
In simple terms, computers are programmed by the manufacturer to perform certain tasks. The hard coded boot program has what is called the Basic Input/Output System (or BIOS for short) which is a collection of various basic functions. The addresses of those functions are at the very beginning of the memory and can be reached with the INT xx instruction instead of a "call" instruction. The content of selected registers act as parameters and advises the function of the exact requirements.

Originally, Microsoft issued an operating system (OS) known as MS DOS to perform more advanced functions. All those functions can be accessed as above for the BIOS, but most of them use the INT 21H interrupt. The content of the AH register indicates the general function. The content of other registers may also need to be set for many of the functions.

You should study the requirements of each of those functions if you intend to write programs based on MSDOS. You can get a list of function descriptions from many sites on the web. Just do a search for "interrupt list". If I remember right, I think Ralph Brown has the most comprehensive one. Someone else may have a link to it.

Raymond
Posted on 2005-02-12 15:47:29 by Raymond