Subversion Repositories Kolibri OS

Rev

Rev 8968 | 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. macro ignore_empty_revision_keyword {
  19.   ; svn keywords are neither substituted by git-svn nor catched by $Revision
  20.   ; macro above, ignore them to not fail the build
  21.   macro $Rev#ision$ \{\}
  22. }
  23. ignore_empty_revision_keyword
  24.  
  25. $Revision: 8968 $
  26.  
  27.  
  28. ;// mike.dld, 2006-29-01 [
  29.  
  30. ; macros definition
  31. macro diff16 title,l1,l2
  32. {
  33.   local s,d
  34.   s = l2-l1
  35.   display title,': 0x'
  36.   repeat 16
  37.     d = 48 + s shr ((16-%) shl 2) and $0F
  38.     if d > 57
  39.       d = d + 65-57-1
  40.     end if
  41.     display d
  42.   end repeat
  43.   display 13,10
  44. }
  45. macro diff10 title,l1,l2
  46.  {
  47.   local s,d,z,m
  48.   s = l2-l1
  49.   z = 0
  50.   m = 1000000000
  51.   display title,': '
  52.   repeat 10
  53.    d = '0' + s / m
  54.    s = s - (s/m)*m
  55.    m = m / 10
  56.    if d <> '0'
  57.     z = 1
  58.    end if
  59.    if z <> 0
  60.     display d
  61.    end if
  62.   end repeat
  63.   display 13,10
  64.  }
  65.  
  66. include 'kglobals.inc'
  67.  
  68. ; \begin{diamond}[29.09.2006]
  69.  
  70. ; @brief May be useful for kernel debugging
  71. ; example 1:
  72. ;       dbgstr 'Hello, World!'
  73. ; example 2:
  74. ;       dbgstr 'Hello, World!', save_flags
  75. ; @param string Output string
  76. ; @param f Put here anything if you gonna save flags
  77. macro dbgstr string*, f
  78. {
  79. local a
  80. iglobal_nested
  81. a db 'K : ',string,13,10,0
  82. endg_nested
  83. if ~ f eq
  84.         pushfd
  85. end if
  86.         push    esi
  87.         mov     esi, a
  88.         call    sys_msg_board_str
  89.         pop     esi
  90. if ~ f eq
  91.         popfd
  92. end if
  93. }
  94. ; \end{diamond}[29.09.2006]
  95.  
  96.  
  97. macro list_init head
  98. {
  99.         mov     [head+LHEAD.next], head
  100.         mov     [head+LHEAD.prev], head
  101. }
  102.  
  103. macro __list_add new, prev, next
  104. {
  105.         mov     [next+LHEAD.prev], new
  106.         mov     [new+LHEAD.next], next
  107.         mov     [new+LHEAD.prev], prev
  108.         mov     [prev+LHEAD.next], new
  109. }
  110.  
  111. macro list_add new, head
  112. {
  113.         mov     eax, [head+LHEAD.next]
  114.     __list_add new, head, eax
  115. }
  116.  
  117. macro list_add_tail new, head
  118. {
  119.         mov     eax, [head+LHEAD.prev]
  120.     __list_add new, eax, head
  121. }
  122.  
  123. macro list_del entry
  124. {
  125.         mov     edx, [entry+LHEAD.next]
  126.         mov     ecx, [entry+LHEAD.prev]
  127.         mov     [edx+LHEAD.prev], ecx
  128.         mov     [ecx+LHEAD.next], edx
  129. }
  130.  
  131. ; MOV Immediate.
  132. ; Useful for things like movi eax,10:
  133. ; shorter than regular mov, but slightly slower,
  134. ; do not use it in performance-critical places.
  135. macro movi dst, imm
  136. {
  137. if imm >= -0x80 & imm <= 0x7F
  138.         push    imm
  139.         pop     dst
  140. else
  141.         mov     dst, imm
  142. end if
  143. }
  144.