macros.inc

     1:  ; htasc - set the hi bit on the last byte of a string for termination
     2:  ; (by Tom Greene)
     3:  .macro htasc str
     4:          .repeat .strlen(str)-1,I
     5:                  .byte   .strat(str,I)
     6:          .endrep
     7:          .byte   .strat(str,.strlen(str)-1) | $80
     8:  .endmacro
     9:  
    10:  .macro htasc_floppy_error str
    11:          .byte   .strat(str,0) | $80
    12:          .repeat .strlen(str)-2,I
    13:                  .byte   .strat(str,I + 1)
    14:          .endrep
    15:          .byte   .strat(str,.strlen(str)-1) | $80
    16:  .endmacro
    17:  
    18:  ; For every token, a byte gets put into segment "DUMMY".
    19:  ; This way, we count up with every token. The DUMMY segment
    20:  ; doesn't get linked into the binary.
    21:  .macro init_token_tables
    22:          .segment "VECTORS"
    23:  TOKEN_ADDRESS_TABLE:
    24:          .segment "KEYWORDS"
    25:  TOKEN_NAME_TABLE:
    26:                  .segment "DUMMY"
    27:  DUMMY_START:
    28:  .endmacro
    29:  
    30:  ; optionally define token symbol
    31:  ; count up token number
    32:  .macro define_token token
    33:          .segment "DUMMY"
    34:                  .ifnblank token
    35:  token := <(*-DUMMY_START)+$80
    36:                  .endif
    37:                  .res 1; count up in any case
    38:  .endmacro
    39:  
    40:  ; lay down a keyword, optionally define a token symbol
    41:  .macro keyword key, token
    42:                  .segment "KEYWORDS"
    43:                  htasc   key
    44:                  define_token token
    45:  .endmacro
    46:  
    47:  ; lay down a keyword and an address (RTS style),
    48:  ; optionally define a token symbol
    49:  .macro keyword_rts key, vec, token
    50:          .segment "VECTORS"
    51:                  .word   vec-1
    52:                  keyword key, token
    53:  .endmacro
    54:  
    55:  ; lay down a keyword and an address,
    56:  ; optionally define a token symbol
    57:  .macro keyword_addr key, vec, token
    58:          .segment "VECTORS"
    59:                  .addr   vec
    60:                  keyword key, token
    61:  .endmacro
    62:  
    63:  .macro count_tokens
    64:          .segment "DUMMY"
    65:  NUM_TOKENS := <(*-DUMMY_START)
    66:  .endmacro
    67:  
    68:  .macro init_error_table
    69:          .segment "DUMMY"
    70:  DUMMY_START_ERROR:
    71:  
    72:          .segment "ERROR"
    73:  ERROR_MESSAGES:
    74:  .endmacro
    75:  
    76:  .ifdef CBM2_EXT_FILE_ERRORS
    77:   .macro define_error_token token
    78:          .segment "DUMMY"
    79:                  .ifnblank token
    80:  token := <(*-DUMMY_START_ERROR + 1)
    81:                  .endif
    82:                  .res 1; count up in any case
    83:   .endmacro
    84:  
    85:   .macro define_error error, msg, addr
    86:          .segment "ERROR"
    87:  addr := *
    88:                  htasc msg
    89:                  define_error_token error
    90:   .endmacro
    91:  
    92:  .else
    93:   .macro define_error error, msg, addr
    94:          .segment "ERROR"
    95:  error := <(*-ERROR_MESSAGES)
    96:                  htasc msg
    97:   .endmacro
    98:  
    99:  .endif
   100:  
   101:  ;---------------------------------------------
   102:  ; set the MSB of every byte of a string
   103:  .macro asc80 str
   104:          .repeat .strlen(str),I
   105:                  .byte   .strat(str,I)+$80
   106:          .endrep
   107:  .endmacro
   108:  
Valid XHTML 1.0 Strict
macros.inc.html; generated on Fri Sep 18 21:44:54 2015 by ca65html
uz@cc65.org