Am Dienstag, den 13.11.2018, 15:53 +0000 schrieb Jan Kromhout: > Hello, > > I are struggle with the buffer: > As you can see I create two array’s. > I expect that when I initialize this I can read the value. > It's not true. As you can see, values are overwritten. > Am I doing something wrong?
I'm pretty sure that all the cells are not what you want. At least the definition of the buffer does not match their usage: > \ Segment byte maps for numbers 0 to 9 > 10 buffer: Segment_Map_Digit This is 10 bytes, not 10 cells. > : Segment_Map_Digit@ cells Segment_Map_Digit + c@ ; Here you turn a number into a cell-index and access a single byte. The upper half of the cell is not used : initSegment_Map_Digit > \ Segment byte maps for numbers 0 to 9 > $c0 0 Segment_Map_Digit! > $f9 1 Segment_Map_Digit! > $a4 2 Segment_Map_Digit! > $b0 3 Segment_Map_Digit! > $99 4 Segment_Map_Digit! The last position inside your buffer. > $92 5 Segment_Map_Digit! > $82 6 Segment_Map_Digit! > $f8 7 Segment_Map_Digit! > $80 8 Segment_Map_Digit! > $90 9 Segment_Map_Digit! A classic buffer overflow. You access memory outside the buffer (9 cells is 18, which is beyond the 10 bytes allocated) Matthias _______________________________________________ Amforth-devel mailing list for http://amforth.sf.net/ Amforth-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/amforth-devel