diff --git a/unsafe_mem.asm b/unsafe_mem.asm index 7108db0..446bfc5 100644 --- a/unsafe_mem.asm +++ b/unsafe_mem.asm @@ -12,6 +12,8 @@ ; - `<0` if the first segment is less than the second segment. ; - `>0` if the first segment is greater than the second segment. pub compare: + cmp r1, r2 + je _compare__is_eq ; Exclusive end point of the second segment. add r4, r3, r2 ; Exclusive end point of the first segment. @@ -62,7 +64,7 @@ _compare__low1: ; 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". 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. ; 00 => 0x40000000 > 0 ; 01 => 0x00000000 = 0 @@ -70,6 +72,6 @@ _compare__low1: xor r1, r5, 1 lsl r1, r1, 30 jmp r13 -_compare__oob: +_compare__is_eq: mov r1, 0 jmp r13