I am just hanging over the memory test routine in the Sinclair rom but can not understand the principles of this test software.
Code could be from Microsoft.
Code: Select all
;; RAM-CHECK
L03CB: LD H,B ;
LD L,C ;
LD A,$3F ;
;; RAM-FILL
L03CF: LD (HL),$02 ;
DEC HL ;
CP H ;
JR NZ,L03CF ; to RAM-FILL
;; RAM-READ
L03D5: AND A ;
SBC HL,BC ;
ADD HL,BC ;
INC HL ;
JR NC,L03E2 ; to SET-TOP
DEC (HL) ;
JR Z,L03E2 ; to SET-TOP
DEC (HL) ;
JR Z,L03D5 ; to RAM-READ
;; SET-TOP
L03E2: LD ($4004),HL ; set system variable RAMTOP to first byte
; above the BASIC system area.
What I do not understand is the sense of writing $02 into memory cells and after decrementing it two times after each other.
So after first DEC (HL) it is testing if it's not zero. But how could it be zero, when filled with $02 ?
So the only chance to meet this condition is when reading back is $01 instead of $02.
When it is testing for $FF I could understand for checking of non-existing RAM.
It doesn't use any march algorythm.
So what's the heck about ?
Second. Why does it always do SBC HL,BC and after ADD HL,BC ?
Okay it checks if it is reaching maybe getting in ROM address area but why does it this about 16384 times when having 16k RAM ?
Could be more easy done with simply
Code: Select all
INC HL
CP H
JR Z,end-of-memtest
Any ideas ?