Hi all, ok, now a version relying on the 20050511 snapshot (using .set,sprint,.ident). Now with elseif. This is now possible: and #10 if FALSE nop endif nop if x = #10 lda #10 elseif x = 20 lda #20 elseif x = 30 lda #30 else if Y lda #40 else lda #50 endif endif ldx 20 And here the macros: .PSC02 .code .macro else bra _endif .ifdef _else .ident(.sprintf("_else%x",q)): .else _else: .endif q .set q + 1 .endmacro .macro endif .ifdef _else .ident(.sprintf("_else%d",q)): .else _else: .endif _endif: .endscope .endmacro .macro elseif arg bra _endif .ifdef _else .ident(.sprintf("_else%x",q)): .else _else: .endif q .set q + 1 _if arg,.sprintf("%x",q) .endmacro .macro if arg .scope q .set 1 _if arg,"" .endmacro .macro _if arg,arg1 .if .blank(arg) .error "Macro 'if' needs parameter(s) !" .exitmacro .endif .if .tcount(arg) = 1 .if (.match(.mid(0,1,arg),A)) cmp #0 .elseif (.match(.mid(0,1,arg),X)) cpx #0 .elseif (.match(.mid(0,1,arg),Y)) cpy #0 .elseif .xmatch(arg,true) .or .xmatch(arg,TRUE) ;; empty .elseif .xmatch(arg,false) .or .xmatch(arg,FALSE) bne .ident(.concat("_else",arg1)) .exitmacro .else .error "Syntax: if (A|X|Y|FALSE|TRUE|false|true) !" .exitmacro .endif beq .ident(.concat("_else",arg1)) .exitmacro .elseif .tcount(arg) >= 3 .if .match(.mid(1,1,arg),=) .if .match(.mid(0,1,arg),A) cmp .right(.tcount(arg)-2,arg) .elseif .match(.mid(0,1,arg),X) cpx .right(.tcount(arg)-2,arg) .elseif .match(.mid(0,1,arg),Y) cpy .right(.tcount(arg)-2,arg) .else .error "Syntax: if (A|X|Y) = expr" .exitmacro .endif bne .ident(.concat("_else",arg1)) .exitmacro .elseif .match(.mid(1,1,arg),!) .and .match(.mid(2,1,arg),=) .if .match(.mid(0,1,arg),A) cmp .right(.tcount(arg)-3,arg) .elseif .match(.mid(0,1,arg),X) cpx .right(.tcount(arg)-3,arg) .elseif .match(.mid(0,1,arg),Y) cpy .right(.tcount(arg)-3,arg) .else .error "Syntax: if (A|X|Y) != expr" .exitmacro .endif beq .ident(.concat("_else",arg1)) .exitmacro .else .error "Wrong if usage" .exitmacro .endif .else .error "Wrong if usage" .endif .endmacro -- 42Bastian Schick ---------------------------------------------------------------------- To unsubscribe from the list send mail to majordomo@musoftware.de with the string "unsubscribe cc65" in the body(!) of the mail.Received on Wed May 11 11:35:29 2005
This archive was generated by hypermail 2.1.8 : 2005-05-11 11:35:31 CEST