Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current Restore this Version View Page History

« Previous Version 2 Next »

The Hex dump program below was originally published to the EPROM User group. It is of note as it provides a worked example of the in-line assembler abilities of the BBC Basic application.

   10 REM **********************************
   20 REM Hexdump (C) Danny Langton        *
   30 REM Aware Technology, DECEMBER 1988  *
   40 REM TO BE TREATED AS PUBLIC DOMAIN   *
   50 REM I.E. COPY AND USE BUT DON'T SELL *
   60 REM **********************************
   70 PROCassemble
   80 REPEAT
   90   CLS:REPEATINPUT''"Name of file to dump : "'"(Use [ESCAPE] to quit)"SPC10""D$:UNTILLEND$
  100   X=OPENIN D$:IFX=0PRINT'"That file does not exist":GOTO90
  110   PRINT"Use UP and DOWN cursor keys to move through file"'"a line at a time,"'"[SHIFT] and cursor keys for a page at a time"'"and [DEL] to quit":TIME=0:REPEATUNTILTIME>300
  120   L%=0
  130   CLS
  140   REPEAT
  150     PROCdump(L%)
  160     CALL flush
  170     G%=GET:IFG%=0 G%=GET
  180     L%=L%+(G%=255)*16+(G%=251)*112-(G%=254)*16-(G%=250)*112
  190     IF G%=246 L%=EXT#X-96-(EXT#X)MOD16
  200     IF L%<0 OR L%>EXT#X OR G%=247L%=0
  210   UNTILG%=127
  220 UNTIL0
  230 :
  240 DEFPROCdump(L%)
  250 CLS
  260 PTR#X=L%
  270 IFEXT#X-L%<112 F%=EXT#X-L% ELSE F%=112
  280 R%=0:C%=0
  290 PRINTTAB(0,0)STRING$(8-LENSTR$~L%,"0")STR$~L%
  300 FOR M%=L% TO L%+F%-1
  310   IFR%=7GOTO360
  320   N%=BGET#X:N$=STR$~N%:IF LEN N$=1 N$="0"+N$
  330   PRINTTAB(12+C%*3,R%)N$TAB(64+C%,R%);
  340   IFN%>31 AND N%<127 PRINTCHR$N%; ELSE PRINT".";
  350   C%=C%+1:IFC%=16 C%=0:R%=R%+1:IFR%<7PRINTTAB(0,R%)STRING$(8-LENSTR$~(L%+R%*16),"0")+STR$~(L%+R%*16)
  360 NEXT
  370 ENDPROC
  380 :
  390 DEFPROCassemble
  400 DIMflush 50
  410 FORpass=0TO2STEP2
  420   P%=flush
  430   [OPT pass
  440   LD HL,0:ADD HL,SP:LD SP,(&1FFE):PUSH HL:CALL main:POP HL:LD SP,HL:RET
  450   .main
  460   RST &20
  470   DEFB &33
  480   RET
  490   ]
  500 NEXT
  510 ENDPROC
  520 :