summaryrefslogtreecommitdiff
path: root/programs/sub-suite/test-size.s
blob: b543a364dd13fda2804f63bafcad5fa6031a8372 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
MAGIC = $AA


.org 0
findramend:
	and #0		; Reset A.
;	lda #MAGIC	; Set A to a magic number.
@loop:
	mov a, (d)	; Preserve the value.
	mov (d), #MAGIC	; Write the magic number to the current end of RAM.
	cmp (d), #MAGIC	; Is the value in RAM, the same as the magic number we wrote?
	bne @moveback	; No, so move back until we find the last writable memory location.
	mov (d), a	; Yes, so restore the previous value.
	add.w d, #$4000	; Increment the end of RAM pointer by 16K.
	bra @loop	; Keep looping.
@moveback:
	dec d		; Decrement the end of RAM pointer.
	mov a, (d)	; Preserve the value.
	mov (d), #MAGIC	; Write the magic number to the current end of RAM.
	cmp (d), #MAGIC	; Is the value in RAM, the same as the magic number we wrote?
	bne @moveback	; No, so keep looping.
	mov (d), a	; Yes, so restore the previous value.
@end:
	mov a, d	; Return the end of RAM pointer.
;	ple.q		; Restore E.
	rts		; End of findramend.


;findramend:
;	phe.q		; Preserve E.
;	phb.q		; Preserve B.
;	mov e, d	; Set E to the RAM pointer.
;	and #0		; Reset A.
;	lda #MAGIC	; Set A to a magic number.
;@loop:
;	ldb (e)		; Preserve the value.
;	sta (e)		; Write the magic number to the current end of RAM.
;	cmp (e)		; Is the value in RAM, the same as the magic number we wrote?
;	bne @moveback	; No, so move back until we find the last writable memory location.
;	stb (e)		; Yes, so restore the previous value.
;	ade.w #$4000	; Increment the end of RAM pointer by 16K.
;	bra @loop	; Keep looping.
;@moveback:
;	dee		; Decrement the end of RAM pointer.
;	ldb (e)		; Preserve the value.
;	sta (e)		; Write the magic number to the current end of RAM.
;	cmp (e)		; Is the value in RAM, the same as the magic number we wrote?
;	bne @moveback	; No, so keep looping.
;	stb (e)		; Yes, so restore the previous value.
;@end:
;	mov a, e	; Return the end of RAM pointer.
;	ple.q		; Restore E.
;	plb.q		; Restore B.
;	rts		; End of findramend.

a
.org findramend
v
q