OpenCores
URL https://opencores.org/ocsvn/ssbcc/ssbcc/trunk

Subversion Repositories ssbcc

[/] [ssbcc/] [trunk/] [lib/] [9x8/] [cmp_8bit_uu.s] - Blame information for rev 10

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 10 sinclairrf
; Copyright 2013, 2015, Sinclair R.F., Inc.
2 2 sinclairrf
;
3
; 8-bit unsigned vs. unsigned comparison operators
4
 
5 10 sinclairrf
.IFNDEF D__INCLUDED__CMP_8BIT_UU_S__
6
.define D__INCLUDED__CMP_8BIT_UU_S__
7
 
8 2 sinclairrf
; Compare two unsigned 8-bit values for equality.
9
; ( u1 u2 - f"u1 = u2" )
10
.function cmp_8bit_uu_eq
11
  - .return(0=)
12
 
13
; Compare two unsigned 8-bit values for inequality.
14
; ( u1 u2 - f"u1 != u2" )
15
.function cmp_8bit_uu_ne
16
  - .return(0<>)
17
 
18
; Return true if the unsigned value u1 is less than the unsigned value u2.
19
; Method:  If the msb of u1 and u2 are the same, then then msb of the difference
20
;          indicates which one is larger.  Otherwise the msb of u1 indicates
21
;          which one is larger.
22
; ( u1 u2 - f"u1 < u2" )
23
.function cmp_8bit_uu_lt
24
  over over ^ 0x80 & .jumpc(different)
25
    - 0x80 & .return(0<>)
26
  :different
27
    drop 0x80 & .return(0=)
28
 
29
; Return true if the unsigned value u1 is greater than or equal to the unsigned
30
; value u2.
31
; ( u1 u2 - f"u1 >= u2" )
32
.function cmp_8bit_uu_ge
33
  .call(cmp_8bit_uu_lt) .return(0=)
34
 
35
; Return true if the unsigned value u1 is less than or equal to the unsigned
36
; value u2.
37
; ( u1 u2 - f"u1 <= u2" )
38
.function cmp_8bit_uu_le
39
  .call(cmp_8bit_uu_lt,swap) .return(0=)
40
 
41
; Return true if the unsigned value u1 is greater than the unsigned value u2.
42
; ( u1 u2 - f"u1 > u2" )
43
.function cmp_8bit_uu_gt
44
  .call(cmp_8bit_uu_lt,swap) .return
45
 
46
; Return the smaller of two unsigned values.
47
; ( u1 u2 - min(u1,u2) )
48
.function min_u8
49
  ; ( u1 u2 - u1 u2 f"u1 >= u2" )
50
  over .call(cmp_8bit_uu_lt,over) 0=
51
  ; ( u1 u2 f"u1 >= u2" - u1 u2 ) r:( - f"u1 >= u2" )
52
  >r
53
  ; (u1 u2 - u1 u2-u1 )
54
  over -
55
  ; ( u1 u2-u1 - u1 u2-u1 f"u1 >= u2" ) r:( f"u1 >= u2" - )
56
  r>
57
  ; if u1<u2:  ( u1 u2-u1 f"u1 >= u2" - u1 0 )
58
  ; otherwise: ( u1 u2-u1 f"u1 >= u2" - u1 u2-u1 )
59
  &
60
  ; ( u1 uX - min(u1,u2) )
61
  .return(+)
62 10 sinclairrf
 
63
.ENDIF ; D__INCLUDED__CMP_8BIT_UU_S__

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.