FinalZero wrote:Code: Select all
load_font:
lda #font&255
sta addy
lda #font/256
sta addy+1
ldx #3
ldy #0
What do the first two lda's do? I don't understand the #font& and #font/ parts. Does a preceding # mean? Can that character be left out?
As tepples described, the "#" character means immediate addressing -- think "literal value". More on that in a sec.
The &255 and /256 syntax appears to be a bunch of nonsense for getting the low and high bytes of the 16-bit address of a label (in this case, the low and high bytes, respectively, of font). I call it nonsense because
there's some history indicating only devel builds of ca65 support the .LOBYTE and "<" directives, as well as .HIBYTE and ">" directives. God I hate that assembler. I seriously don't understand why people bother with it.
Here's a more much more common syntax you'll see, and makes a lot more sense IMHO:
Code: Select all
lda #<font
sta addy
lda #>font
sta addy+1
In English: if font is located at location $894F, then the first LDA will load the value $4F into the accumulator, while the second LDA would load $89. If you removed use of immediate addressing, you'd have:
Code: Select all
lda <font
sta addy
lda >font
sta addy+1
In English: if font is located at $894F, then the first LDA will load the value stored in memory at location $4F into the accumulator, while the second LDA would do the same but for from location $89.
FinalZero wrote:By the way, is there a way of doing multiline comments like /* */ in C? Or must one prefix every line with a semicolon?
There's no "universal standard" for this. It's important to understand that assembler syntaxes vary greatly depending on the assembler, and it's your responsibility to learn/read up on what your assembler-of-choice supports. You should never assume that an assembler has something even remotely "C-like" in it.
Generally speaking, most assemblers assume that anything past (and including) a semicolon are comments. Example:
Code: Select all
some_code ; in-line comment
some_code ; hello world
some_code ; i like rice
;
; Below code rides snakes around Arabia, or Persia,
; or China, or tepple's living room.
;
some_code
some_code
...
Some assemblers support things like the .COMMENT and .ENDCOMMENT pseudo-directives, which would act more like a /* */ block-style comment in C. E.g.:
Code: Select all
.COMMENT
Below code rides snakes around Arabia, or Persia,
or China, or tepple's living room.
.ENDCOMMENT
some_code
some_code
...
But again, there's no "standard" -- you need to read the documentation associated with your assembler to find out. If there is no documentation, don't bother using that assembler.
Hope this helps. Cheers!