Changeset 592 in xtideuniversalbios for trunk/Assembly_Library/Inc/Emulate.inc


Ignore:
Timestamp:
Jun 25, 2018, 10:29:27 PM (6 years ago)
Author:
krille_n_
Message:

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:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Assembly_Library/Inc/Emulate.inc

    r589 r592  
    6060
    6161;--------------------------------------------------------------------
     62; Find String In String
     63;
     64; FSIS
     65;   Parameters:
     66;       %1:     String to search for (case-insensitive)
     67;       %2:     String to search in
     68;   Returns:
     69;   strpos:     Position of %1 in %2 if found, 0 if not found
     70;--------------------------------------------------------------------
     71%macro FSIS 2.nolist
     72%defstr s1 %1
     73%defstr s2 %2
     74%strlen sl1 s1
     75%strlen sl2 s2
     76%assign strpos 0
     77    %if sl1 <= sl2
     78        %assign strpos sl2 - sl1 + 1
     79        %rep strpos
     80            %substr %%ss s2 strpos, sl1
     81            %ifidni %%ss, s1
     82                %exitrep
     83            %else
     84                %assign strpos strpos - 1
     85            %endif
     86        %endrep
     87    %endif
     88%endmacro
     89
     90
     91;--------------------------------------------------------------------
    6292; The undocumented instruction SALC (Set AL According to CF).
    6393; Available on all Intel processors and truly compatible clones.
     
    108138;--------------------------------------------------------------------
    109139; The AAM instruction (ASCII Adjust after Multiplication).
    110 ; Available on all Intel processors and truly compatible clones.
    111 ; Does not work on the NEC V20/V30 or Sony CXQ70108 processors
    112 ; unless %1 is 10 (0Ah).
    113140;
    114141; eAAM
     
    152179%macro eBSF 2
    153180%ifndef USE_386
    154     push    cx
    155181    cmp     WORD %2, BYTE 0     ; Source operand is zero?
    156182    je      SHORT %%Return      ;  If so, return with ZF set
    157183
    158184    ; Set destination to zero and load mask for bit 0
     185    push    cx
    159186    xor     %1, %1
    160187    mov     cx, 1
     
    163190%%BitLoop:
    164191    test    %2, cx              ; Bit set?
    165     jnz     SHORT %%Return      ;  If so, return with ZF cleared
     192    jnz     SHORT %%PopAndReturn;  If so, return with ZF cleared
    166193    shl     cx, 1               ; Prepare to test next bit
    167194    inc     %1                  ; Increment bit index
    168195    jmp     SHORT %%BitLoop     ; Loop until bit found
    169 %%Return:
     196%%PopAndReturn:
    170197    pop     cx
     198%%Return:
    171199;-----------------------------------
    172200%else
     
    193221%macro eBSR 2
    194222%ifndef USE_386
    195     push    cx
    196223    cmp     WORD %2, BYTE 0     ; Source operand is zero?
    197224    je      SHORT %%Return      ;  If so, return with ZF set
    198225
    199226    ; Load mask for highest order bit
     227    push    cx
    200228    mov     cx, 1<<15
    201229    mov     %1, 15
     
    204232%%BitLoop:
    205233    test    %2, cx              ; Bit set?
    206     jnz     SHORT %%Return      ;  If so, return with ZF cleared
     234    jnz     SHORT %%PopAndReturn;  If so, return with ZF cleared
    207235    shr     cx, 1               ; Prepare to test next bit
    208236    dec     %1                  ; Decrement bit index
    209237    jmp     SHORT %%BitLoop     ; Loop until bit found
    210 %%Return:
     238%%PopAndReturn:
    211239    pop     cx
     240%%Return:
    212241;-----------------------------------
    213242%else
     
    260289
    261290%macro eCMOVE 2
    262     eCMOVZ %1, %2
     291    eCMOVZ  %1, %2
    263292%endmacro
    264293
    265294%macro eCMOVNE 2
    266     eCMOVNZ %1, %2
     295    eCMOVNZ %1, %2
    267296%endmacro
    268297
    269298%macro eCMOVB 2
    270     jnb     SHORT %%Return
    271     mov     %1, %2
    272 %%Return:
     299    eCMOVC  %1, %2
    273300%endmacro
    274301
     
    289316; Conditional Set.
    290317;
    291 ; eCSETcc
     318; eSETcc
    292319;   Parameters:
    293320;       %1:     Destination data
     
    297324;       Flags
    298325;--------------------------------------------------------------------
    299 %macro eCSETZ 1
     326%macro eSETZ 1
    300327    mov     %1, 0           ; Clear while preserving flags
    301328    jnz     SHORT %%Return  ; Nothing to set
     
    304331%endmacro
    305332
    306 %macro eCSETNZ 1
     333%macro eSETNZ 1
    307334    mov     %1, 0           ; Clear while preserving flags
    308335    jz      SHORT %%Return  ; Nothing to set
     
    339366        xor     dh, dh
    340367    %else   ; SI, DI, BP (all may be used in effective address)
    341         push    ax
    342         mov     al, %2
    343         xor     ah, ah
    344         xchg    ax, %1
    345         pop     ax
     368        FSIS    %1, %2
     369        %if strpos
     370            push    ax
     371            mov     al, %2
     372            xor     ah, ah
     373            xchg    %1, ax
     374            pop     ax
     375        %else
     376            xchg    %1, ax
     377            mov     al, %2
     378            xor     ah, ah
     379            xchg    %1, ax
     380        %endif
    346381    %endif
    347382;-----------------------------------
     
    484519; eSEG_STR
    485520;   Parameters:
    486 ;       %1:     REP/REPNE or REPE prefix
     521;       %1:     REP/REPE/REPZ or REPNE/REPNZ prefix
    487522;       %2:     Source segment override (destination is always ES)
    488523;       %3:     String instruction
     
    491526;       FLAGS for cmps and scas only
    492527;   Corrupts registers:
    493 ;       Nothing
     528;       FLAGS
    494529;--------------------------------------------------------------------
    495530%macro eSEG_STR 3
     
    499534        %2                      ; SEG is the prefix that won't be lost
    500535        %3                      ; String instruction
     536FSIS    cmps, %3
     537%ifn strpos
     538    FSIS    scas, %3
     539%endif
     540%if strpos                      ; Must preserve FLAGS
    501541        jcxz    %%End           ; Jump to end if no repeats left (preserves FLAGS)
    502542        jmp     SHORT %%Loop    ; Loop while repeats left
    503543    %%End:
     544%else                           ; No need to preserve FLAGS
     545        inc     cx
     546        loop    %%Loop
     547%endif
    504548%else   ; No bug on V20/V30 and later, don't know about 188/186
    505549    %2
     
    556600%ifdef USE_386
    557601    %if %2 = 1
    558         add     %1, %1  ; Same size but faster on 386 and 486. Fails if %1 is a memory operand.
     602        FSIS    ], %1
     603        %if strpos
     604            eSHIFT_IM   %1, %2, shl
     605        %else
     606            add     %1, %1  ; Same size but faster on 386 and 486.
     607        %endif
    559608    %else
    560609        eSHIFT_IM   %1, %2, shl
     
    582631%ifdef USE_386
    583632    %if %2 = 1
    584         adc     %1, %1  ; Same size but faster on 386 and 486. Fails if %1 is a memory operand.
     633        FSIS    ], %1
     634        %if strpos
     635            eSHIFT_IM   %1, %2, rcl
     636        %else
     637            adc     %1, %1  ; Same size but faster on 386 and 486.
     638        %endif
    585639    %else
    586640        eSHIFT_IM   %1, %2, rcl
Note: See TracChangeset for help on using the changeset viewer.