antoine-source/appleworksgs/Macros/m16.bob

1 line
10 KiB
Plaintext
Raw Normal View History

2023-03-04 02:45:20 +00:00
;..............................................................................; ; ; If - expression, test, value, goto ; ; This macro implements an if construct. The expression will be evaluated, ; its value compared to the given value, and if the test succeeds execution ; continues at 'goto'. Otherwise execution will continue until an EndWhile ; macro is encountered. ; ; The expression may be a register, simple variable, or complex expression. ; If the 'goto' label is preceeded by a '!' then it is assumed that a long ; branch is necessary. ; ; Sample calls: ; ; If X,'<>',#50,DoneIf - if x<>50 then goto DoneIf ; If Var1,'=',Var2,!DoneIf - if var1=var2 then branch long to DoneIf ; If '(Var1.+Var2)','>',Var3,Quit - if var1+var2>var3 then goto Quit ; ; The following test conditions are supported and must be quoted: ; ; '=', '>', '>=', '<', '<=', '<>' ; ; A complex expression must be quoted and placed in paranthesis to work ; correctly. ; ;..............................................................................; MACRO &lab IF_ &exp,&test,&value,&goto &lab ; lclc &cc lclc &first lclc &newexp lclc &WorkAroundApplesBuggyAssembler &newexp setc &exp &first setc &substr(&newexp,1,1) IF (&newexp = 'x') or (&newexp = 'y') or (&newexp = 'a') GOTO .register IF (&newexp = 'X') or (&newexp = 'Y') or (&newexp = 'A') GOTO .register IF (&first = '(') GOTO .expression .simplevar lda &newexp cmp &value GOTO .dotest mexit .expression &newexp setc &substr(&newexp,2,&len(&newexp)-2) eval &newexp cmp &value GOTO .dotest .register &WorkAroundApplesBuggyAssembler setc &concat('cp',&newexp) .; cp&newexp &value **SIGH!!!!!!** &WorkAroundApplesBuggyAssembler &value GOTO .dotest .dotest IF (&test = '=') GOTO .doeq IF (&test = '<') GOTO .dolt IF (&test = '>=') GOTO .doge IF (&test = '<>') GOTO .done IF (&test = '<=') GOTO .dole IF (&test = '>') GOTO .dogt IF (&test = '<27>') GOTO .dole IF (&test = '<27>') GOTO .doge IF (&test = '<27>') GOTO .done macerr 'IF_: unrecognized comparison <20>',&test,'<27> (make sure it's not in quotes).' mexit .doeq &cc setc 'eq' GOTO .goto .dolt &cc setc 'lt' GOTO .goto .doge &cc setc 'ge' GOTO .goto .done &cc setc 'ne' GOTO .goto .dole &cc setc 'le' GOTO .goto .dogt &cc setc 'gt' GOTO .goto mexit .goto jump &cc,&goto mexit MEND ;..............................................................................; ; ; jump - Branch on condition code to short/long label ; ; Generic jump macro. If label starts with ! will do long jump else short. ; ;..............................................................................; MACRO &lab jump &cc,&label &lab ; lclc &a &a setc &substr(&label,1,1) IF (&a = '!') GOTO .long b&cc &label mexit .long &a setc &substr(&label,2,&len(&label)-1) j&cc &a mexit MEND ;..............................................................................; ; ; While - expression, test, value, resume ; ; This macro implements a while construct. The expression will be evaluated, ; its value compared to the given value, and if the test fails execution will ; continue at 'resume'. Otherwise execution will continue until an EndWhile ; macro is encountered. ; ; The expression may be a register, simple variable, or complex expression. ; If the 'resume' label is preceeded by a '!' then it is assumed that a long ; branch is necessary. ; ; Sample calls: ; ; While X,'<>',#50 - loop until x register = 50 ; While Var1,'=',Var2 - loop until var1<>var2, then jump long ; While '(Var1.+Var2)','>',Var3 - loop until var1+var2<=var3 ; ; The following test conditions are supported and must be q