You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
1.7 KiB
51 lines
1.7 KiB
3 years ago
|
|
||
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||
|
|
||
|
struc SegmentDescriptor
|
||
|
.wLimitLow RESW 1 ;�ν���16λ
|
||
|
.wBaseLow RESW 1 ;����ַ��16λ
|
||
|
.bBaseMiddle RESB 1 ;����ַ�м�8λ
|
||
|
.bAttrib RESB 1 ;������
|
||
|
.bLimitHight4Bit_AttribHight4Bit RESB 1 ;�ν��ĸ�4λ�Ͷ����Եĸ�4λ
|
||
|
.bBaseHigh RESB 1 ;����ַ�ĸ�8λ
|
||
|
endstruc
|
||
|
|
||
|
; varaible ,offset,Base
|
||
|
%macro SetDescriptor_Base_Offset 3
|
||
|
xor eax, eax
|
||
|
mov ax, %3
|
||
|
shl eax, 4
|
||
|
add eax, %2
|
||
|
mov word [%1 + SegmentDescriptor.wBaseLow], ax
|
||
|
shr eax, 16
|
||
|
mov byte [%1 + SegmentDescriptor.bBaseMiddle], al
|
||
|
mov byte [%1 + SegmentDescriptor.bBaseHigh], ah
|
||
|
%endmacro
|
||
|
|
||
|
; varaible , Base
|
||
|
%macro SetDescriptor_Base 2
|
||
|
mov eax,%2
|
||
|
mov word [%1 + SegmentDescriptor.wBaseLow], ax
|
||
|
shr eax, 16
|
||
|
mov byte [%1 + SegmentDescriptor.bBaseMiddle], al
|
||
|
mov byte [%1 + SegmentDescriptor.bBaseHigh], ah
|
||
|
%endmacro
|
||
|
|
||
|
; %1 new descriptor name
|
||
|
; %2 base : 32 bit
|
||
|
; %3 limit : 20 bit
|
||
|
; %4 attribute ; 12 bit
|
||
|
%macro NewDescriptor 4
|
||
|
%1:
|
||
|
istruc SegmentDescriptor
|
||
|
at SegmentDescriptor.wLimitLow , dw %3 & 0xffff
|
||
|
at SegmentDescriptor.wBaseLow , dw %2 & 0xffff
|
||
|
at SegmentDescriptor.bBaseMiddle, db (%2>>16) & 0xff
|
||
|
at SegmentDescriptor.bAttrib , db %4 & 0xff
|
||
|
at SegmentDescriptor.bLimitHight4Bit_AttribHight4Bit, db ( (%3>>16) & 0x0F) | (%4 >> 8)
|
||
|
at SegmentDescriptor.bBaseHigh , db (%2 >> 24) & 0xff
|
||
|
iend
|
||
|
%endmacro
|
||
|
|
||
|
|