Created
September 20, 2018 02:01
-
-
Save TedThompson/e7a79b48a7d98450f0ed49d5e31d712b to your computer and use it in GitHub Desktop.
Apple //e Applesoft BASIC program to convert HEX opcodes to decimal numbers for POKEing into memory
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
100 HOME | |
110 PRINT ">>HEXACON - HEX to DECicmal converter" | |
120 PRINT "_____________________________________" | |
130 PRINT | |
140 INVERSE : PRINT "MAKE SURE CAPS LOCK IS ON": NORMAL | |
150 PRINT "Enter one byte at a time." | |
160 PRINT "Enter - to back up and reenter data" | |
170 PRINT "Press ENTER key alone to end." | |
180 PRINT | |
190 DIM B$(255),C$(255):I = 1 | |
200 IF I < 1 THEN I = 1 | |
210 PRINT "BYTE ";I;: INPUT "->";A$ | |
220 IF A$ = "" THEN I = I - 1: GOTO 290 | |
230 IF A$ = "-" THEN PRINT "RE-ENTER ";:I = I - 1: GOTO 200 | |
240 IF LEN (A$) < > 2 THEN PRINT "INVALID": GOTO 200 | |
250 B$(I) = LEFT$ (A$,1):C$(I) = RIGHT$ (A$,1) | |
260 IF ASC (B$(I)) < 48 OR ASC (B$(I)) > 70 THEN PRINT "INVALID": GOTO 200 | |
270 IF ASC (B$(I)) < 65 AND ASC (B$(I)) > 57 THEN PRINT "INVALID": GOTO 200 | |
280 I = I + 1: GOTO 200 | |
290 IF I = 0 THEN END | |
300 HOME : PRINT "REVIEW-" | |
310 FOR L = 1 TO I: PRINT B$(L);C$(L); | |
320 IF L < > I THEN PRINT ","; | |
330 NEXT | |
340 PRINT : PRINT : PRINT "RESULT-": PRINT " DATA "; | |
350 FOR L = 1 TO I | |
360 IF ASC (B$(L)) > 57 THEN D1 = ASC (B$(L)) - 55 | |
370 IF ASC (B$(L)) < 58 THEN D1 = VAL (B$(L)) | |
380 D1 = D1 * 16 | |
390 IF ASC (C$(L)) > 57 THEN D1 = D1 + ( ASC (C$(L)) - 55) | |
400 IF ASC (C$(L)) < 58 THEN D1 = D1 + VAL (C$(L)) | |
410 PRINT D1; | |
420 IF I < > L THEN PRINT ","; | |
430 NEXT | |
440 PRINT : END |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment