Entry
BBCBASIC: Windows:Memory:Operation:Get:Can you give simple program to read all characters in memory?
Nov 18th, 2006 02:06
Knud van Eeden,
----------------------------------------------------------------------
--- Knud van Eeden --- 21 September 2020 - 10:20 pm ------------------
BBCBASIC: Windows:Memory:Operation:Get:Can you give simple program to
read all characters in memory?
Idea:
You start from the beginning of the memory
and you keep reading characters
until you encounter the end of memory marker.
===
BNF
(program in memory) is
(zero or one begin marker)
followed by (zero or more characters)
followed by (one end marker)
===
Regular expression
(program in memory) = (begin marker)? (character)* (end of memory
marker)
===
or written in shorthand
P = B? C* E
where
P = program
B = begin of program in memory marker
? = zero or one
C = characer
* = zero or more
E = end of program in memory marker
===
or written as a BNF diagram
+----<----+
| |
P = ->-+-(B)-+->-+->-(C)->-+->-(E)->-
| | | |
+-->--+ +---->----+
===
because there is no begin marker here, you
can reduce this to
P = C* E
===
or written as a diagram
+----<----+
| |
P = ->-+->-(C)->-+->-(E)->-
| |
+---->----+
===
or written in pseudo code
WHILE NOT (E)
(C)
ENDWHILE
(E)
===
state diagram
'memory read all characters' =
+---<-----------+
| |
->-[goto begin of memory]->-+-[read char]->-+->-[found end memory]->-
| |
+--->-----------+
===
Steps: Overview:
1. -E.g. create the following program
--- cut here: begin --------------------------------------------------
REM --- MAIN --- REM
PROCMemoryGetCharacterReadAllSimple( PAGE )
END
:
:
:
REM --- LIBRARY --- REM
:
REM library: memory: get: character: read: all: simple [kn, ri, tu,
24-10-2020 22:15:26]
DEF PROCMemoryGetCharacterReadAllSimple( minI% )
REM e.g. PROCMemoryGetCharacterReadAllSimple( PAGE )
REM e.g. END
REM e.g. :
REM e.g. :
REM e.g. :
LOCAL I%
REM goto begin of program in memory
I% = minI%
REM
REM no begin marker
REM
REM while not found end marker
WHILE NOT ( ?I% = 0 AND ?(I% + 1 ) = 255 AND ?( I% + 2 ) = 255 )
PRINT; ?I%; " "; : REM get byte
I% = I% + 1 : REM goto next byte
ENDWHILE
PRINT; ?I%; " "; : PRINT; ?( I% + 1 ); " "; : PRINT; ?( I% + 2 ) :
REM get end marker
ENDPROC
--- cut here: end ----------------------------------------------------
2. -Running this program will e.g. output (print) all the characters
(bytes) starting from a given memory position until the end of
program marker (e.g. for a tokenized program, this is 0, followed
by 255, followed by 255), is found
--- cut here: begin --------------------------------------------------
22 0 0 244 32 45 45 45 32 77 65 73 78 32 45 45 45 32 82 69 77 13 4 0 0
13 41 0 0 242 77 101 109 111 114 121 71 101 116 67 104 97 114 97 99
116 101 114 82 101 97 100 65 108 108 83 105 109 112 108 101 40 32 144
32 41 13 5 0 0 224 13 5 0 0 5 8 13 5 0 0 58 13 5 0 0 58 13 4 0 0 13 25
0 0 244 32 45 45 45 32 76 73 66 82 65 82 89 32 45 45 45 32 82 69 77 13
5 0 0 5 8 13 90 0 0 244 32 108 105 98 114 97 114 121 58 32 109 101 109
111 114 121 58 32 103 101 116 58 32 99 104 97 114 97 99 116 101 114 58
32 114 101 97 100 58 32 97 108 108 58 32 115 105 109 112 108 101 32 91
107 110 44 32 114 105 44 32 116 1 17 44 32 50 52 45 49 48 45 50 48 48
54 32 50 50 58 49 53 58 50 54 93 13 47 0 0 221 32 242 77 101 109 111
114 121 71 101 116 67 104 97 114 97 99 116 101 114 82 101 97 100 65
108 108 83 105 109 112 108 101 40 32 109 105 110 73 37 32 41 13 5 4 0
0 244 32 101 46 103 46 32 80 82 79 67 77 101 109 111 114 121 71 101
116 67 104 97 114 97 99 116 101 114 82 101 97 1 00 65 108 108 83 105
109 112 108 101 40 32 80 65 71 69 32 41 13 14 0 0 244 32 101 46 103 46
32 69 78 68 13 12 0 0 244 3 2 101 46 103 46 32 58 13 12 0 0 244 32 101
46 103 46 32 58 13 12 0 0 244 32 101 46 103 46 32 58 13 8 0 0 234 32
73 37 1 3 37 0 0 244 32 103 111 116 111 32 98 101 103 105 110 32 111
102 32 112 114 111 103 114 97 109 32 105 110 32 109 101 10 9 111 114
121 13 14 0 0 73 37 32 61 32 109 105 110 73 37 13 32 0 0 244 32 119
104 105 108 101 32 110 111 116 32 102 111 117 110 100 32 101 110 100
32 109 97 114 107 101 114 13 58 0 0 199 32 172 32 40 32 63 73 37 32 61
32 48 32 128 32 63 4 0 73 37 32 43 32 49 32 41 32 61 32 50 53 53 32
128 32 63 40 32 73 37 32 43 32 50 32 41 32 61 32 50 53 53 32 41 13 29
0 0 241 59 32 63 73 37 59 32 34 32 34 59 32 58 32 244 32 103 101 116
32 98 121 116 101 13 34 0 0 73 37 32 61 32 73 37 32 43 32 49 32 58 32
244 32 103 111 116 111 32 110 101 120 116 32 98 121 116 101 13 5 0 0
206 13 75 0 0 241 59 32 63 73 37 59 32 34 32 34 59 32 58 32 241 59 32
63 40 32 73 37 32 43 32 49 32 41 59 32 34 32 34 59 32 58 32 241 59 32
63 40 32 73 37 32 43 32 50 32 41 32 58 32 244 32 103 101 116 32 101
110 100 32 109 97 114 107 101 114 13 5 0 0 225 13 0 255 255
--- cut here: end ----------------------------------------------------
===
Internet: see also:
---
----------------------------------------------------------------------