Skip to navigation


Version analysis of ZES2

This code appears in the following versions (click to see it in the source code):

Code variations between these versions are shown below.

Name: ZES2 Type: Subroutine Category: Utility routines Summary: Zero-fill a specific page

Code variation 1 of 5A variation in the comments only

Tap on a block to expand it, and tap it again to revert.

Zero-fill from address (X SC) + Y to (X SC) + &FF.
Zero-fill from address (X SC) to (X SC) + Y.
Zero-fill from address SC(1 0) + Y to SC(1 0) + &FF.

Arguments:

Code variation 2 of 5A variation in the comments only

This variation is blank in the Disc (flight) and Electron versions.

X The high byte (i.e. the page) of the starting point of the zero-fill

Code variation 3 of 5A variation in the comments only

Tap on a block to expand it, and tap it again to revert.

Y The offset from (X SC) where we start zeroing, counting up to &FF
Y The offset from (X SC) where we start zeroing, counting down to 0
SC The low byte (i.e. the offset into the page) of the starting point of the zero-fill
Returns: Z flag Z flag is set
.ZES2

Code variation 4 of 5Other (e.g. bug fix, optimisation)

The disc version's flight code has a different ZES2 routine - it still zero-fills a part of a page, but it fills the opposite part of the page to the other versions.

See below for more variations related to this code.

This variation is blank in the Disc (flight) version.

Tap on a block to expand it, and tap it again to revert.

LDA #0 \ Load A with the byte we want to fill the memory block \ with - i.e. zero STX SC+1 \ We want to zero-fill page X, so store this in the \ high byte of SC, so the 16-bit address in SC and \ SC+1 is now pointing to the SC-th byte of page X
LDA #0 \ Load A with the byte we want to fill the memory block \ with - i.e. zero
.ZEL1

 STA (SC),Y             \ Zero the Y-th byte of the block pointed to by SC,
                        \ so that's effectively the Y-th byte before SC

Code variation 5 of 5Other (e.g. bug fix, optimisation)

See variation 4 above for details.

Tap on a block to expand it, and tap it again to revert.

INY \ Increment the loop counter
DEY \ Decrement the loop counter
 BNE ZEL1               \ Loop back to zero the next byte

 RTS                    \ Return from the subroutine