'===========================================================================
' Subject: DUMP HEX/ASM CODE                  Date: 06-23-99 (09:38)       
'  Author: Matt Gulden                        Code: QB, QBasic, PDS        
'  Origin: www.karland.com/code/basic/      Packet: BINARY.ABC
'===========================================================================
' DUMPCODE.BAS by Matt Gulden (aka Folter) -- webmaster@thrillhaus.com
' This file originated at www.THRILLHAUS.com
' You may modify and redistribute this as long as the above two lines are
' included, unmodified.
' This source may help you learn about how compilers work. It just allows you
' to dump hex-code to a file. To find out how to get hex-code for some asm
' code, go into DEBUG in dos, type "a", enter the asm code, and later type
' "u" to unload and get the hex-code in the second column.

DEFINT A-Z
DECLARE SUB DumpCode (FileNumber, hexcode$)
Screen13$ = "B81300CD10"
End$ = "CD20"

OPEN "MODE13.COM" FOR BINARY AS 1

' This dumps the following asm code:
'   MOV AX, 0013
'   INT 10
'   INT 20
' That code calls screen mode 13, then ends the program; much like the screen
' 13 command.
DumpCode 1, Screen13$
DumpCode 1, End$

CLOSE

END

SUB DumpCode (FileNumber, hexcode$)

  FOR NUM = 1 TO LEN(hexcode$) - 1 STEP 2
    Code$ = Code$ + CHR$(VAL("&H" + MID$(hexcode$, NUM, 2)))
  NEXT

  PUT FileNumber, , Code$

END SUB
