seb15753

boot/GDT.inc

Jun 24th, 2014
314
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ;a.michelizza.free.fr
  2. ;--------------------------------------------------------------------
  3. ; CalcAdr
  4. ; input:
  5. ;    ax -> segment
  6. ;    bx -> offset
  7. ; output:
  8. ;    ecx -> 32 bits linear address
  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. ;--------------------------------------------------------------------
  22. ; descInit
  23. ;--------------------------------------------------------------------
  24. %macro descInit    5    ; base(32), limite(20/32), acces(8), flags(4/8), adresse(32)
  25.     push eax
  26. ; base :
  27.     mov eax, %1
  28.     mov word [%5+2], ax
  29.     shr eax, 16
  30.     mov byte [%5+4], al
  31.     shr eax, 8
  32.     mov byte [%5+7], al
  33. ; limite :
  34.     mov eax, %2
  35.     and eax, 0x000FFFFF
  36.     mov word [%5], ax  
  37.     shr eax, 16        
  38.     mov byte [%5+6], 0
  39.     or  [%5+6], al    
  40. ; flags :
  41.     mov al, %4
  42.     and al, 0x0F
  43.     shl al, 4
  44.     or [%5+6], al
  45. ; acces :
  46.     mov byte [%5+5], %3
  47.     pop eax
  48. %endmacro
  49. ;--------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment