'=========================================================================== ' Subject: INTERRUPT HELP Date: Unknown Date (00:00:00) ' Author: Earl Montgomery Code: QB, PDS ' Keys: INTERRUPT,HELP Packet: INTERRPT.ABC '=========================================================================== '$INCLUDE: 'qb.bi' DIM inregs AS regtypex, outregs AS regtypex CLS LOCATE 1, 1: PRINT "For those of you that have mastered the use "; PRINT "of interrupts, read no further!"; LOCATE 2, 1: PRINT "However if you are like me and still"; PRINT " struggling you might find this interesting."; LOCATE 3, 1: PRINT "First off whenever you use an interrupt with"; PRINT " QB you need to load QB/L."; LOCATE 4, 1: PRINT "This loads the QB.QLB library which contains"; PRINT " the code needed to use interrupts."; LOCATE 5, 1: PRINT "Now you are ready to program! Your first"; PRINT " entry should be '$INCLUDE: 'QB.BI'"; LOCATE 6, 1: PRINT "This file contains the TYPE and Data"; PRINT " structure to be used."; LOCATE 7, 1: PRINT "List QB.BI from DOS and you will see there "; PRINT "are two types defined."; LOCATE 8, 1: PRINT "RegType and RegTypeX. Notice that both are "; PRINT "identical except that"; LOCATE 9, 1: PRINT "RegTypeX allows the use of the ES and DS "; PRINT "segment registers."; LOCATE 10, 1: PRINT "Your next entry should be: DIM inregs as "; PRINT "regtypex,outregs as regtypex"; LOCATE 11, 1: PRINT "Now we need to call an interrupt. If you "; PRINT "have the DOS programmers manual"; LOCATE 12, 1: PRINT "look at interrupt &h21 function &h19. This "; PRINT "interrupt gets the Default"; LOCATE 13, 1: PRINT "Drive and returns the info in AL of register"; PRINT " AX. If AL returns a 0 this"; LOCATE 14, 1: PRINT "represents Drive A. If AL returns a 1 then "; PRINT "this represents drive B. If AL"; LOCATE 15, 1: PRINT "returns a 2 this represents Drive C and so on." LOCATE 16, 1: PRINT "Now we need to put something in register AX"; PRINT " and that is the function &H19."; LOCATE 17, 1: PRINT "INREGS.AX=&H1900" LOCATE 18, 1: PRINT "Now we call the interrupt." LOCATE 19, 1: PRINT "CALL INTERRUPTX(&h21,INREGS,OUTREGS)" LOCATE 23, 28: PRINT "Press any key to continue." WAIT1: I$ = INKEY$: IF I$ = "" THEN GOTO WAIT1 CLS LOCATE 1, 1: PRINT "OK the DOS programmers manual said that the "; PRINT "info would be returned in AL."; LOCATE 2, 1: PRINT "How do we read AL from register AX? Use this"; PRINT " formula:"; LOCATE 3, 1: PRINT "AL=AX AND &HFF (More on these formulas later.)" LOCATE 4, 1: PRINT "PRINT AL" LOCATE 5, 1: PRINT : PRINT "Let's put everything together and "; PRINT "see what we have."; LOCATE 7, 1: PRINT "'$include: 'Qb.BI'" LOCATE 8, 1: PRINT "DIM inregs AS RegTypeX,outregs AS RegTypeX" LOCATE 9, 1: PRINT "inregs.ax=&h1900" LOCATE 10, 1: PRINT "CALL INTERRUPTX(&h21,INREGS,OUTREGS)" LOCATE 11, 1: PRINT "AX = (outregs.ax)" LOCATE 12, 1: PRINT "AL=AX AND &Hff" LOCATE 13, 1: PRINT "PRINT AL" LOCATE 14, 1: PRINT "Now let's actually run this program. Ready?"; PRINT " Here goes!"; inregs.AX = &H1900 CALL interruptx(&H21, inregs, outregs) loop1: LOCATE 15, 28: PRINT "Press any key to continue." I$ = INKEY$: IF I$ = "" THEN GOTO loop1 REM Formula to find AL. AX = (outregs.AX) AL = AX AND &HFF REM Looking for a 2 in AL (My default drive is C) PRINT AL LOCATE 19, 1: PRINT "Well I got a 2 because my default drive is "; PRINT "C. How about you?"; LOCATE 23, 28: PRINT "Press any key to continue." wait2: I$ = INKEY$: IF I$ = "" THEN GOTO wait2 CLS LOCATE 1, 28: PRINT "Formulas to read AH and AX." LOCATE 2, 1: PRINT "Now let's see how we can read AH." LOCATE 3, 1: PRINT "To find AH the formula is "; PRINT "AH=(AX AND &HFF00)/256"; LOCATE 4, 1: PRINT "Let's run it and see what we get." LOCATE 5, 28: PRINT "Press any key to continue." loop3: I$ = INKEY$: IF I$ = "" THEN GOTO loop3 AH = (AX AND &HFF00) / 256 PRINT AH LOCATE 7, 1: PRINT "I got 25. How about you?" PRINT LOCATE 10, 1: PRINT "Well we know the value of AL and AH. With "; PRINT "these two values"; LOCATE 11, 1: PRINT "we can find out what is in AX. The formula "; PRINT "is AX=(256*ah)+AL"; LOCATE 12, 1: PRINT "In my case AL was 2 and AH was 25. So 256 *"; PRINT " 25 + 2 in AL=6402"; LOCATE 13, 1: PRINT "Let's run it and see what we get." AX = (256 * AH) + AL LOCATE 14, 28: PRINT "Press any key to continue." loop4: I$ = INKEY$: IF I$ = "" THEN GOTO loop4 PRINT AX LOCATE 17, 1: PRINT "My values matched how about yours?" LOCATE 23, 28: PRINT "Press any key to continue." loop5: I$ = INKEY$: IF I$ = "" THEN GOTO loop5 CLS LOCATE 1, 1: PRINT "But someone is saying in "; PRINT "AX how can it contain 6402!"; LOCATE 2, 1: PRINT "Did I mention the AX,BX,CX and DX registers "; PRINT "are 16 bit registers?"; LOCATE 3, 1: PRINT "This means AX is composed of two 8 bit "; PRINT "registers AL & AH"; LOCATE 4, 1: PRINT "Remember we put &H19 in AH and AL returned a"; PRINT " &h2. Therefore AX contains"; LOCATE 5, 1: PRINT "&H1902. And if you do a PRINT &H1902 you get "; PRINT "6402. I am printing all"; LOCATE 6, 1: PRINT "values in decimal. Anyway, let's print it now." LOCATE 8, 28: PRINT "Press any key to continue" loop6: I$ = INKEY$: IF I$ = "" THEN GOTO loop6 PRINT &H1902 PRINT "Your value may differ depending on your default drive." LOCATE 23, 28: PRINT "Press any key to continue." loop7: I$ = INKEY$: IF I$ = "" THEN GOTO loop7 CLS LOCATE 1, 1: PRINT "I hear someone saying "; LOCATE 2, 1: PRINT "Then why doesn't AX contain &h0219 instead "; PRINT " of &h1902?"; LOCATE 3, 1: PRINT "My reference books show the same thing and "; PRINT "that is confusing to me too."; LOCATE 4, 1: PRINT "But trust me for now AH is on the left and AL"; PRINT " is on the right. Maybe someone"; LOCATE 5, 1: PRINT "can shed some light on why the progrmming "; PRINT "books show examples with AL on the"; LOCATE 6, 1: PRINT "left and AH on the right." LOCATE 8, 1: PRINT "How would you like to see how the bit wise "; PRINT "AND operation with"; LOCATE 9, 1: PRINT "&Hff allows us to read the value in AL? Hey!"; PRINT " Where is everyone going!?"; LOCATE 10, 1: PRINT "Class hasn't been dismissed! Hey come back!"; PRINT " Well for those of you who"; LOCATE 11, 1: PRINT "stayed it is very very simple: The AND &Hff"; PRINT " (255) or binary 11111111 " LOCATE 12, 1: PRINT "sets all the bits in AH to 0. Therefore all "; PRINT "we have left is what is in AL." PRINT "Neat huh?" LOCATE 14, 1: PRINT "Class is now dismissed." locate 15,1:print"Your instructor was Earl Montgomery" LOCATE 23, 28: PRINT "Press any key to continue." loop8: I$ = INKEY$: IF I$ = "" THEN GOTO loop8 END