I fixed a typo in the down comparison. I had two #< LSB constants. Now its:
Code:
lda p+0 ; L150
cmp #<33648
lda p+1
sbc #>33648
The 'equ' (or .equ) directive (equate) defines a symbol (p in this case) to have a specific value. I set p to $20, an address on zero page than is used as a pointer into the video RAM area. Some assemblers use '=' but that often creates a symbol you can change later on (X = X+1). A symbol created with equate can usually not be changed.
My own 6502 assembler generates code for control structures like if/then/else and loops. You could write this code like this:
Code:
.6502
00000020 = p .equ $20
00001234 = chrout .equ $1234 ; Address of print subroutine
.code
.org $2000
00:2000 A993 : lda #147 ; L100
00:2002 203412 : jsr chrout
00:2005 A927 : lda #<32807 ; L110
00:2007 8520 : sta p+0
00:2009 A980 : lda #>32807
00:200B 8521 : sta p+1
repeat
00:200D A000 : ldy #0 ; L120
00:200F A9FE : lda #254
00:2011 9120 : sta (p),y
00:2013 A028 : ldy #40
00:2015 A961 : lda #97
00:2017 9120 : sta (p),y
00:2019 A050 : ldy #80
00:201B A9FB : lda #251
00:201D 9120 : sta (p),y
repeat
00:201F A597 : lda 151 ; L140/150 PEEK tests
00:2021 C932 : cmp #50
00:2023 D01E : if eq
00:2025 A520 : lda p+0 ; L140
00:2027 C94E : cmp #<32846
00:2029 A521 : lda p+1
00:202B E980 : sbc #>32846
00:202D 3011 : if pl
00:202F A050 : ldy #80
00:2031 A920 : lda #32
00:2033 9120 : sta (p),y
00:2035 38 : sec
00:2036 A520 : lda p+0
00:2038 E928 : sbc #40
00:203A 8520 : sta p+0
00:203C B002 : if cc
00:203E C621 : dec p+1
endif
endif
00:2040 4C6820 : break
endif
00:2043 C912 : cmp #18
00:2045 D01E : if eq
00:2047 A520 : lda p+0 ; L150
00:2049 C970 : cmp #<33648
00:204B A521 : lda p+1
00:204D E983 : sbc #>33648
00:204F 1011 : if mi
00:2051 A000 : ldy #0
00:2053 A920 : lda #32
00:2055 9120 : sta (p),y
00:2057 18 : clc
00:2058 A520 : lda p+0
00:205A 6928 : adc #40
00:205C 8520 : sta p+0
00:205E 9002 : if cs
00:2060 E621 : inc p+1
endif
endif
00:2062 4C6820 : break
endif
00:2065 4C1F20 : forever
00:2068 4C0D20 : forever