Subversion Repositories Kolibri OS

Rev

Rev 1857 | Blame | 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: 2305 $
  13.  
  14. ; macros definition
  15. macro diff16 title,l1,l2
  16. {
  17.   local s,d
  18.   s = l2-l1
  19.   display title,': 0x'
  20.   repeat 16
  21.     d = 48 + s shr ((16-%) shl 2) and $0F
  22.     if d > 57
  23.       d = d + 65-57-1
  24.     end if
  25.     display d
  26.   end repeat
  27.   display 13,10
  28. }
  29. macro diff10 title,l1,l2
  30.  {
  31.   local s,d,z,m
  32.   s = l2-l1
  33.   z = 0
  34.   m = 1000000000
  35.   display title,': '
  36.   repeat 10
  37.    d = '0' + s / m
  38.    s = s - (s/m)*m
  39.    m = m / 10
  40.    if d <> '0'
  41.     z = 1
  42.    end if
  43.    if z <> 0
  44.     display d
  45.    end if
  46.   end repeat
  47.   display 13,10
  48.  }
  49.  
  50. include 'kglobals.inc'
  51.  
  52. ; \begin{diamond}[29.09.2006]
  53. ; may be useful for kernel debugging
  54. ; example 1:
  55. ;       dbgstr 'Hello, World!'
  56. ; example 2:
  57. ;       dbgstr 'Hello, World!', save_flags
  58. macro dbgstr string*, f
  59. {
  60. local a
  61. iglobal_nested
  62. a db 'K : ',string,13,10,0
  63. endg_nested
  64. if ~ f eq
  65.         pushfd
  66. end if
  67.         push    esi
  68.         mov     esi, a
  69.         call    sys_msg_board_str
  70.         pop     esi
  71. if ~ f eq
  72.         popfd
  73. end if
  74. }
  75. ; \end{diamond}[29.09.2006]
  76.  
  77. macro Mov op1,op2,op3 ; op1 = op2 = op3
  78.  {
  79.         mov   op2,op3
  80.         mov   op1,op2
  81.  }
  82.  
  83.  
  84. if __CPU_type eq p5             ; CMOVcc isnt supported on the P5
  85.  
  86. cmove   fix     cmovz
  87. macro cmovz reg1, reg2 {
  88.  
  89. local   .jumpaddr
  90.  
  91.         jnz     .jumpaddr
  92.         mov     reg1, reg2
  93.        .jumpaddr:
  94. }
  95.  
  96. cmovne  fix     cmovnz
  97. macro cmovnz reg1, reg2 {
  98.  
  99. local   .jumpaddr
  100.  
  101.         jz      .jumpaddr
  102.         mov     reg1, reg2
  103.        .jumpaddr:
  104. }
  105.  
  106. macro cmovg reg1, reg2 {
  107.  
  108. local   .jumpaddr
  109.  
  110.         jle     .jumpaddr
  111.         mov     reg1, reg2
  112.        .jumpaddr:
  113. }
  114.  
  115. macro cmovl reg1, reg2 {
  116.  
  117. local   .jumpaddr
  118.  
  119.         jge     .jumpaddr
  120.         mov     reg1, reg2
  121.        .jumpaddr:
  122. }
  123.  
  124. end if
  125.