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

Subversion Repositories ssbcc

[/] [ssbcc/] [trunk/] [lib/] [9x8/] [math.s] - Blame information for rev 7

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 4 sinclairrf
; Copyright 2014, Sinclair R.F., Inc.
2 2 sinclairrf
;
3 4 sinclairrf
; Unsigned arithmetic operations.
4 2 sinclairrf
 
5 7 sinclairrf
; Notation:
6
;   ux_n is the n'th byte of ux where n=0 is the LSB
7
;         example:  ( u0_0 u0_1 ) are the LSB and MSB of a 2-byte 16-bit value.
8
;   u0 and u1 are two input vectors, us is their sum
9
 
10 4 sinclairrf
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
11
;
12
; Add two unsigned 8-bit values to produce an unsigned 16-bit value.
13 7 sinclairrf
; Method:  calculate and push the carry bit onto the return stack, calculate the
14
;          8-bit sum of the two 8-bit values, use the previously stored and
15
;          computed carry bit as the MSB of the 16-bit return value.
16
; 6 instructions
17 4 sinclairrf
;
18 7 sinclairrf
; ( u0 u1 - us_0 us_1 )
19 4 sinclairrf
.function math__add_u8_u8_u16
20 7 sinclairrf
  ; ( u_0 u_1 - u_0 u_1 ) r:( - c )
21
  ; ( u0 u1 - us_0 us_1 )
22
  +c >r + r>
23
  .return
24 2 sinclairrf
 
25 4 sinclairrf
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
26
; miscellaneous unsigned addition operations
27 2 sinclairrf
 
28 7 sinclairrf
; ( u0_0 u0_1  u0 - us_0 us_1 )
29
; 9 instructions
30 4 sinclairrf
.function math__add_u16_u8_u16
31 7 sinclairrf
  ; ( u0_0 u0_1 u1 - u0_0 u1 ) r:( - u0_1  )
32
  swap >r
33
  ; ( u0_0 u1 - us_0 c_0 )
34
  +c >r + r>
35
  ; ( c_0 - us_1 ) r:( u0_1 )
36
  r> .return(+)
37 2 sinclairrf
 
38 7 sinclairrf
; ( u0_0 u0_1 u1 - us_0 us_1 us_2 )
39
; 13 instructions
40 4 sinclairrf
.function math__add_u16_u8_u24
41 7 sinclairrf
  ; ( u0_0 u0_1 u1 - u0_0 u1 ) r:( - u0_1 )
42
  swap >r
43
  ; ( u0_0 u1 - us_0 c_0 )
44
  +c >r + r>
45
  ; ( c_0 - us_1 us_2 ) r:( u0_1  - )
46
  r> +c >r + r>
47
  .return
48 2 sinclairrf
 
49 7 sinclairrf
; ( u0_0 u0_1 u0_2 u1 - us_0 us_1 us_2 )
50 4 sinclairrf
.function math__add_u24_u8_u24
51
  swap >r .call(math__add_u16_u8_u24)
52
  r> .return(+)
53 2 sinclairrf
 
54 7 sinclairrf
; ( u0_0 u0_1 u0_2 u1 - us_0 us_1 us_2 us_3 )
55 4 sinclairrf
.function math__add_u24_u8_u32
56
  swap >r .call(math__add_u16_u8_u24)
57
  r> .call(math__add_u8_u8_u16)
58
  .return
59 2 sinclairrf
 
60 4 sinclairrf
.function math__add_u32_u8_u32
61
  swap >r .call(math__add_u24_u8_u32)
62
  r> .return(+)
63 2 sinclairrf
 
64 4 sinclairrf
.function math__add_u32_u16_u32
65
  >r .call(math__add_u32_u8_u32)
66
  r> .call(math__add_u24_u8_u24)
67
  .return
68 2 sinclairrf
 
69 4 sinclairrf
.function math__add_u32_u24_u32
70
  >r .call(math__add_u32_u16_u32)
71
  r> .call(math__add_u16_u8_u16)
72
  .return
73 2 sinclairrf
 
74 4 sinclairrf
.function math__add_u32_u32_u32
75
  >r .call(math__add_u32_u24_u32)
76
  r> .return(+)

powered by: WebSVN 2.1.0

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