]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdePkg/Include/X64/Nasm.inc
MdePkg/Nasm.inc: add macros for C types used in structure definition
[mirror_edk2.git] / MdePkg / Include / X64 / Nasm.inc
index e57a803c81a7f3a554835ee19a35a767f6b7de47..527f71e9eb4d34ab9e14d24640f898364e1272bb 100644 (file)
@@ -1,6 +1,6 @@
 ;------------------------------------------------------------------------------\r
 ;\r
 ;------------------------------------------------------------------------------\r
 ;\r
-; Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>\r
+; Copyright (c) 2019 - 2021, Intel Corporation. All rights reserved.<BR>\r
 ; SPDX-License-Identifier: BSD-2-Clause-Patent\r
 ;\r
 ; Abstract:\r
 ; SPDX-License-Identifier: BSD-2-Clause-Patent\r
 ;\r
 ; Abstract:\r
 %macro INCSSP_RAX      0\r
     DB 0xF3, 0x48, 0x0F, 0xAE, 0xE8\r
 %endmacro\r
 %macro INCSSP_RAX      0\r
     DB 0xF3, 0x48, 0x0F, 0xAE, 0xE8\r
 %endmacro\r
+\r
+; NASM provides built-in macros STRUC and ENDSTRUC for structure definition.\r
+; For example, to define a structure called mytype containing a longword,\r
+; a word, a byte and a string of bytes, you might code\r
+;\r
+; struc   mytype\r
+;\r
+;  mt_long:      resd    1\r
+;  mt_word:      resw    1\r
+;  mt_byte:      resb    1\r
+;  mt_str:       resb    32\r
+;\r
+; endstruc\r
+;\r
+; Below macros are help to map the C types and the RESB family of pseudo-instructions.\r
+; So that the above structure definition can be coded as\r
+;\r
+; struc   mytype\r
+;\r
+;  mt_long:      CTYPE_UINT32    1\r
+;  mt_word:      CTYPE_UINT16    1\r
+;  mt_byte:      CTYPE_UINT8     1\r
+;  mt_str:       CTYPE_CHAR8     32\r
+;\r
+; endstruc\r
+%define CTYPE_UINT64    resq\r
+%define CTYPE_INT64     resq\r
+%define CTYPE_UINT32    resd\r
+%define CTYPE_INT32     resd\r
+%define CTYPE_UINT16    resw\r
+%define CTYPE_INT16     resw\r
+%define CTYPE_BOOLEAN   resb\r
+%define CTYPE_UINT8     resb\r
+%define CTYPE_CHAR8     resb\r
+%define CTYPE_INT8      resb\r
+\r
+%define CTYPE_UINTN     resq\r
+%define CTYPE_INTN      resq\r