2000-05-28 13:40:48 +00:00
|
|
|
;
|
|
|
|
; Ullrich von Bassewitz, 10.08.1998
|
|
|
|
;
|
|
|
|
; int DbgIsRAM (unsigned Addr);
|
|
|
|
;
|
|
|
|
|
2013-05-09 11:56:54 +00:00
|
|
|
.export _DbgIsRAM
|
|
|
|
.import popax, return0, return1
|
|
|
|
.importzp ptr1
|
2000-05-28 13:40:48 +00:00
|
|
|
|
|
|
|
_DbgIsRAM:
|
2013-05-09 11:56:54 +00:00
|
|
|
sta ptr1 ; Store the address
|
|
|
|
stx ptr1+1
|
2000-05-28 13:40:48 +00:00
|
|
|
|
2013-05-09 11:56:54 +00:00
|
|
|
ldy #0
|
|
|
|
php ; Save I flag
|
|
|
|
sei ; Disable interrupts
|
2000-05-28 13:40:48 +00:00
|
|
|
|
2013-05-09 11:56:54 +00:00
|
|
|
lda (ptr1),y ; Get old value
|
|
|
|
pha ; ...and save it
|
2000-05-28 13:40:48 +00:00
|
|
|
|
2013-05-09 11:56:54 +00:00
|
|
|
ldx #3
|
|
|
|
L1: lda TestVal,x
|
|
|
|
jsr CheckCell
|
|
|
|
bne L2
|
|
|
|
dex
|
|
|
|
bpl L1
|
2000-05-28 13:40:48 +00:00
|
|
|
|
|
|
|
; This seems to be RAM
|
|
|
|
|
2013-05-09 11:56:54 +00:00
|
|
|
pla
|
|
|
|
sta (ptr1),y ; Restore old value
|
|
|
|
plp ; Restore old I flag
|
|
|
|
jmp return1
|
2000-05-28 13:40:48 +00:00
|
|
|
|
|
|
|
; No RAM at this address
|
|
|
|
|
2013-05-09 11:56:54 +00:00
|
|
|
L2: pla
|
|
|
|
sta (ptr1),y ; Restore old value
|
|
|
|
plp ; Restore old I flag
|
|
|
|
jmp return0
|
2000-05-28 13:40:48 +00:00
|
|
|
|
|
|
|
; Check one memory cell
|
|
|
|
|
|
|
|
CheckCell:
|
2013-05-09 11:56:54 +00:00
|
|
|
sta (ptr1),y
|
|
|
|
cmp (ptr1),y ; Could we write it?
|
|
|
|
rts
|
2000-05-28 13:40:48 +00:00
|
|
|
|
|
|
|
|
|
|
|
.rodata
|
|
|
|
TestVal:
|
2013-05-09 11:56:54 +00:00
|
|
|
.byte $55, $AA, $33, $CC
|
2000-05-28 13:40:48 +00:00
|
|
|
|
|
|
|
|