forked from TCShenanigans/symphony_stdlib
Fixed unsafe_mem.compare not working correctly when both input pointers are the same
This commit is contained in:
+4
-2
@@ -12,6 +12,8 @@
|
|||||||
; - `<0` if the first segment is less than the second segment.
|
; - `<0` if the first segment is less than the second segment.
|
||||||
; - `>0` if the first segment is greater than the second segment.
|
; - `>0` if the first segment is greater than the second segment.
|
||||||
pub compare:
|
pub compare:
|
||||||
|
cmp r1, r2
|
||||||
|
je _compare__is_eq
|
||||||
; Exclusive end point of the second segment.
|
; Exclusive end point of the second segment.
|
||||||
add r4, r3, r2
|
add r4, r3, r2
|
||||||
; Exclusive end point of the first segment.
|
; Exclusive end point of the first segment.
|
||||||
@@ -62,7 +64,7 @@ _compare__low1:
|
|||||||
; Otherwise, the target is that non-zero byte.
|
; Otherwise, the target is that non-zero byte.
|
||||||
; Check if the target is out of bounds, i.e. the loop terminated through the "bounds check".
|
; Check if the target is out of bounds, i.e. the loop terminated through the "bounds check".
|
||||||
cmp r1, r3
|
cmp r1, r3
|
||||||
jae _compare__oob
|
jae _compare__is_eq
|
||||||
; r5 is the comparison result in the format of `cmp`. Convert it to the desired format.
|
; r5 is the comparison result in the format of `cmp`. Convert it to the desired format.
|
||||||
; 00 => 0x40000000 > 0
|
; 00 => 0x40000000 > 0
|
||||||
; 01 => 0x00000000 = 0
|
; 01 => 0x00000000 = 0
|
||||||
@@ -70,6 +72,6 @@ _compare__low1:
|
|||||||
xor r1, r5, 1
|
xor r1, r5, 1
|
||||||
lsl r1, r1, 30
|
lsl r1, r1, 30
|
||||||
jmp r13
|
jmp r13
|
||||||
_compare__oob:
|
_compare__is_eq:
|
||||||
mov r1, 0
|
mov r1, 0
|
||||||
jmp r13
|
jmp r13
|
||||||
|
|||||||
Reference in New Issue
Block a user