It is currently Wed Oct 18, 2017 8:51 pm

All times are UTC - 7 hours



Forum rules


Related:



Post new topic Reply to topic  [ 16 posts ]  Go to page Previous  1, 2
Author Message
PostPosted: Tue Jun 21, 2016 10:51 am 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 5718
Location: Canada
The only time I seem to use * in my code is with asserts.

Most often I use it to verify that I didn't make a mistake when creating a table (same as the "sizeof" idiom):
Code:
TABLE_SIZE = 30
table:
.byte 1,2,3,4,5,6,7,8,9
.byte 5,6,7,8,9
.assert (*-table) = TABLE_SIZE, error, "incorrect number of entries in table"


Sometimes I use it to verify code page alignment when specific timing is needed:
Code:
label:
   lda #1
   sta nmi_lock
   :
      bit $2002
      bvs :-
   :
      bit $2002
      bmi @fail
      bvc :-
   lda #0
   sta $2005
   sta $2006
   .assert (* & $FF00) = (label & $FF00), error, "code crosses page boundary"


Note that * is just a way of creating a temporary label for the current line, i.e. you can do the same stuff with a regular label:
Code:
SpriteBuf1: .res $200
SpriteBuf1End:
SpriteBuf1Size = SpriteBuf1End - SpriteBuf1


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 16 posts ]  Go to page Previous  1, 2

All times are UTC - 7 hours


Who is online

Users browsing this forum: 93143 and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group