Changeset 624 in xtideuniversalbios for trunk/Assembly_Library/Inc


Ignore:
Timestamp:
Oct 2, 2022, 7:30:02 PM (19 months ago)
Author:
krille_n_
Message:

Changes:

  • The BIOS version string has been changed to show the repository revision number instead of the useless "v2.0.0 beta 3+" string. In other words, the seemingly never ending beta is finally over! The version string is now updated by TortoiseSVN client side hook scripts (residing in \Tools) to be used when committing changes to the repository. It should also be possible to use these scripts with other subversion clients under Windows since they are essentially just regular batch (cmd) files!
  • The eSEG_STR macro has been changed to always disable interrupts. The workaround used for the buggy, early revisions of the 8088/8086 CPUs apparently does not work. Many thanks to Jim Leonard (Trixter) for reporting this problem!
  • Minor optimizations to the eBSF and eBSR macros.
Location:
trunk/Assembly_Library/Inc
Files:
2 edited

Legend:

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

    r589 r624  
    88; JMP_WAIT_FOR_RETRACE_IF_NECESSARY_THEN
    99;   Parameters:
    10 ;       %1:     Instruction that accessed CGA memory
     10;       %1:     Instruction that accesses CGA memory
    1111;       AL:     Character to output
    1212;       AH:     Attribute to output (stosw only)
  • trunk/Assembly_Library/Inc/Emulate.inc

    r623 r624  
    188188;       %2:     Source WORD operand where to search bit (not CX or same as %1!)
    189189;   Returns:
     190;       %1:     Index of lowest order bit from %2
     191;       ZF:     Set if %2 is zero
     192;               Cleared if %2 is non-zero
     193;   Corrupts registers:
     194;       Nothing
     195;--------------------------------------------------------------------
     196%macro eBSF 2
     197%ifndef USE_386
     198    FSIS    ], %2               ; %2 is a memory operand?
     199    %if strpos
     200        cmp     WORD %2, BYTE 0 ; Source operand is zero?
     201        je      SHORT %%Return  ;  If so, return with ZF set
     202    %else                       ; No, %2 is a register
     203        test    %2, %2
     204        jz      SHORT %%Return
     205    %endif
     206
     207    push    cx
     208
     209%ifdef USE_NEC_V
     210    mov     cx, -1
     211
     212ALIGN JUMP_ALIGN
     213%%BitLoop:
     214    inc     cx
     215    eTEST1  %2, cl
     216    jz      SHORT %%BitLoop
     217    mov     %1, cx
     218
     219%else ; ~USE_NEC_V
     220    mov     cx, 1<<15
     221    mov     %1, -1
     222
     223ALIGN JUMP_ALIGN
     224%%BitLoop:
     225    rol     cx, 1               ; Prepare to test next bit
     226    inc     %1                  ; Increment bit index
     227    test    %2, cx              ; Bit set?
     228    jz      SHORT %%BitLoop
     229%endif
     230
     231    pop     cx
     232
     233%%Return:
     234;-----------------------------------
     235%else ; USE_386
     236    bsf     %1, %2
     237%endif
     238%endmacro
     239
     240
     241;--------------------------------------------------------------------
     242; Emulates BSR (Bit Scan Reverse) instruction when necessary.
     243; BSR is used to find index of most significant bit.
     244;
     245; eBSR
     246;   Parameters:
     247;       %1:     Destination WORD Register for bit index (not CX or same as %2!)
     248;       %2:     Source WORD operand where to search bit (not CX or same as %1!)
     249;   Returns:
    190250;       %1:     Index of highest order bit from %2
    191251;       ZF:     Set if %2 is zero
     
    194254;       Nothing
    195255;--------------------------------------------------------------------
    196 %macro eBSF 2
     256%macro eBSR 2
    197257%ifndef USE_386
    198     cmp     WORD %2, BYTE 0     ; Source operand is zero?
    199     je      SHORT %%Return      ;  If so, return with ZF set
    200 
    201     ; Set destination to zero and load mask for bit 0
     258    FSIS    ], %2               ; %2 is a memory operand?
     259    %if strpos
     260        cmp     WORD %2, BYTE 0 ; Source operand is zero?
     261        je      SHORT %%Return  ;  If so, return with ZF set
     262    %else                       ; No, %2 is a register
     263        test    %2, %2
     264        jz      SHORT %%Return
     265    %endif
     266
    202267    push    cx
    203     xor     %1, %1
    204     mov     cx, 1
     268
     269%ifdef USE_NEC_V
     270    mov     cx, 16
    205271
    206272ALIGN JUMP_ALIGN
    207273%%BitLoop:
    208     test    %2, cx              ; Bit set?
    209     jnz     SHORT %%PopAndReturn;  If so, return with ZF cleared
    210     shl     cx, 1               ; Prepare to test next bit
    211     inc     %1                  ; Increment bit index
    212     jmp     SHORT %%BitLoop     ; Loop until bit found
    213 %%PopAndReturn:
    214     pop     cx
    215 %%Return:
    216 ;-----------------------------------
    217 %else
    218     bsf     %1, %2
    219 %endif
    220 %endmacro
    221 
    222 
    223 ;--------------------------------------------------------------------
    224 ; Emulates BSR (Bit Scan Reverse) instruction when necessary.
    225 ; BSR is used to find index of most significant bit.
    226 ;
    227 ; eBSR
    228 ;   Parameters:
    229 ;       %1:     Destination WORD Register for bit index (not CX or same as %2!)
    230 ;       %2:     Source WORD operand where to search bit (not CX or same as %1!)
    231 ;   Returns:
    232 ;       %1:     Index of highest order bit from %2
    233 ;       ZF:     Set if %2 is zero
    234 ;               Cleared if %2 is non-zero
    235 ;   Corrupts registers:
    236 ;       Nothing
    237 ;--------------------------------------------------------------------
    238 %macro eBSR 2
    239 %ifndef USE_386
    240     cmp     WORD %2, BYTE 0     ; Source operand is zero?
    241     je      SHORT %%Return      ;  If so, return with ZF set
    242 
    243     ; Load mask for highest order bit
    244     push    cx
    245     mov     cx, 1<<15
    246     mov     %1, 15
     274    dec     cx
     275    eTEST1  %2, cl
     276    jz      SHORT %%BitLoop
     277    mov     %1, cx
     278
     279%else ; ~USE_NEC_V
     280    mov     cx, 1
     281    mov     %1, 16
    247282
    248283ALIGN JUMP_ALIGN
    249284%%BitLoop:
     285    ror     cx, 1               ; Prepare to test next bit
     286    dec     %1                  ; Decrement bit index
    250287    test    %2, cx              ; Bit set?
    251     jnz     SHORT %%PopAndReturn;  If so, return with ZF cleared
    252     shr     cx, 1               ; Prepare to test next bit
    253     dec     %1                  ; Decrement bit index
    254     jmp     SHORT %%BitLoop     ; Loop until bit found
    255 %%PopAndReturn:
     288    jz      SHORT %%BitLoop
     289%endif
     290
    256291    pop     cx
    257 %%Return:
    258 ;-----------------------------------
    259 %else
     292
     293%%Return:
     294;-----------------------------------
     295%else ; USE_386
    260296    bsr     %1, %2
    261297%endif
     
    539575;       %2:     Source segment override (destination is always ES)
    540576;       %3:     String instruction
     577;       %4:     An exclamation mark (!) if the state of the IF must
     578;               be preserved (can not be used together with CMPS or
     579;               SCAS instructions), otherwise it will be set on
     580;               return from the macro (i.e. interrupts will be on)
    541581;       CX:     Repeat count
    542582;   Returns:
    543 ;       FLAGS for cmps and scas only
     583;       FLAGS for CMPS and SCAS only
    544584;   Corrupts registers:
    545585;       FLAGS
    546586;--------------------------------------------------------------------
    547 %macro eSEG_STR 3
    548 %ifndef USE_186 ; 8088/8086 has string instruction restart bug when more than one prefix
    549     %%Loop:
    550         %1                      ; REP is the prefix that can be lost
    551         %2                      ; SEG is the prefix that won't be lost
    552         %3                      ; String instruction
    553 FSIS    cmps, %3
     587%macro eSEG_STR 3-4
     588%ifndef USE_186 ; 8088/8086 has string instruction restart bug when using more than one prefix
     589%ifidn %4, !                ; Preserve the IF
     590    FSIS    cmps, %3
    554591%ifn strpos
    555592    FSIS    scas, %3
    556593%endif
    557 %if strpos                      ; Must preserve FLAGS
    558         jcxz    %%End           ; Jump to end if no repeats left (preserves FLAGS)
    559         jmp     SHORT %%Loop    ; Loop while repeats left
    560     %%End:
    561 %else                           ; No need to preserve FLAGS
    562         inc     cx
    563         loop    %%Loop
    564 %endif
    565 %else   ; No bug on V20/V30 and later, don't know about 188/186
     594%if strpos
     595    %error "The state of the IF can not be preserved when using CMPS or SCAS!"
     596%endif
     597    pushf
     598    cli
     599    %1                      ; REP is the prefix that can be lost
     600    %2                      ; SEG is the prefix that won't be lost
     601    %3                      ; String instruction
     602    popf
     603%else                       ; No need to preserve the IF
     604    cli
     605    %1
     606    %2
     607    %3
     608    sti
     609%endif
     610%else   ; No bug on V20/V30/188/186 and later
    566611    %2
    567612    %1 %3
Note: See TracChangeset for help on using the changeset viewer.