Subversion Repositories Kolibri OS

Rev

Rev 2540 | Blame | Last modification | View Log | Download | RSS feed

  1. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2. ;;                                                              ;;
  3. ;; Copyright (C) KolibriOS team 2004-2011. All rights reserved. ;;
  4. ;; Distributed under terms of the GNU General Public License    ;;
  5. ;;                                                              ;;
  6. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  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 $
  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.  
  120.  
  121.  
  122. if __CPU_type eq p5             ; CMOVcc isnt supported on the P5
  123.  
  124. cmove   fix     cmovz
  125. macro cmovz reg1, reg2 {
  126.  
  127. local   .jumpaddr
  128.  
  129.         jnz     .jumpaddr
  130.         mov     reg1, reg2
  131.        .jumpaddr:
  132. }
  133.  
  134. cmovne  fix     cmovnz
  135. macro cmovnz reg1, reg2 {
  136.  
  137. local   .jumpaddr
  138.  
  139.         jz      .jumpaddr
  140.         mov     reg1, reg2
  141.        .jumpaddr:
  142. }
  143.  
  144. macro cmovg reg1, reg2 {
  145.  
  146. local   .jumpaddr
  147.  
  148.         jle     .jumpaddr
  149.         mov     reg1, reg2
  150.        .jumpaddr:
  151. }
  152.  
  153. macro cmovl reg1, reg2 {
  154.  
  155. local   .jumpaddr
  156.  
  157.         jge     .jumpaddr
  158.         mov     reg1, reg2
  159.        .jumpaddr:
  160. }
  161.  
  162. macro cmova reg1, reg2 {
  163.  
  164. local   .jumpaddr
  165.  
  166.         jbe     .jumpaddr
  167.         mov     reg1, reg2
  168.        .jumpaddr:
  169. }
  170.  
  171. macro cmovb reg1, reg2 {
  172.  
  173. local   .jumpaddr
  174.  
  175.         jae     .jumpaddr
  176.         mov     reg1, reg2
  177.        .jumpaddr:
  178. }
  179.  
  180. macro cmovae reg1, reg2 {
  181.  
  182. local   .jumpaddr
  183.  
  184.         jb     .jumpaddr
  185.         mov     reg1, reg2
  186.        .jumpaddr:
  187. }
  188.  
  189. macro cmovbe reg1, reg2 {
  190.  
  191. local   .jumpaddr
  192.  
  193.         ja     .jumpaddr
  194.         mov     reg1, reg2
  195.        .jumpaddr:
  196. }
  197.  
  198. end if
  199.  
  200.