home *** CD-ROM | disk | FTP | other *** search
- '*****************************************************
- ' This is an example of using PEEK to read the user
- ' specified contents of memory. READMEM.BAS
- '
- ' By: George Spafford Copyright 1993
- ' All Rights Reserved
- '
- ' No external libraries are required
- '
- ' v1.0 04/30/93
- '
- '*****************************************************
-
- DEFINT A-Z
-
- Title$ = "S3 Demo of Reading Memory v1.0 Copyright George Spafford 04/30/93"
- CLS
- PRINT Title$
- PRINT
- LOCATE 3, 40: PRINT "Specify a value preceded by &H if you"
- LOCATE 4, 40: PRINT "want to use hex numbers. For example"
- LOCATE 5, 40: PRINT "&H400 is 400H or 1024 integer."
- LOCATE 3, 1
-
- 'One neat ability of BASIC is its ability to have a hexadecimal value
- 'specified during input and convert it on the fly. In this example, I
- 'am not performing any error trapping. Usually, I input to a string,
- 'check and see if it is NULL and then exit the program. It serves as
- 'a back door for users who want to exit the program. Here, I am just
- 'inputting directly do an integer. If the user enters a hex value in the
- 'form of &Hnnnn, the program will use it. However, if they get carried
- 'away, they can cause an overflow condition by exceding the bounds of
- 'an integer.
-
- INPUT "Segment: ", Segment
- INPUT "Offset : ", Offset
- INPUT "Bytes : ", Length
-
- PRINT : PRINT
-
- DEF SEG = Segment 'set default segment to 0000
- FOR n = Offset TO (Offset + (Length - 1)) STEP 1 'start at offset and look at
- 'at the bytes
- T$ = HEX$(PEEK(n)) 'get the values at offset
- IF LEN(T$) = 1 THEN T$ = "0" + T$ 'HEX$ doesn't add "0" if
- 'it is the first byte.
- PRINT T$; " "; 'print it
- CharLine = CharLine + 1 'track hex codes one screen
- IF CharLine = 8 AND Length <> 8 THEN 'if 8 codes and user wanted
- 'more than eight, add hyphen
- PRINT "- ";
- END IF
- IF CharLine = 16 THEN 'if 16 codes on screen, then
- PRINT 'do a line feed
- CharLine = 0
- END IF
- NEXT n 'do next n
- DEF SEG 'return to BASIC segment
-
- PRINT
- END
-
-
-