A program to dump a hex file in octal

General discussions related to the Altair 8800 Clone

A program to dump a hex file in octal

Postby jdrago » June 16th, 2015, 1:15 am

I'm not sure if there is an easier way to do this, however, I wrote a program to take a .HEX file and dump the contents in OCTAL. The output is similar to the octal dumps that Mike provides in his example programs.

I hope you find it useful.

John

Code: Select all
1000 '
1010 ' Dump HEX file in octal
1020 '
1030 PRINT "Filename: ";
1040 INPUT F$
1050 PRINT:PRINT "File: ";F$
1060 PRINT
1070 GOSUB 5000
1080 OPEN "I",#1,F$
1090 IF EOF(1) THEN 1300
1100 INPUT #1,L$
1110 'PRINT L$
1120 '
1130 ' print Octal dump for line in L$
1140 '
1150 C$=MID$(L$,2,2)
1160 GOSUB 2000:L=D
1170 IF L = 0 THEN 1300
1180 'PRINT L
1190 C$=MID$(L$,4,2):GOSUB 2000:ADDR=D*256
1200 C$=MID$(L$,6,2):GOSUB 2000:ADDR=ADDR+D
1210 GOSUB 4000
1220 PRINT ADDR$;": ";
1230 FOR I=1 TO L
1240 C$=MID$(L$,(I-1)*2+10,2)
1250 GOSUB 3000
1260 PRINT O$;" ";
1270 NEXT I
1280 PRINT
1290 GOTO 1090
1300 CLOSE #1
1310 PRINT:PRINT "--- END ---"
1320 END
2000 '
2010 ' Get decimal value of string in C$ return in D
2020 '
2030 TEMP=ASC(LEFT$(C$,1))-ASC("0"):IF TEMP > 10 THEN TEMP=TEMP-7
2040 D=TEMP*16
2050 TEMP=ASC(RIGHT$(C$,1))-ASC("0"):IF TEMP > 10 THEN TEMP=TEMP-7
2060 D=D+TEMP
2070 RETURN
3000 '
3010 ' Get octal string value of string in c$ return in o$
3020 '
3030 GOSUB 2000
3040 TEMP=INT(D/64):O$=RIGHT$(STR$(TEMP),1):D=D-(TEMP*64)
3050 TEMP=INT(D/8):O$=O$+RIGHT$(STR$(TEMP),1):D=D-(TEMP*8)
3060 O$=O$+RIGHT$(STR$(D),1)
3070 RETURN
4000 '
4010 ' Convert decimal address in ADDR to a 4-digit octal address.  Return in ad
dr$
4020 '
4030 ' 0 000 000 000 000 000
4040 ' 177777
4050 'PRINT ADDR
4060 TEMP=INT(ADDR/32768!):ADDR$=RIGHT$(STR$(TEMP),1):ADDR=ADDR-(TEMP*32768!)
4070 TEMP=INT(ADDR/4096):ADDR$=ADDR$+RIGHT$(STR$(TEMP),1):ADDR=ADDR-(TEMP*4096)
4080 TEMP=INT(ADDR/512):ADDR$=ADDR$+RIGHT$(STR$(TEMP),1):ADDR=ADDR-(TEMP*512)
4090 TEMP=INT(ADDR/64):ADDR$=ADDR$+RIGHT$(STR$(TEMP),1):ADDR=ADDR-(TEMP*64)
4100 TEMP=INT(ADDR/8):ADDR$=ADDR$+RIGHT$(STR$(TEMP),1):ADDR=ADDR-(TEMP*8)
4110 ADDR$=ADDR$+RIGHT$(STR$(ADDR),1)
4120 'PRINT ADDR$
4130 RETURN
5000 '
5010 ' Capitalize F$
5020 '
5030 L=LEN(F$)
5040 FOR I = 1 TO L
5050 C$=MID$(F$,I,1)
5060 IF C$>="a" AND C$ <="z" THEN C$=CHR$(ASC(C$)-32):MID$(F$,I,1)=C$
5070 NEXT I
5080 RETURN
jdrago
 
Posts: 3
Joined: May 30th, 2015, 9:46 pm

Re: A program to dump a hex file in octal

Postby gio74 » June 16th, 2015, 1:24 pm

thank you!
very useful, I will upload it on my altair today :)
gio74
 
Posts: 54
Joined: January 30th, 2015, 2:43 pm

Re: A program to dump a hex file in octal

Postby AltairClone » June 17th, 2015, 12:45 pm

Works great - thanks!

Mike
AltairClone
Site Admin
 
Posts: 632
Joined: April 5th, 2013, 10:55 am


Return to General Discussions

Who is online

Users browsing this forum: No registered users and 18 guests

cron