URL
https://opencores.org/ocsvn/ssbcc/ssbcc/trunk
[/] [ssbcc/] [trunk/] [lib/] [9x8/] [cmp_8bit_uu.s] - Blame information for rev 4
Go to most recent revision |
Details |
Compare with Previous |
View Log
Line No. |
Rev |
Author |
Line |
1 |
2 |
sinclairrf |
; Copyright 2013, Sinclair R.F., Inc.
|
2 |
|
|
;
|
3 |
|
|
; 8-bit unsigned vs. unsigned comparison operators
|
4 |
|
|
|
5 |
|
|
; Compare two unsigned 8-bit values for equality.
|
6 |
|
|
; ( u1 u2 - f"u1 = u2" )
|
7 |
|
|
.function cmp_8bit_uu_eq
|
8 |
|
|
- .return(0=)
|
9 |
|
|
|
10 |
|
|
; Compare two unsigned 8-bit values for inequality.
|
11 |
|
|
; ( u1 u2 - f"u1 != u2" )
|
12 |
|
|
.function cmp_8bit_uu_ne
|
13 |
|
|
- .return(0<>)
|
14 |
|
|
|
15 |
|
|
; Return true if the unsigned value u1 is less than the unsigned value u2.
|
16 |
|
|
; Method: If the msb of u1 and u2 are the same, then then msb of the difference
|
17 |
|
|
; indicates which one is larger. Otherwise the msb of u1 indicates
|
18 |
|
|
; which one is larger.
|
19 |
|
|
; ( u1 u2 - f"u1 < u2" )
|
20 |
|
|
.function cmp_8bit_uu_lt
|
21 |
|
|
over over ^ 0x80 & .jumpc(different)
|
22 |
|
|
- 0x80 & .return(0<>)
|
23 |
|
|
:different
|
24 |
|
|
drop 0x80 & .return(0=)
|
25 |
|
|
|
26 |
|
|
; Return true if the unsigned value u1 is greater than or equal to the unsigned
|
27 |
|
|
; value u2.
|
28 |
|
|
; ( u1 u2 - f"u1 >= u2" )
|
29 |
|
|
.function cmp_8bit_uu_ge
|
30 |
|
|
.call(cmp_8bit_uu_lt) .return(0=)
|
31 |
|
|
|
32 |
|
|
; Return true if the unsigned value u1 is less than or equal to the unsigned
|
33 |
|
|
; value u2.
|
34 |
|
|
; ( u1 u2 - f"u1 <= u2" )
|
35 |
|
|
.function cmp_8bit_uu_le
|
36 |
|
|
.call(cmp_8bit_uu_lt,swap) .return(0=)
|
37 |
|
|
|
38 |
|
|
; Return true if the unsigned value u1 is greater than the unsigned value u2.
|
39 |
|
|
; ( u1 u2 - f"u1 > u2" )
|
40 |
|
|
.function cmp_8bit_uu_gt
|
41 |
|
|
.call(cmp_8bit_uu_lt,swap) .return
|
42 |
|
|
|
43 |
|
|
; Return the smaller of two unsigned values.
|
44 |
|
|
; ( u1 u2 - min(u1,u2) )
|
45 |
|
|
.function min_u8
|
46 |
|
|
; ( u1 u2 - u1 u2 f"u1 >= u2" )
|
47 |
|
|
over .call(cmp_8bit_uu_lt,over) 0=
|
48 |
|
|
; ( u1 u2 f"u1 >= u2" - u1 u2 ) r:( - f"u1 >= u2" )
|
49 |
|
|
>r
|
50 |
|
|
; (u1 u2 - u1 u2-u1 )
|
51 |
|
|
over -
|
52 |
|
|
; ( u1 u2-u1 - u1 u2-u1 f"u1 >= u2" ) r:( f"u1 >= u2" - )
|
53 |
|
|
r>
|
54 |
|
|
; if u1<u2: ( u1 u2-u1 f"u1 >= u2" - u1 0 )
|
55 |
|
|
; otherwise: ( u1 u2-u1 f"u1 >= u2" - u1 u2-u1 )
|
56 |
|
|
&
|
57 |
|
|
; ( u1 uX - min(u1,u2) )
|
58 |
|
|
.return(+)
|
© copyright 1999-2024
OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.