Merge pull request 'Changed docs of math functions to conform to new guidelines' (#12) from Micha_i/symphony_stdlib:math-functions-docs into main
Reviewed-on: #12
This commit was merged in pull request #12.
This commit is contained in:
@@ -1,8 +1,15 @@
|
|||||||
|
; Multiplies r1 and r2, returning the lower part of the result
|
||||||
|
; Arguments:
|
||||||
|
; r1 - The first value
|
||||||
|
; r2 - The second value
|
||||||
|
; Result:
|
||||||
|
; r1 - The lower 32 bits of the result
|
||||||
|
; Clobbers: r2, r3, r4, r5
|
||||||
pub mul_low:
|
pub mul_low:
|
||||||
mov r3, 0 ; result
|
mov r3, 0 ; result
|
||||||
mov r4, 31 ; loop counter
|
mov r4, 31 ; loop counter
|
||||||
|
|
||||||
mull_loop:
|
mul_low_loop:
|
||||||
asr r5, r2, 31
|
asr r5, r2, 31
|
||||||
and r5, r5, r1
|
and r5, r5, r1
|
||||||
lsl r5, r5, r4
|
lsl r5, r5, r4
|
||||||
@@ -10,14 +17,18 @@ pub mul_low:
|
|||||||
lsl r2, r2, 1
|
lsl r2, r2, 1
|
||||||
sub r4, r4, 1
|
sub r4, r4, 1
|
||||||
cmp r4, 0
|
cmp r4, 0
|
||||||
jge mull_loop
|
jge mul_low_loop
|
||||||
mov r1, r3
|
mov r1, r3
|
||||||
|
|
||||||
jmp r13
|
jmp r13
|
||||||
|
|
||||||
; Calculates the absolute value of the value provided in the r1 register
|
; Calculates the absolute value of the value provided in the r1 register
|
||||||
; Based on Stanford's BitHacks
|
; Arguments:
|
||||||
; Clobbers r2
|
; r1 - The value for which we want the absolute value
|
||||||
|
; Result:
|
||||||
|
; r1 - The calculated absolute value
|
||||||
|
; Clobbers: r2
|
||||||
|
; Info: Based on Stanford's BitHacks
|
||||||
pub abs: ; SHOULD BE INLINED
|
pub abs: ; SHOULD BE INLINED
|
||||||
; mask = v >> 31
|
; mask = v >> 31
|
||||||
asr r2, r1, 31
|
asr r2, r1, 31
|
||||||
@@ -28,8 +39,13 @@ pub abs: ; SHOULD BE INLINED
|
|||||||
jmp r13
|
jmp r13
|
||||||
|
|
||||||
; Calculates the minimum value of the two values provided in the r1 and r2 registers
|
; Calculates the minimum value of the two values provided in the r1 and r2 registers
|
||||||
; Based on Stanford's BitHacks
|
; Arguments:
|
||||||
; Clobbers flags
|
; r1 - The first value
|
||||||
|
; r2 - The second value
|
||||||
|
; Result:
|
||||||
|
; r1 - The smaller value
|
||||||
|
; Clobbers: Nothing
|
||||||
|
; Info: Based on Stanford's BitHacks
|
||||||
pub min: ; SHOULD BE INLINED
|
pub min: ; SHOULD BE INLINED
|
||||||
; x < y
|
; x < y
|
||||||
cmp r1, r2
|
cmp r1, r2
|
||||||
@@ -45,8 +61,13 @@ pub min: ; SHOULD BE INLINED
|
|||||||
jmp r13
|
jmp r13
|
||||||
|
|
||||||
; Calculates the maximum value of the two values provided in the r1 and r2 registers
|
; Calculates the maximum value of the two values provided in the r1 and r2 registers
|
||||||
; Based on Stanford's BitHacks
|
; Arguments:
|
||||||
; Clobbers r2 and flags
|
; r1 - The first value
|
||||||
|
; r2 - The second value
|
||||||
|
; Result:
|
||||||
|
; r1 - The smaller value
|
||||||
|
; Clobbers: r2
|
||||||
|
; Info: Based on Stanford's BitHacks
|
||||||
pub max: ; SHOULD BE INLINED
|
pub max: ; SHOULD BE INLINED
|
||||||
; x < y
|
; x < y
|
||||||
cmp r1, r2
|
cmp r1, r2
|
||||||
|
|||||||
Reference in New Issue
Block a user