BIN to Poke Converters for MikeBASIC



If like me, you make use of the POKE command in
MikeBASIC, then you will know it's quite a pain to
write the pgm in assembler, then compile, then
disassemble then convert all the hex bytes to decimal.

I have written a two programs that will do it automatically.
All you have to do is compile the ASM pgm you want to
include into your basic pgm, then run the .bin thru
one of my pgms.

It will ask you for the name and path to the bin file,
the name and path to create the new text file
and finally the start address (in decimal) of your POKEs.

The format of the created text file which you can then
include into your Basic pgm as follows:

poke 192 40000
poke 208 40001
poke 175 40002
poke 198 40003
etc etc
call 40000

The first pgm is for those that compile/develop
MikeBASIC apps under DOS/WIN and the second
is a perl script for those that use Linux.
I have written the .bas for QuickBasic 4.5, but should run
on other flavours of Basic such as TurboBasic
or even GWBasic (with some changes).

If you are reading this html file from the zip archive
then the source for this pgm along with the compiled exe
is also included, see bin2poke.bas and bin2poke.exe

Note that the DOS/WIN version gives you the option
of creating the text file with CRLF or just LF formatting.

These pgms are only for MikeBASIC up to version 4.2 as most 
likely from version 4.3 there will be a new format/syntax 
when using POKE statements.
Once it is finalized, I will update these pgms.


The DOS/WIN version:

'======================================= ' .bin/.com to MikeBASIC POKE converter ' compile with QuickBasic 4.5 ' Paulo Valongo 26 September 2011 '======================================= DIM FileData AS STRING * 1 INPUT "Enter file name and path to open "; InFile$ INPUT "Enter file name and path to create the POKE statements in "; OutFile$ INPUT "Enter the start address in decimal "; PokeAddr '============================= AskFileType: '============================= INPUT "Enter 1 for CRLFs in text file (WIN/DOS) or 2 for LFs only (LINUX) or 3 to exit"; FileType IF FileType = 3 THEN GOTO finish OrigPokeAddr = PokeAddr OPEN InFile$ FOR BINARY AS #1 OPEN OutFile$ FOR OUTPUT AS #2 IF FileType = 1 THEN GOTO CRLF IF FileType = 2 THEN GOTO LF GOTO UserError '=============================== CRLF: '=============================== FOR x = 1 TO LOF(1) GET #1, x, FileData DecValue$ = STR$(ASC(FileData)) PRINT #2, "poke"; DecValue$; PokeAddr PokeAddr = PokeAddr + 1 NEXT x PRINT #2, "call"; OrigPokeAddr CLOSE #1 CLOSE #2 '================================ finish: '================================ END '================================ UserError: '================================ PRINT " " PRINT "Invalid option entered" PRINT " " GOTO AskFileType '================================ LF: '================================ FOR x = 1 TO LOF(1) GET #1, x, FileData DecValue$ = STR$(ASC(FileData)) PRINT #2, "poke"; DecValue$; PokeAddr; CHR$(10); PokeAddr = PokeAddr + 1 NEXT x PRINT #2, "call"; OrigPokeAddr CLOSE #1 CLOSE #2 GOTO finish

The Linux perl script:

(Don't forget to set the appropriate permissions) Note that this perl script can also be run under Win32 however the created text file will always have CRLF formatting. I tested it using WinXP PRO 32 bit and ActiveState Perl Ver 5.8.6 Included in the zip archive, are two versions of this perl script: bin2poke.pl is the LF formatted one for use on Linux and the bin2pokeW.pl is CRLF formatted for use on Windows. #!/usr/bin/perl print "Bin to POKE converter for MikeBASIC\n"; print "by Paulo Valongo 26 September 2011\n"; print " \n"; print "Enter name and path to bin file\n"; $FileIn = <>; print "Enter name and path to text file to be created\n"; $FileOut = <>; print "Enter start POKE address in decimal\n"; $PokeAddr = <>; chomp($FileOut); chomp($PokeAddr); $OrigPokeAddr = $PokeAddr; open (FILE1, ">", $FileOut) or die $!; open (FILE2, $FileIn) or die $!; binmode FILE2; my ($data, $n); while (($n = read FILE2, $data, 1) != 0) { $ord = ord($data); print FILE1 "poke ", $ord, " ", $PokeAddr, "\n"; $PokeAddr = $PokeAddr + 1; } print FILE1 "call ", $OrigPokeAddr; close FILE2; close FILE1; $NumBytes = $PokeAddr - $OrigPokeAddr; print "DONE, processed ", $NumBytes, " bytes\n"; Hope it's of help. Paulo.