-
Notifications
You must be signed in to change notification settings - Fork 4
/
INTEL.B2S
53 lines (53 loc) · 1.19 KB
/
INTEL.B2S
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
10 ON ERROR GOTO 220
15 PRINT "Hex dump to INTEL absolute load format"
16 PRINT
20 PRINT "Filename ";
30 INPUT LINE F$
40 OPEN F$ FOR INPUT AS FILE 1%
50 PRINT "Output to ";
60 INPUT LINE O$
70 OPEN O$ FOR OUTPUT AS FILE 2%
80 INPUT "Start address (hex) ";S$
90 WHILE -1%
100 INPUT #1%,L$
111 N$=RIGHT(FNH$(LEN(L$)/2%),3%)
112 N%=FND%(N$)
113 C%=N%+FND%(LEFT(S$,2%))+FND%(RIGHT(S$,3%))
120 PRINT #2%,":"+N$+S$+"00";
150 FOR I%=1% TO 31% STEP 2%
151 D$=MID(L$,I%,2%)
152 D%=FND%(D$)
153 C%=C%+D%
160 PRINT #2%,D$;
170 NEXT I%
180 PRINT #2%,RIGHT(FNH$(-C%),3%)
200 S$=FNH$(FND%(S$)+16%)
210 NEXT
220 PRINT #2%
230 CLOSE 1%,2%
240 PRINT
250 PRINT "Done"
260 GOTO 32767
1000 DEF* FND%(X$)
1010 X0%=0%
1020 FOR X1%=1% TO LEN(X$)
1030 X2%=ASCII(MID(X$,X1%,1%))
1040 IF X2%<48% OR (X2%>57% AND X2%<65%) OR X2%>70% THEN &
PRINT "Illegal hex character in "+X$ \ STOP
1050 X2%=X2%-48%
1060 X2%=X2%-7% IF X2%>9%
1070 X0%=X2%+X0%*16%
1080 NEXT X1%
1090 FND%=X0%
1100 FNEND
2000 DEF* FNH$(X%)
2010 X$=""
2020 FOR X1%=0% TO 3%
2030 X0%=(X% AND (16%^(X1%+1%)-1%*(16%^X1%)))/(16%^X1%)
2040 X0%=X0%+16% IF X0%<0%
2050 X$=CHR$(48%+X0%)+X$ IF X0%<10%
2060 X$=CHR$(55%+X0%)+X$ IF X0%>9%
2070 NEXT X1%
2080 FNH$=X$
2090 FNEND
32767 END