Changeset 592 in xtideuniversalbios for trunk/Assembly_Library/Inc/Emulate.inc
- Timestamp:
- Jun 25, 2018, 10:29:27 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Assembly_Library/Inc/Emulate.inc
r589 r592 60 60 61 61 ;-------------------------------------------------------------------- 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 ;-------------------------------------------------------------------- 62 92 ; The undocumented instruction SALC (Set AL According to CF). 63 93 ; Available on all Intel processors and truly compatible clones. … … 108 138 ;-------------------------------------------------------------------- 109 139 ; 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 processors112 ; unless %1 is 10 (0Ah).113 140 ; 114 141 ; eAAM … … 152 179 %macro eBSF 2 153 180 %ifndef USE_386 154 push cx155 181 cmp WORD %2, BYTE 0 ; Source operand is zero? 156 182 je SHORT %%Return ; If so, return with ZF set 157 183 158 184 ; Set destination to zero and load mask for bit 0 185 push cx 159 186 xor %1, %1 160 187 mov cx, 1 … … 163 190 %%BitLoop: 164 191 test %2, cx ; Bit set? 165 jnz SHORT %% Return; If so, return with ZF cleared192 jnz SHORT %%PopAndReturn; If so, return with ZF cleared 166 193 shl cx, 1 ; Prepare to test next bit 167 194 inc %1 ; Increment bit index 168 195 jmp SHORT %%BitLoop ; Loop until bit found 169 %% Return:196 %%PopAndReturn: 170 197 pop cx 198 %%Return: 171 199 ;----------------------------------- 172 200 %else … … 193 221 %macro eBSR 2 194 222 %ifndef USE_386 195 push cx196 223 cmp WORD %2, BYTE 0 ; Source operand is zero? 197 224 je SHORT %%Return ; If so, return with ZF set 198 225 199 226 ; Load mask for highest order bit 227 push cx 200 228 mov cx, 1<<15 201 229 mov %1, 15 … … 204 232 %%BitLoop: 205 233 test %2, cx ; Bit set? 206 jnz SHORT %% Return; If so, return with ZF cleared234 jnz SHORT %%PopAndReturn; If so, return with ZF cleared 207 235 shr cx, 1 ; Prepare to test next bit 208 236 dec %1 ; Decrement bit index 209 237 jmp SHORT %%BitLoop ; Loop until bit found 210 %% Return:238 %%PopAndReturn: 211 239 pop cx 240 %%Return: 212 241 ;----------------------------------- 213 242 %else … … 260 289 261 290 %macro eCMOVE 2 262 eCMOVZ 291 eCMOVZ %1, %2 263 292 %endmacro 264 293 265 294 %macro eCMOVNE 2 266 eCMOVNZ 295 eCMOVNZ %1, %2 267 296 %endmacro 268 297 269 298 %macro eCMOVB 2 270 jnb SHORT %%Return 271 mov %1, %2 272 %%Return: 299 eCMOVC %1, %2 273 300 %endmacro 274 301 … … 289 316 ; Conditional Set. 290 317 ; 291 ; e CSETcc318 ; eSETcc 292 319 ; Parameters: 293 320 ; %1: Destination data … … 297 324 ; Flags 298 325 ;-------------------------------------------------------------------- 299 %macro e CSETZ 1326 %macro eSETZ 1 300 327 mov %1, 0 ; Clear while preserving flags 301 328 jnz SHORT %%Return ; Nothing to set … … 304 331 %endmacro 305 332 306 %macro e CSETNZ 1333 %macro eSETNZ 1 307 334 mov %1, 0 ; Clear while preserving flags 308 335 jz SHORT %%Return ; Nothing to set … … 339 366 xor dh, dh 340 367 %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 346 381 %endif 347 382 ;----------------------------------- … … 484 519 ; eSEG_STR 485 520 ; Parameters: 486 ; %1: REP/REP NE or REPEprefix521 ; %1: REP/REPE/REPZ or REPNE/REPNZ prefix 487 522 ; %2: Source segment override (destination is always ES) 488 523 ; %3: String instruction … … 491 526 ; FLAGS for cmps and scas only 492 527 ; Corrupts registers: 493 ; Nothing528 ; FLAGS 494 529 ;-------------------------------------------------------------------- 495 530 %macro eSEG_STR 3 … … 499 534 %2 ; SEG is the prefix that won't be lost 500 535 %3 ; String instruction 536 FSIS cmps, %3 537 %ifn strpos 538 FSIS scas, %3 539 %endif 540 %if strpos ; Must preserve FLAGS 501 541 jcxz %%End ; Jump to end if no repeats left (preserves FLAGS) 502 542 jmp SHORT %%Loop ; Loop while repeats left 503 543 %%End: 544 %else ; No need to preserve FLAGS 545 inc cx 546 loop %%Loop 547 %endif 504 548 %else ; No bug on V20/V30 and later, don't know about 188/186 505 549 %2 … … 556 600 %ifdef USE_386 557 601 %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 559 608 %else 560 609 eSHIFT_IM %1, %2, shl … … 582 631 %ifdef USE_386 583 632 %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 585 639 %else 586 640 eSHIFT_IM %1, %2, rcl
Note:
See TracChangeset
for help on using the changeset viewer.