Classic Computer Magazine Archive COMPUTE! ISSUE 80 / JANUARY 1987 / PAGE 71

ML Write For Atari

Danny Maupin

Though it's designed particularly for machine language (ML) programmers, this program may come in handy even if you're not an ML expert. It converts any ML program into DATA statements for use in a BASIC program. "ML Write" runs on any eight-bit Atari computer.


If you're a machine language (ML) programmer, you've probably faced the task of incorporating an ML routine into a BASIC program. The usual method is to include the ML in the form of DATA values which the BASIC program READS and POKEs into memory. Performing this conversion is a tedious task, since you must determine the numeric value of every byte in the ML program and manually type in all the necessary DATA statements. "ML Write" automates the entire process, reading the ML data from disk or tape and creating a series of DATA statements which can easily be merged with any BASIC program. The resulting series of BASIC lines also includes commands to READ the DATA and POKE it into memory.
    Type in the program and save it to disk or tape. When you run ML Write, it asks you to enter the line number increment for the DATA statements. This value determines how much the line number increases for each new DATA line. The next prompt asks for the filename of the object code: This is the file that contains the machine language. Answer this prompt by entering the correct device specifier, followed by the filename. For instance, you would convert the file GAME by entering D:GAME for disk or C: for tape.
    The last prompt asks for the starting line number. For instance, if you choose a line increment of 10 and a starting line number of 200, the first DATA line is 200, the second is line 210, and so on. The program does not allow you to enter a starting line number greater than 32767, the largest legal line number. Be careful not to set a line increment and starting line number that cause the program to exceed the value 32767 while it runs.
    When the program finishes reading the ML data, it deletes itself, leaving the DATA statements in memory, together with program lines that READ the DATA and POKE it into memory. To complete the process, LIST these lines to disk or tape so that they can later be merged with another program.

ML Write For Atari
For instructions on entering this program, please refer to "COMPUTEI's Guide to Typing In Programs" in this issue of COMPUTE!.

FD 10 DIM AS(20)
PP 20 GRAPHICS 0:SETCOLOR 2,
      0,0:SETCOLOR 1,0,15:?
      "{10 SPACES}<<<<ML WRIT
      E»»"
LP 30 TRAP 30:? :? "ENTER IN
      CREMENT ";:INPUT N:IF
      N=0 THEN 30
OF 40 TRAP 40:? "ENTER FILEN
      AME ";:INPUT A$
BG 50 TRAP 50:? "ENTER START
      INS LINE ";:INPUT A
PK 60 IF A<200 OR A>32767 TH
      EN GOTO 50
IB 70 TRAP 20:CLOSE 82:OPEN
      #2,4,0,A$:GET #2,D:GET
       #2,D:GET #2,SLB:GET #
      2,SHB:GET #2,ELB:GET #
      2,EHB:ST=A:A=A+10
BD 80 TRAP 130:POKE 842,12:6
      RAPHICS 0:SETCOLOR 2,0
      ,0:POKE 752,1:? :? :FO
      R C=1 TO 5
GO 90 ? A;" DATA ";:FOR I=1
      TO 21:GET #2,B:? B;
CB 100 IF I<21 THEN ? ",";
HP 110 NEXT I:? :? :A-A+N:NE
       XT C:? "CONT":POSITIO
       N 2,0:POKE 842,13:STO
       P
DE 120 GOTO 80
GH 130 ? "{LEFT} ":? :? :? "
       CONT":POSITION 2,0:PO
       KE 842,13:STOP
PL 140 GRAPHICS 0:SETCOLOR 2
       ,0,0:POKE 752,1:? :?
LO 150 FOR 1=10 TO 150 STEP
       10:? I:NEXT I
BH 160 ? ST;" FOR A=";SLB+25
       6*SHB;" TO ";ELB+256*
       EHB;":READ B:POKE A,B
       :NEXT A":? "CONT"
LC 170 POSITION 2,0:POKE 842
       ,13:STOP
AA 180 ? "{CLEAR}":? :? :FOR
        I=160 TO 190 STEP 10
       :? I:NEXT I:? "POKE 8
       42,12:GRAPHICS 0:SETC
       OLOR 2,0,0:LIST"
DE 190 POSITION 2,0:POKE 842
       ,13