source: xtideuniversalbios/trunk/Assembly_Library/Inc/Macros.inc @ 592

Last change on this file since 592 was 592, checked in by krille_n_, 6 years ago

Changes:

  • The problem with NASM in the previous revision (r591) has been fixed.
  • The colors used by the boot menu and hotkey bar can now be customized by selecting one of a number of pre-defined color themes. Suggestions for additional themes are more than welcome!
  • Large builds are now 10 KB. Small builds are still 8 KB with the exception of the Tiny build which is now 4 KB. In other words, builds are now as small as possible to make it easier to combine them with other BIOSes.
  • Added code to the library to improve drive error handling. XTIDECFG can now handle "Drive Not Ready" errors.
  • Fixed a couple of potential bugs in AtaID.asm (AtaID_GetMaxPioModeToAXandMinCycleTimeToCX); 1) ATA1.bPioMode was treated as a WORD variable. 2) ATA2.bPIOSupp was assumed to be non-zero which would result in PIO mode 3 being returned if the assumption was wrong.
  • Made the same changes in the equivalent function used by BIOSDRVS (DisplayPioModeInformationUsingAtaInfoFromDSBX in AtaInfo.asm).
  • Fixed a bug from r587 in PDC20x30.asm in PDC20x30_GetMaxPioModeToALandMinPioCycleTimeToBX.
  • Fixed a bug from r523 in XTIDECFG where Auto Configure would only set the IRQ on one IDE interface on AT-builds.
  • XTIDECFG will now restore the default settings for the "Serial port virtual device" when reselecting it in the list of device types. This makes it behave consistently for all device types.
  • The eAAM macro is now used regardless if USE_UNDOC_INTEL is defined or not because it is apparently supported on all processors including the NEC V20/V30 CPUs.
  • Renamed the EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS define to EXCLUDE_FROM_XUB.
  • Added a define to exclude unused library code from BIOSDRVS (EXCLUDE_FROM_BIOSDRVS). This makes it a lot smaller than in previous revisions.
  • All unnecessary CLD-instructions are now under a new define 'CLD_NEEDED' which is only enabled for the BIOS. It is disabled for XTIDECFG and BIOSDRVS but can be enabled if needed by adding this define to the respective makefile. This change was made because these unnecessary instructions are wasteful and should never be needed. In fact, they only serve to hide bugs (in other peoples code) which I strongly believe should be avoided. I recommend people making their own BIOSes from source to not use this define as it's extremely unlikely to be needed.
  • Updated the copyright info in SerDrive and changed an URL to point to the new site.
  • Updated the copyright info and version number in BIOSDRVS.
  • Updated the copyright info in XTIDECFG.
  • Optimizations in general.
File size: 3.4 KB
Line 
1; Project name  :   Assembly Library
2; Description   :   This is the place to put various generic macros.
3;                   Should be included immediately after Emulate.inc
4%ifndef MACROS_INC
5%define MACROS_INC
6
7;--------------------------------------------------------------------
8; Skips the immediately following 2 byte instruction by using it
9; as an immediate value to a dummy instruction.
10; Destroys the contents of %1.
11;
12; SKIP2B
13;   Parameters:
14;       %1:     Any 16 bit general purpose register or F for flags.
15;   Returns:
16;       Nothing
17;   Corrupts registers:
18;       %1
19;--------------------------------------------------------------------
20%macro SKIP2B 1.nolist
21    %ifidni     %1, f
22        db  03Dh                    ; Opcode byte for CMP AX, <immed>
23        ;db 0A9h                    ; Alt. version TEST AX, <immed>
24    %elifidni   %1, ax
25        db  0B8h                    ; Opcode byte for MOV AX, <immed>
26    %elifidni   %1, cx
27        db  0B9h                    ; Opcode byte for MOV CX, <immed>
28    %elifidni   %1, dx
29        db  0BAh                    ; Opcode byte for MOV DX, <immed>
30    %elifidni   %1, bx
31        db  0BBh                    ; Opcode byte for MOV BX, <immed>
32    %elifidni   %1, sp
33        db  0BCh                    ; Opcode byte for MOV SP, <immed>
34    %elifidni   %1, bp
35        db  0BDh                    ; Opcode byte for MOV BP, <immed>
36    %elifidni   %1, si
37        db  0BEh                    ; Opcode byte for MOV SI, <immed>
38    %elifidni   %1, di
39        db  0BFh                    ; Opcode byte for MOV DI, <immed>
40    %else
41        %error "Invalid parameter passed to SKIP2B"
42    %endif
43%endmacro
44
45
46;--------------------------------------------------------------------
47; Load BDA (Bios Data Area) segment to wanted segment register.
48;
49; Use an exclamation point (!) as the third parameter when you want
50; to force the use of the register in the second parameter. This is
51; useful when that register needs to be zeroed in subsequent code or
52; when stack usage is undesirable (ie speed is critical).
53;
54; The PRESERVE_FLAGS version will zero the register with a MOV instead
55; of an XOR, thus preserving the flags.  It is one byte larger on
56; non-186 or higher systems.
57;
58; LOAD_BDA_SEGMENT_TO
59; LOAD_BDA_SEGMENT_PRESERVE_FLAGS_TO
60;   Parameters:
61;       %1:     Destination Segment Register
62;       %2:     Temporary WORD Register
63;       %3:     Can be ! or empty
64;   Returns:
65;       %1:     BDA segment (zero)
66;   Corrupts registers:
67;       %2
68;--------------------------------------------------------------------
69%macro LOAD_BDA_SEGMENT_TO 2-3
70%ifndef USE_186
71    xor     %2, %2
72    mov     %1, %2
73%elifidn %3, !
74    xor     %2, %2
75    mov     %1, %2
76%else
77    push    BYTE 0
78    pop     %1
79%endif
80%endmacro
81
82%macro LOAD_BDA_SEGMENT_PRESERVE_FLAGS_TO 2-3
83%ifndef USE_186
84    mov     %2, 0
85    mov     %1, %2
86%elifidn %3, !
87    mov     %2, 0
88    mov     %1, %2
89%else
90    push    BYTE 0
91    pop     %1
92%endif
93%endmacro
94
95
96;--------------------------------------------------------------------
97; eENTER_STRUCT
98;   Parameters:
99;       %1:     Number of bytes to reserve from stack
100;   Returns:
101;       SS:BP:  Ptr to beginning of struct reserved from stack
102;   Corrupts registers:
103;       FLAGS
104;--------------------------------------------------------------------
105%macro eENTER_STRUCT 1
106    push    bp
107    sub     sp, %1
108    mov     bp, sp
109%endmacro
110
111;--------------------------------------------------------------------
112; eLEAVE_STRUCT
113;   Parameters:
114;       %1:     Number of bytes reserved with eENTER_STRUCT
115;   Returns:
116;       BP:     What it was before eENTER_STRUCT
117;   Corrupts registers:
118;       FLAGS
119;--------------------------------------------------------------------
120%macro eLEAVE_STRUCT 1
121    add     sp, %1
122    pop     bp
123%endmacro
124
125
126%endif ; MACROS_INC
Note: See TracBrowser for help on using the repository browser.