Code: Select all

```
1 REM PROGRAM: COMPILER.BAS
2 REM TYPE OF COMPILER CONVERTING HEXADECIMAL
3 REM CREATED BY: GREGORY LYONS
4 REM CONTAINS ORIGINAL IDEAS BY GREGORY LYONS
5 REM PROGRAM IS FREE TO USE ALSO IS INCOMPLETE
20 INPUT "FILE TO MAKE AS TOKEN WITH -[.TKN]:", FILENAMETOKEN$
30 IF INSTR(1, FILENAMETOKEN$, ".") > 1 THEN PLACEOFEXTENSION = INSTR(1,
FILENAMETOKEN$, ".")
40 IF INSTR(1, FILENAMETOKEN$, ".") = 1 THEN PLACEOFEXTENSION = 1
50 LENGTHOFEXTENSION = LEN(FILENAMETOKEN$) - PLACEOFEXTENSION
60 EXTENSION$ = MID$(FILENAMETOKEN$, PLACEOFEXTENSION, LENGTHOFEXTENSION)
70 IF EXTENSION$ <> "TKN" THEN EXTENSION$ = ".TKN"
80 IF PLACEOFEXTENSION > 1 THEN FILENAME$ = LEFT$(FILENAMETOKEN$,
(PLACEOFEXTENSION - 1))
90 IF PLACEOFEXTENSION = 1 THEN COLOR 4, 0: PRINT"ERROR #1 - STARTED FILE
WITH '.' OR NO EXTENSION ENTERED!!!": COLOR 7, 0: GOTO 20
100 IF PLACEOFEXTENSION = 0 THEN FILENAME$ = FILENAMETOKEN$
110 FILENAMETOKEN$ = FILENAME$ + EXTENSION$
120 FILETOMAKE$ = FILENAME$ + ".EXE"
130 OPEN FILETOMAKE$ FOR OUTPUT AS #1
140 FIRST$ = "M" + "Z" + CHR$(144)
150 PRINT #1, FIRST$;
160 OPEN FILENAMETOKEN$ FOR INPUT AS #2
170 WHILE NOT EOF(2)
180 SYSDB$ = INPUT$(2, 2)
190 CHEESY = CVI(SYSDB$)
200 WELT$ = HEX$(CHEESY)
210 IF LEN(WELT$) = 3 THEN WELT$ = "0" + WELT$
220 IF LEN(WELT$) = 2 THEN WELT$ = "0" + "0" + WELT$
230 IF LEN(WELT$) = 1 THEN WELT$ = "0" + "0" + "0" + WELT$
240 STUCK$ = LEFT$(WELT$, 2)
250 SAMPLE$ = MID$(WELT$, 2, 2)
260 FIRSTCHOICE$ = LEFT$(STUCK$, 1)
270 SECONDCHOICE$ = MID$(STUCK$, 2, 1)
280 THIRDCHOICE$ = LEFT$(SAMPLE$, 1)
290 FOURTHCHOICE$ = MID$(SAMPLE$, 2, 1)
300 FOR DIVERT = 1 TO 6
310 JUMBLE1$ = FIRSTCHOICE$
320 IF JUMBLE1$ = CHR$(64 + DIVERT) THEN FIRSTCHOICE$ = STR$(9 + DIVERT)
330 JUMBLE2$ = SECONDCHOICE$
340 IF JUMBLE2$ = CHR$(64 + DIVERT) THEN SECONDCHOICE$ = STR$(9 + DIVERT)
350 JUMBLE3$ = THIRDCHOICE$
360 IF JUMBLE3$ = CHR$(64 + DIVERT) THEN THIRDCHOICE$ = STR$(9 + DIVERT)
370 JUMBLE4$ = FOURTHCHOICE$
380 IF JUMBLE4$ = CHR$(64 + DIVERT) THEN FOURTHCHOICE$ = STR$(9 + DIVERT)
390 NEXT DIVERT
400 IF VAL(FIRSTCHOICE$) = 0 THEN STUCK$ = STR$(VAL(SECONDCHOICE$))
410 IF VAL(SECONDCHOICE$) = 0 THEN STUCK$ = STR$(VAL(FIRSTCHOICE$) * 10)
420 IF (VAL(SECONDCHOICE$) > 0) AND VAL(FIRSTCHOICE$) <0> 0) AND VAL(THIRDCHOICE$) <> 0 THEN SAMPLE$ =
STR$(VAL(THIRDCHOICE$) * VAL(FOURTHCHOICE$))
460 STUCK$ = STR$(VAL(STUCK$) - 1)
470 SYSDB$ = CHR$(ASC(STUCK$))
480 PRINT #1, SYSDB$;
490 SAMPLE$ = STR$(VAL(SAMPLE$) - 1)
500 SYSDB$ = CHR$(ASC(SAMPLE$))
510 PRINT #1, SYSDB$;
520 WEND
530 CLOSE #2
540 CLOSE #1
550 END
```