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

Subversion Repositories forwardcom

[/] [forwardcom/] [libraries/] [raise_event.as] - Blame information for rev 168

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

Line No. Rev Author Line
1 108 Agner
/*********************************  raise_event *******************************
2
* Author:        Agner Fog
3
* date created:  2018-03-23
4
* Last modified: 2021-04-25
5
* Version:       1.11
6
* Project:       ForwardCom library libc.li
7
* Description:   raise_event: find event handlers and call them
8
* C declaration: int64_t raise_event(int64_t id_and_key, int64_t parameter1, const char * parameter2, ...)
9
*
10
* Copyright 2018 GNU General Public License http://www.gnu.org/licenses
11
*****************************************************************************/
12
 
13
extern __event_table: ip                         // address of event table
14
extern __event_table_num: constant               // size of event table
15
extern __ip_base: ip                             // reference point
16
 
17
code section execute align = 4
18
 
19
_raise_event function public
20
push (r16, 22)                                   // save registers r16 - r22
21
int64 r16 = address([__event_table])             // address of event table
22
int32 r17 = __event_table_num                    // size of event table
23
int64 r18 = address([__ip_base])                 // reference point
24
int64 r19 = r0                                   // save ID and key
25
int64 r20 = r1                                   // save function parameters
26
int64 r21 = r2
27
int64 r22 = r3
28
 
29
// loop through event table
30
// (note: this table is sorted. we may use binary search if the table is big)
31
while (int32 r17 > 0) {
32
   int64 r0 = [r16+8]                            // read key and id from table entry
33
   if (int64 r0 == r19) {
34
      // matching record found
35
      int64 r1 = r20                             // function parameters are in r1, r2, r3
36
      int64 r2 = r21
37
      int64 r3 = r22
38
      int32 call_relative(r18, [r16])            // call relative function pointer from table, with r18 as reference point
39
      if (int64 r0 == 0) {break}                 // disable further events with same ID if return value is 0
40
   }
41
   int64 r16 += 16                               // next record in event table
42
   int64 r17--                                   // decrement loop counter
43
}
44
pop (r16, 22)                                    // restore registers r22 - r16
45
return
46
 
47
_raise_event end
48
 
49
code end

powered by: WebSVN 2.1.0

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