Subversion Repositories Kolibri OS

Rev

Rev 2154 | Rev 2381 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1.  
  2. __REV = 0
  3.  
  4. macro $Revision a {
  5.   match =: Num =$,a \{
  6.     if __REV < Num
  7.       __REV = Num
  8.     end if
  9.   \}
  10. }
  11.  
  12. $Revision: 2288 $
  13.  
  14.  
  15. ; structure definition helper
  16. macro struct name, [arg]
  17.  {
  18.   common
  19.    name@struct equ name
  20.    struc name arg {
  21.  }
  22.  
  23. macro declare_sizeof xname,value
  24. { sizeof.#xname = value }
  25.  
  26. macro struct_helper name
  27.  {
  28.   match xname,name
  29.   \{
  30.    virtual at 0
  31.    xname xname
  32.    declare_sizeof xname, $ - xname
  33.    name equ sizeof.#xname
  34.    end virtual
  35.   \}
  36.  }
  37.  
  38. ends fix } struct_helper name@struct
  39.  
  40. ;// mike.dld, 2006-29-01 [
  41.  
  42. ; macros definition
  43. macro diff16 title,l1,l2
  44. {
  45.   local s,d
  46.   s = l2-l1
  47.   display title,': 0x'
  48.   repeat 16
  49.     d = 48 + s shr ((16-%) shl 2) and $0F
  50.     if d > 57
  51.       d = d + 65-57-1
  52.     end if
  53.     display d
  54.   end repeat
  55.   display 13,10
  56. }
  57. macro diff10 title,l1,l2
  58.  {
  59.   local s,d,z,m
  60.   s = l2-l1
  61.   z = 0
  62.   m = 1000000000
  63.   display title,': '
  64.   repeat 10
  65.    d = '0' + s / m
  66.    s = s - (s/m)*m
  67.    m = m / 10
  68.    if d <> '0'
  69.     z = 1
  70.    end if
  71.    if z <> 0
  72.     display d
  73.    end if
  74.   end repeat
  75.   display 13,10
  76.  }
  77.  
  78. include 'kglobals.inc'
  79.  
  80. ; \begin{diamond}[29.09.2006]
  81. ; may be useful for kernel debugging
  82. ; example 1:
  83. ;       dbgstr 'Hello, World!'
  84. ; example 2:
  85. ;       dbgstr 'Hello, World!', save_flags
  86. macro dbgstr string*, f
  87. {
  88. local a
  89. iglobal_nested
  90. a db 'K : ',string,13,10,0
  91. endg_nested
  92. if ~ f eq
  93.         pushfd
  94. end if
  95.         push    esi
  96.         mov     esi, a
  97.         call    sys_msg_board_str
  98.         pop     esi
  99. if ~ f eq
  100.         popfd
  101. end if
  102. }
  103. ; \end{diamond}[29.09.2006]
  104.  
  105. macro Mov op1,op2,op3 ; op1 = op2 = op3
  106.  {
  107.         mov     op2, op3
  108.         mov     op1, op2
  109.  }
  110.  
  111. macro __list_add new, prev, next
  112. {
  113.         mov     [next+LHEAD.prev], new
  114.         mov     [new+LHEAD.next], next
  115.         mov     [new+LHEAD.prev], prev
  116.         mov     [prev+LHEAD.next], new
  117. }
  118.  
  119. macro list_add new, head
  120. {
  121.         mov     eax, [head+LHEAD.next]
  122.     __list_add new, head, eax
  123. }
  124.  
  125. macro list_add_tail new, head
  126. {
  127.         mov     eax, [head+LHEAD.prev]
  128.     __list_add new, eax, head
  129. }
  130.  
  131. macro list_del entry
  132. {
  133.         mov     edx, [entry+list_fd]
  134.         mov     ecx, [entry+list_bk]
  135.         mov     [edx+list_bk], ecx
  136.         mov     [ecx+list_fd], edx
  137. }
  138.  
  139.