Subversion Repositories Kolibri OS

Rev

Rev 5565 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2. ;;                                                              ;;
  3. ;; Copyright (C) KolibriOS team 2004-2015. 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: 5599 $
  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.  
  87. macro list_init head
  88. {
  89.         mov     [head+LHEAD.next], head
  90.         mov     [head+LHEAD.prev], head
  91. }
  92.  
  93. macro __list_add new, prev, next
  94. {
  95.         mov     [next+LHEAD.prev], new
  96.         mov     [new+LHEAD.next], next
  97.         mov     [new+LHEAD.prev], prev
  98.         mov     [prev+LHEAD.next], new
  99. }
  100.  
  101. macro list_add new, head
  102. {
  103.         mov     eax, [head+LHEAD.next]
  104.     __list_add new, head, eax
  105. }
  106.  
  107. macro list_add_tail new, head
  108. {
  109.         mov     eax, [head+LHEAD.prev]
  110.     __list_add new, eax, head
  111. }
  112.  
  113. macro list_del entry
  114. {
  115.         mov     edx, [entry+LHEAD.next]
  116.         mov     ecx, [entry+LHEAD.prev]
  117.         mov     [edx+LHEAD.prev], ecx
  118.         mov     [ecx+LHEAD.next], edx
  119. }
  120.  
  121. ; MOV Immediate.
  122. ; Useful for things like movi eax,10:
  123. ; shorter than regular mov, but slightly slower,
  124. ; do not use it in performance-critical places.
  125. macro movi dst, imm
  126. {
  127. if imm >= -0x80 & imm <= 0x7F
  128.         push    imm
  129.         pop     dst
  130. else
  131.         mov     dst, imm
  132. end if
  133. }
  134.