Subversion Repositories Kolibri OS

Rev

Rev 2455 | Rev 5130 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2455 mario79 1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;;                                                              ;;
3
;; Copyright (C) KolibriOS team 2004-2011. All rights reserved. ;;
4
;; Distributed under terms of the GNU General Public License    ;;
5
;;                                                              ;;
6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2288 clevermous 7
 
8
__REV = 0
9
 
10
macro $Revision a {
11
  match =: Num =$,a \{
12
    if __REV < Num
13
      __REV = Num
14
    end if
15
  \}
16
}
17
 
18
$Revision: 3598 $
19
 
20
 
21
;// mike.dld, 2006-29-01 [
22
 
23
; macros definition
24
macro diff16 title,l1,l2
25
{
26
  local s,d
27
  s = l2-l1
28
  display title,': 0x'
29
  repeat 16
30
    d = 48 + s shr ((16-%) shl 2) and $0F
31
    if d > 57
32
      d = d + 65-57-1
33
    end if
34
    display d
35
  end repeat
36
  display 13,10
37
}
38
macro diff10 title,l1,l2
39
 {
40
  local s,d,z,m
41
  s = l2-l1
42
  z = 0
43
  m = 1000000000
44
  display title,': '
45
  repeat 10
46
   d = '0' + s / m
47
   s = s - (s/m)*m
48
   m = m / 10
49
   if d <> '0'
50
    z = 1
51
   end if
52
   if z <> 0
53
    display d
54
   end if
55
  end repeat
56
  display 13,10
57
 }
58
 
59
include 'kglobals.inc'
60
 
61
; \begin{diamond}[29.09.2006]
62
; may be useful for kernel debugging
63
; example 1:
64
;       dbgstr 'Hello, World!'
65
; example 2:
66
;       dbgstr 'Hello, World!', save_flags
67
macro dbgstr string*, f
68
{
69
local a
70
iglobal_nested
71
a db 'K : ',string,13,10,0
72
endg_nested
73
if ~ f eq
74
        pushfd
75
end if
76
        push    esi
77
        mov     esi, a
78
        call    sys_msg_board_str
79
        pop     esi
80
if ~ f eq
81
        popfd
82
end if
83
}
84
; \end{diamond}[29.09.2006]
85
 
86
macro Mov op1,op2,op3 ; op1 = op2 = op3
87
 {
88
        mov     op2, op3
89
        mov     op1, op2
90
 }
91
 
92
macro __list_add new, prev, next
93
{
94
        mov     [next+LHEAD.prev], new
95
        mov     [new+LHEAD.next], next
96
        mov     [new+LHEAD.prev], prev
97
        mov     [prev+LHEAD.next], new
98
}
99
 
100
macro list_add new, head
101
{
102
        mov     eax, [head+LHEAD.next]
103
    __list_add new, head, eax
104
}
105
 
106
macro list_add_tail new, head
107
{
108
        mov     eax, [head+LHEAD.prev]
109
    __list_add new, eax, head
110
}
111
 
112
macro list_del entry
113
{
114
        mov     edx, [entry+list_fd]
115
        mov     ecx, [entry+list_bk]
116
        mov     [edx+list_bk], ecx
117
        mov     [ecx+list_fd], edx
118
}
119
 
3598 clevermous 120
; MOV Immediate.
121
; Useful for things like movi eax,10:
122
; shorter than regular mov, but slightly slower,
123
; do not use it in performance-critical places.
124
macro movi dst, imm
125
{
126
if imm >= -0x80 & imm <= 0x7F
127
        push    imm
128
        pop     dst
129
else
130
        mov     dst, imm
131
end if
132
}