3/29/2023 0 Comments Mathematica factorial![]() 9 loop Set_Re ( Arg, Real ( I )) Set_Im ( Arg, 0.0 ) Put ( "factorial(" & Integer ' Image ( I ) & ") = " ) Put ( Item => Factorial ( Arg ), Fore => 6, Aft => 8, Exp => 0 ) New_Line end loop end Factorial_Numeric_Approximation With _Complex_Types with _Complex_Elementary_Functions with _Elementary_Functions with Ada.Text_IO.Complex_Io with Ada.Text_Io use Ada.Text_Io procedure Factorial_Numeric_Approximation is type Real is digits 15 package Complex_Pck is new _Complex_Types (Real ) use Complex_Pck package Complex_Io is new Ada.Text_Io.Complex_Io (Complex_Pck ) use Complex_IO package Cmplx_Elem_Funcs is new _Complex_Elementary_Functions (Complex_Pck ) use Cmplx_Elem_Funcs function Gamma ( X : Complex ) return Complex is package Elem_Funcs is new _Elementary_Functions (Real ) use Elem_Funcs use Ada.Numerics - Coefficients used by the GNU Scientific Library G : Natural := 7 P : constant array ( Natural range 0. * for this file see task include a file in language AArch64 assembly */ Umulh x11,x20,x0 // x11 is the hi rd if 0 overflow * for this file see task include a file in language AArch64 assembly*/ ![]() * ARM assembly AARCH64 Raspberry PI 3B */ innershiftloop: ANDI #%00001111,CCR clear extend flag ROXL.L D5 ROXL.L D4 DBRA D7. noShift MOVE.W D7 ,-( SP ) MOVEQ #0, D4 MOVE.L D3, D5. wasOdd: MOVEQ #31-1, D6 30 BITS TO CHECK MOVEQ #1-1, D7 START AT BIT 1, MINUS 1 IS FOR DBRA CORRECTION FACTOR. This is our +1 for an odd second operand. MOVE.L D1, D2 EXG D0, D1 D1 IS OUR BASE VALUE, WE'LL USE BIT SHIFTS TO REPEATEDLY MULTIPLY. OUTPUTS HIGH LONG IN D0, LOW LONG IN D1 INPUT: D0.L, D1.W = FACTORS MOVEM.L D2-D7 ,-( SP ) SWAP D1 CLR.W D1 SWAP D1 CLEAR THE TOP WORD OF D1. isOne: MOVEQ #1, D0 RTS MULU_48: "48-BIT" MULTIPLICATION. loop: SUBQ.L #1, D4 MOVE.L D1 ,-( SP ) MOVE.L D4, D1 JSR MULU_48 multiplies D0.L by D1.W EXG D0, D1 output is in D1 so we need to put it in D0 MOVE.L ( SP ) +, D1 DBRA D5. Since DBRA stops at FFFF we can't use it as our multiplier. isOne MOVEM.L D4-D5 ,-( SP ) MOVE.W D0, D4 MOVE.W D0, D5 SUBQ.W #2, D5 D2 = LOOP COUNTER. 'įactorial: input: D0.W: number you wish to get the factorial of. LR R13,R15 base register and savearea pointer
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |