Plaster

text
;; First four parameters: ;; rcx ;; rdx ;; r8 ;; r9 ;; Rest on stack. ;; Structs: ;; Sizes of: 8 16 32 64 ;; 1-4 passed in regs. ;; 5-x passed on stack ;; Not sizes: 8 16 32 64 ;; Passed by pointer. ;; 1-4 pointers passed in regs ;; 5-x passed on stack ;; Return values: ;; rax - Return value ;; A scalar return value that can fit into 64 bits is returned through RAX ;; ;; Other important registers: ;; rsp - Stack pointer (also esp is the lower half or 32bit stack pointer) ;; ;; Structure alignment: ;; ;; Scalar Type C Data Type Required Alignment ;; ------------------------- ----------------------------- ------------------ ;; INT8 char Byte ;; UINT8 unsigned char Byte ;; INT16 short Word ;; UINT16 unsigned short Word ;; INT32 int, long Doubleword ;; UINT32 unsigned int, unsigned long Doubleword ;; INT64 __int64 Quadword ;; UINT64 unsigned __int64 Quadword ;; FP32 (single precision) float Doubleword ;; FP64 (double precision) double Quadword ;; POINTER \* Quadword ;; __m64 struct __m64 Quadword ;; __m128 struct __m128 Octaword ;; ;; Where (from Microsoft lingo): ;; Byte = 8 bits 1 byte ;; Word = 16 bits 2 bytes ;; Doubleword = 32 bits 4 bytes ;; Quadword = 64 bits 8 bytes ;; Octaword = 128 bits 16 bytes ;; ;; The following aggregate alignment rules apply: ;; ;; - The alignment of an array is the same as the alignment of one of the ;; elements of the array. ;; ;; - The alignment of the beginning of a structure or a union is the maximum ;; alignment of any individual member. Each member within the structure or ;; union must be placed at its proper alignment as defined in the previous ;; table, which may require implicit internal padding, depending on the ;; previous member. ;; ;; - Structure size must be an integral multiple of its alignment, which may ;; require padding after the last member. Since structures and unions can be ;; grouped in arrays, each array element of a structure or union must begin ;; and end at the proper alignment previously determined. ;; ;; - It is possible to align data in such a way as to be greater than the ;; alignment requirements as long as the previous rules are maintained. ;; ;; - An individual compiler may adjust the packing of a structure for size ;; reasons. For example /Zp (Struct Member Alignment) allows for adjusting ;; the packing of structures. ;;