manual:chapter5:asm

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revision Both sides next revision
manual:chapter5:asm [2019/12/03 15:39]
claudio [Tests]
manual:chapter5:asm [2019/12/04 15:36]
claudio [Example code]
Line 37: Line 37:
 |  :::  |  :::  | ''ASIN''  |  :::  |  :::  | ''MAX''  | |  :::  |  :::  | ''ASIN''  |  :::  |  :::  | ''MAX''  |
 |  :::  |  :::  | ''ACOS''  |  :::  |  :::  | ''RND''  | |  :::  |  :::  | ''ACOS''  |  :::  |  :::  | ''RND''  |
-|  :::  |  :::  | ''ATAN'' |  :::  |  :::  |    +|  :::  |  :::  | ''ATAN'' |  :::  |  :::  | ''CLR''  
-|  :::  |  :::  | ''SINH''  |  :::  |  :::  |  :::  +|  :::  |  :::  | ''SINH''  |  :::  |  :::  |   
-|  :::  |  :::  | ''COSH''  |  :::  |  :::  |  :::  |+|  :::  |  :::  | ''COSH''  |  :::  |  :::  |    |
 |  :::  |  :::  | ''TANH''  |  :::  |  :::  |  :::  | |  :::  |  :::  | ''TANH''  |  :::  |  :::  |  :::  |
 |  :::  |  :::  | ''ASINH''  |  :::  |  :::  |  :::  | |  :::  |  :::  | ''ASINH''  |  :::  |  :::  |  :::  |
Line 99: Line 99:
 | ''AL''    | Always                 | ---       | ---       | | ''AL''    | Always                 | ---       | ---       |
 | ''LT''    | Less Than              | ---       | Set       | | ''LT''    | Less Than              | ---       | Set       |
-| ''EQ''    | Equals                 | Set       | ---       | +| ''EQ'' or ''Z''  | Equals                 | Set       | ---       | 
-| ''LTE''   | Less Than or Equals    | ---       | Set       |+| ''LE''    | Less Than or Equals    | ---       | Set       |
 | :::       | :::                    | Set       | ---       | | :::       | :::                    | Set       | ---       |
 | ''NA''    | Never                  | ---       | ---       | | ''NA''    | Never                  | ---       | ---       |
-| ''GTE''   | Greater Than or Equals | ---       | Clear     | +| ''GE''    | Greater Than or Equals | ---       | Clear     | 
-| ''NE''    | Not Equals             | Clear     | ---       |+| ''NE'' or ''NZ''  | Not Equals             | Clear     | ---       |
 | ''GT''    | Greater Than           | Clear     | Clear     | | ''GT''    | Greater Than           | Clear     | Clear     |
  
 ---- ----
  
-| '':SKIP.EQ''  | Skip next instruction if the result of last comparison was //Equals// +| '':SKIP.EQ''  | Skip next instruction if the state of the flags was //Equals// 
-| '':LOOP.LTE''  | Must be followed by a program ''« ... »'' or a secondary '':: ... ;''. Repeat the object that follows while the result of the last comparison is //Less Than or Equals//. Notice the program or secondary that follows **must** update the internal flags with a '':CMP.[Y].[Z]'' statement or it will loop indefintely  | +| '':LOOP.LE''  | Must be followed by a program ''« ... »'' or a secondary '':: ... ;''. Repeat the object that follows while the state of the flags is //Less Than or Equals//. Notice the program or secondary that follows **must** update the internal flags with a '':CMP.[Y].[Z]'' or other test statement or it will loop indefinitely  | 
-| '':FPUSH.GT'' Push True (''1''to the stack if the result of the last comparison is //Greater Than//, otherwise push False (''0'' |+| '':A=CHK.GT'' Results in true (''1'') if the state of flags is //Greater Than//, otherwise results in False (''0''). Result may be stored into a register or pseudo-register. If the result is not stored, flags will be affected accordingly  |
  
-The ''FPUSH'' command is useful to combine assembly-like statements into **newRPL** flow control structures. For example<code>+The ''CHK'' command is useful to combine assembly-like statements into **newRPL** flow control structures. For example<code>
 « IF  « IF 
-    :CMP.A.#0 +    :CMP.A.#3    @@ COMPARE A WITH 3 
-    :FPUSH.EQ+    :P=CHK.EQ    @@ AND CHECK IF IT'S EQUAL, PUSHING TRUE/FALSE TO THE STACK
   THEN   THEN
     ...     ...
Line 133: Line 133:
 | '':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 ====
Line 146: Line 147:
   -103 SF             @ Complex results   -103 SF             @ Complex results
   :A=RPOP.S1.#      @ Store coefficients in registers   :A=RPOP.S1.#      @ Store coefficients in registers
-  :CMP.A.#0 :FPUSH.EQ @ a=0? Push test on the stack +  :AND.A.C            @ Are either zero? 
-  :CMP.C.#0 :FPUSH.EQ @ c=0? Push test on the stack +  :SKIP.NZ            @ Skip next seco if both A and C were non-zero
-  OR                  @ Are either zero? +
-  :CMP.S1.#1 DROP     @ Turn newRPL boolean into flags and discard it +
-  :SKIP.NE            @ Skip next seco if false+
   :: "Zero Input Invalid"   :: "Zero Input Invalid"
      DOERR            @ Abort with error      DOERR            @ Abort with error
   ;   ;
-  :P=#0-B             Push -B on stack +  :D=#0-B             @ -B 
-  DUP SQ              -B, B^2 +  :E=B*B              @ B^2 
-  :S1*=A :S1*=C     @ -B, B^24*A*C +  :F=#4*A :F*=C       4*A*C 
-  - √                 @ -B√(B^2-4*A*C) +  :E-=F   :E=SQRT.E   @ √(B^2-4*A*C) 
-  :P=B SIGN *       @ -B-SIGN(B)*√(B^2-4*A*C) +   
-  2 / :S1/=A          @ (-B-SIGN(B)*√(B^2-4*A*C))/2/A is R1, the largest root in absolute value +  :CMP.B.#0 
-  :P=C :S1/=        @ R1, C/A+  :SKIP.GE :F=D+E     @ -B+√(B^2-4*A*C) when B<=0 
 +  :SKIP.LT :F=D-E     @ -B-√(B^2-4*A*C) when B>0 
 +   
 +  :E=A*#2             @ 2*A 
 +  :P=F/             @ (-B-SIGN(B)*√(B^2-4*A*C))/2/A is R1, the largest root in absolute value 
 +  :P=C/             @ R1, C/A
   :S1/=S2             @ C/(R1*A) is R2, the other root   :S1/=S2             @ C/(R1*A) is R2, the other root
 » »
Line 183: Line 186:
     :F*=A         @ F='(y2-y1)*(X-x1)'     :F*=A         @ F='(y2-y1)*(X-x1)'
     :B-=F         @ B='(Y-y1)*(x2-x1)-(y2-y1)*(X-x1)'     :B-=F         @ B='(Y-y1)*(x2-x1)-(y2-y1)*(X-x1)'
-    :PUSH.B.#1    @ Push result on the stack+    :P=         @ Push result on the stack
   »   »
 » »
 </code>  </code> 
  • manual/chapter5/asm.txt
  • Last modified: 2021/09/29 05:58
  • by jojo1973