home *** CD-ROM | disk | FTP | other *** search
-
-
- DATA2ASM.COM
-
- This is a simple program that converts a disk file to .ASM source
- so that you may incorporate the data in your programs. This is handy
- for including character fonts, bitblocks or screens in your .EXE program.
-
- Here's how you use it:
-
- Let's assume you have a bitblock file called BITBLOCK.DAT, and you want
- to include this bitblock in your data segment:
-
- C:\MYSUB>DATA2ASM IN=bitblock.dat OUT=bitblock.asm
-
- This creates a file called BITBLOCK.ASM, which you may edit to add
- whatever public symbols you need. If you were to assemble BITBLOCK.ASM,
- link and EXE2BIN, the resulting BITBLOCK.BIN would be an exact dupiclate
- of the original BITBLOCK.DAT; however, the real purpose of DATA2ASM is
- to add the output source file to your programs. The example below grabs
- a bitblock from the screen and saves it as the file BITBLOCK.DAT.
-
- include asm.inc
-
- public grab_and_write
- extrn fcreate:proc, fput:proc, fclose:proc
- extrn halloc:proc
- extrn bitblockbytes:proc, getbitblock:proc
-
- .data
- block_size dw ?
- blockptr dw ?
- filename db 'bitblock.dat',0
- x0 dw 10,10,100,100
-
- .code
- grab_and_write proc
-
- ;
- ; this example program assumes that you have an image in the
- ; region defined by the corner coordinates at x0
- ;
- ; program fragment assumes DS:@data
- ;
- .
- .
- lea bx,x0 ; point to block corners
- call bitblockbytes ; calculate byte requirement
- jc too_big ; error control
- mov block_size,ax ; save bytes
- call halloc ; this example allocates the buffer from heap
- ; can't do this w/ huge bit blocks
- jc no_memory ; more error control
- mov blockptr,bx ; save near address of bit block
- push ds
- pop es ; ES = DS
- mov di,bx ; ES:[DI] points to buffer
- lea bx,x0 ; DS:[BX] points to coordinate data
- call getbitblock
- lea dx,filename ; DS:[DX] points to filename
- call fcreate ; create the file
-
- jc something_went_wrong
- mov bx,ax ; file handle to AX
- mov di,blockptr ; ES:[DI] points to bitblock
- mov cx,block_size ; bytes to write
- call fput
- jc something_went_wrong
- call fclose
- jc something_went_wrong
- ret ; back to caller
-
- something_went_wrong:
- ;
- ; look up DOS error code, print message & quit
- ;
- .
- .
- .
- ret
-
-
- too_big:
- ;
- ; make up a lame excuse, then exit
- ;
- .
- .
- .
- ret
-
- no_memory:
- ;
- ; print an error message, then exit
- ;
- .
- .
- .
- ret
- grab_and_write endp
-
- end
-
-
- DATA2ASM source code is included with ASMLIB registration.
-