Both sides previous revision
Previous revision
Next revision
|
Previous revision
Next revision
Both sides next revision
|
manual:chapter5:asm [2019/12/04 15:30] claudio [Flow control] |
manual:chapter5:asm [2019/12/05 14:03] jojo1973 [Simple assignments with operators] Added a particular syntax regarding register R |
| '':A=S2'' '':S2=S1'' '':S1=A'' | Swap stack level 1 with level 2 using register ''A'' as temporary storage. An error is raised if the stack contains less than 2 levels | | | '':A=S2'' '':S2=S1'' '':S1=A'' | Swap stack level 1 with level 2 using register ''A'' as temporary storage. An error is raised if the stack contains less than 2 levels | |
| '':C+=B^#2'' | Square the value register ''B'' and adds the result to register ''C'' | | | '':C+=B^#2'' | Square the value register ''B'' and adds the result to register ''C'' | |
| | '':B=R^#2 π'' | Assign ''%%'%%π^2%%'%%'' to register B. This example shows that register ''R'' must not necessarily be the second argument of a binary operator | |
| |
==== Assignment with math functions ==== | ==== Assignment with math functions ==== |
| '':PUSH.A.#3'' | Reverse of '':POP''. In this example will do '':P=C'', '':P=B'' and '':P=A'' | | | '':PUSH.A.#3'' | Reverse of '':POP''. In this example will do '':P=C'', '':P=B'' and '':P=A'' | |
| '':RPUSH.A.#3'' | Reverse of '':RPOP''. In this example will do '':P=A'', '':P=B'', and '':P=C'' | | | '':RPUSH.A.#3'' | Reverse of '':RPOP''. In this example will do '':P=A'', '':P=B'', and '':P=C'' | |
| | '':CLR.A.#3'' | Set registers to zero (clear) starting with ''A'', and as many registers as requested. In this example will do '':A=0'', '':B=0'' and '':C=0'' | |
| |
==== Example code ==== | ==== Example code ==== |
-103 SF @ Complex results | -103 SF @ Complex results |
:A=RPOP.S1.#3 @ Store coefficients in registers | :A=RPOP.S1.#3 @ Store coefficients in registers |
:CMP.A.#0 :D=CHK.EQ @ a=0? | :AND.A.C @ Are either zero? |
:CMP.C.#0 :E=CHK.EQ @ c=0? | :SKIP.NZ @ Skip next seco if both A and C were non-zero |
:OR.D.E @ Are either zero? | |
:SKIP.EQ @ Skip next seco if both tests were false | |
:: "Zero Input Invalid" | :: "Zero Input Invalid" |
DOERR @ Abort with error | DOERR @ Abort with error |