1 /* SPDX-License-Identifier: GPL-2.0-or-later */
4 * Copyright (C) 2017 Ake Rehnman
5 * ake.rehnman(at)gmail.com
8 ;; erase check memory code
12 start_addr: .byte 0x00
18 ; SP must point to start_addr on entry
19 ; first relocate start_addr to the location
24 ldw X,(start_addr+1,SP) ;start addr
25 ldw Y,(byte_cnt+1,SP) ;count
28 ; if count == 0 return
31 jrne .decrcnt ;continue if low word != 0
32 tnz (byte_cnt,SP) ;high byte
35 ; decrement count (byte_cnt)
37 tnzw Y ;low word count
39 dec (byte_cnt,SP) ;high byte
43 ; first check if [start_addr] is 0xff
47 jrne .exit ;exit if not 0xff
49 ; increment start_addr (addr)
52 inc (start_addr,SP) ;increment high byte
56 ldw (start_addr+1,SP),X ;start addr
57 ldw (byte_cnt+1,SP),Y ;count