seb15753

GDT.inc

Jun 22nd, 2014
345
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ;originally found at http://a.michelizza.free.fr
  2. ;--------------------------------------------------------------------
  3. ; CalcAdr
  4. ; input:
  5. ;    ax -> segment
  6. ;    bx -> offset
  7. ; output:
  8. ;    ecx -> 32 bits linear @
  9. ; change: ebx
  10. ;--------------------------------------------------------------------
  11. calcadr:
  12.     xor ecx, ecx
  13.     mov cx, ax
  14.     shl ecx, 4
  15.     and ebx, 0x0000FFFF
  16.     add ecx, ebx
  17.     ret
  18. ;--------------------------------------------------------------------
  19.  
  20. ;--------------------------------------------------------------------
  21. ; descInit
  22. ;--------------------------------------------------------------------
  23. %macro descInit    5    ; base(32), limit(20/32), acces(8), flags(4/8), addresse(32)
  24.     push eax
  25. ; base :
  26.     mov eax, %1
  27.     mov word [%5+2], ax
  28.     shr eax, 16
  29.     mov byte [%5+4], al
  30.     shr eax, 8
  31.     mov byte [%5+7], al
  32. ; limite :
  33.     mov eax, %2
  34.     and eax, 0x000FFFFF
  35.     mov word [%5], ax
  36.     shr eax, 16
  37.     mov byte [%5+6], 0
  38.     or  [%5+6], al
  39. ; flags :
  40.     mov al, %4
  41.     and al, 0x0F
  42.     shl al, 4
  43.     or [%5+6], al
  44. ; acces :
  45.     mov byte [%5+5], %3
  46.     pop eax
  47. %endmacro
  48. ;--------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment