home *** CD-ROM | disk | FTP | other *** search
/ Oakland CPM Archive / oakcpm.iso / sigm / vol193 / hex2data.bas < prev    next >
Encoding:
BASIC Source File  |  1984-10-17  |  2.3 KB  |  55 lines

  1. 10 REM  **********************************************************************
  2. 20 REM  Program:  HEX2DATA.BAS
  3. 30 REM    Author:  Ian Cottrell, Ottawa, Ontario  (613)-829-1650
  4. 40 REM  Language:  MICROSOFT BASIC-80  VER. 5.XX
  5. 50 REM  Date:  December, 1983
  6. 60 REM  Remarks:  This program will convert data files from Intel Hex Format
  7. 70 REM            to a series of BASIC 'DATA' statements.  The DATA statements
  8. 80 REM            are numbered starting with 10,000 and incrementing by 10
  9. 90 REM            although this can easily be changed if desired (NUM).
  10. 100 REM           This program can be very useful for building assembly
  11. 110 REM           language sub-routines into your BASIC programs.  Once the
  12. 120 REM           sub-routine is written, assembled, and debugged, use this
  13. 130 REM           routine to convert the output of the assembler into a series
  14. 140 REM           of DATA statements.  The resultant file is saved in ASCII
  15. 150 REM           format so it can be CHAIN MERGEd with your main program.
  16. 160 REM           Then you need only write a loop to read the data and POKE it
  17. 170 REM           into memory at the desired location.
  18. 180 REM  *********************************************************************
  19. 190 DIM B$(50),Z(50),Z$(50)
  20. 200 NUM=10000:NUM$=STR$(NUM)+" ":F=0
  21. 210 CLS$=CHR$(4):PRINT CLS$
  22. 220 INPUT "What is the INPUT filename (extension must be 'HEX')";I$
  23. 230 PRINT:INPUT "What is the OUTPUT filename (extension will be 'BAS')";O$
  24. 240 FOR I=1 TO LEN(I$)
  25. 250    IF MID$(I$,I,1)="." THEN I$=LEFT$(I$,I-1):GOTO 270
  26. 260 NEXT I
  27. 270 I$=I$+".HEX"
  28. 280 FOR I=1 TO LEN(O$)
  29. 290    IF MID$(O$,I,1)="." THEN O$=LEFT$(O$,I-1):GOTO 310
  30. 300 NEXT I
  31. 310 O$=O$+".BAS"
  32. 320 OPEN "I",#1,I$
  33. 330 OPEN "O",#2,O$
  34. 340 LINE INPUT#1,A$
  35. 350 IF MID$(A$,2,2)="00" THEN CLOSE:PRINT "ENDING ADDRESS  : "ADDR$:END
  36. 360 ADDR$=MID$(A$,4,4):IF F=0 THEN PRINT:PRINT  "STARTING ADDRESS: "ADDR$:F=1
  37. 370 A$=RIGHT$(A$,LEN(A$)-9)
  38. 380 A$=LEFT$(A$,LEN(A$)-2)
  39. 390 FOR I=1 TO (LEN(A$)/2)
  40. 400    B$(I)=MID$(A$,2*I-1,2)
  41. 410    X$=LEFT$(B$(I),1):Y$=RIGHT$(B$(I),1)
  42. 420    X=ASC(X$):Y=ASC(Y$)
  43. 430    IF X>57 THEN X=16*(10+(X-65)) ELSE X=16*(X-48)
  44. 440    IF Y>57 THEN Y=10+(Y-65) ELSE Y=Y-48
  45. 450    Z(I)=X+Y:Z$(I)=STR$(Z(I))
  46. 460 NEXT I
  47. 470 PRINT#2,NUM$;"DATA ";RIGHT$(Z$(1),LEN(Z$(1))-1);
  48. 480 FOR I=2 TO (LEN(A$)/2)
  49. 490    PRINT#2,",";RIGHT$(Z$(I),LEN(Z$(I))-1);
  50. 500 NEXT I
  51. 510 PRINT#2,CHR$(13);CHR$(10)
  52. 520 NUM=NUM+10
  53. 530 NUM$=STR$(NUM)+" "
  54. 540 GOTO 340
  55.