%macro Descriptor 3
dw %2 & 0FFFFh
dw %1 & 0FFFFh
db (%1 >> 16) & 0FFh
dw ((%2 >> 8) & 0F00h) | (%3 & 0F0FFh)
db (%1 >> 24) & 0FFh
%endmacro
用法:
DA_DRW EQU 92h
LABEL_GDT: Descriptor 0, 0, 0
LABEL_DESC_TEST: Descriptor 0500000h, 0ffffh, DA_DRW
LABEL_DESC_VIDEO: Descriptor 0B8000h, 0ffffh, DA_DRW
我昨天刚开始学习鼻子,请回答一下......
答案 0 :(得分:0)
宏相当于编译时文本替换。在这种情况下,你有一个名为Descriptor
的宏,它有3个参数。宏的每次使用都将替换为宏体,%n
将替换为第n个参数。
例如:
LABEL_DESC_TEST: Descriptor 0500000h, 0ffffh, DA_DRW
将扩展为:
LABEL_DESC_TEST: dw 0ffffh & 0FFFFh
dw 0500000h & 0FFFFh
db (0500000h >> 16) & 0FFh
dw ((0ffffh >> 8) & 0F00h) | (DA_DRW & 0F0FFh)
db (0500000h >> 24) & 0FFh