Changeset 624 in xtideuniversalbios for trunk/Assembly_Library
- Timestamp:
- Oct 2, 2022, 7:30:02 PM (2 years ago)
- Location:
- trunk/Assembly_Library
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Assembly_Library/Inc/CgaSnow.inc
r589 r624 8 8 ; JMP_WAIT_FOR_RETRACE_IF_NECESSARY_THEN 9 9 ; Parameters: 10 ; %1: Instruction that accesse dCGA memory10 ; %1: Instruction that accesses CGA memory 11 11 ; AL: Character to output 12 12 ; AH: Attribute to output (stosw only) -
trunk/Assembly_Library/Inc/Emulate.inc
r623 r624 188 188 ; %2: Source WORD operand where to search bit (not CX or same as %1!) 189 189 ; 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 212 ALIGN 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 223 ALIGN 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: 190 250 ; %1: Index of highest order bit from %2 191 251 ; ZF: Set if %2 is zero … … 194 254 ; Nothing 195 255 ;-------------------------------------------------------------------- 196 %macro eBS F2256 %macro eBSR 2 197 257 %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 202 267 push cx 203 xor %1, %1 204 mov cx, 1 268 269 %ifdef USE_NEC_V 270 mov cx, 16 205 271 206 272 ALIGN JUMP_ALIGN 207 273 %%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 247 282 248 283 ALIGN JUMP_ALIGN 249 284 %%BitLoop: 285 ror cx, 1 ; Prepare to test next bit 286 dec %1 ; Decrement bit index 250 287 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 256 291 pop cx 257 %%Return: 258 ;----------------------------------- 259 %else 292 293 %%Return: 294 ;----------------------------------- 295 %else ; USE_386 260 296 bsr %1, %2 261 297 %endif … … 539 575 ; %2: Source segment override (destination is always ES) 540 576 ; %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) 541 581 ; CX: Repeat count 542 582 ; Returns: 543 ; FLAGS for cmps and scasonly583 ; FLAGS for CMPS and SCAS only 544 584 ; Corrupts registers: 545 585 ; FLAGS 546 586 ;-------------------------------------------------------------------- 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 554 591 %ifn strpos 555 592 FSIS scas, %3 556 593 %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 566 611 %2 567 612 %1 %3 -
trunk/Assembly_Library/Src/Display/DisplayFormat.asm
r592 r624 366 366 367 367 cmp si, BYTE 7Fh ; well within the boundaries of ROMVARS_size 368 jb .notFormatted368 jb SHORT .notFormatted 369 369 370 370 dec bp … … 373 373 inc bp ; will be decremented after the call is done 374 374 inc bp 375 jmp .done375 jmp SHORT .done 376 376 377 377 .notFormatted:
Note:
See TracChangeset
for help on using the changeset viewer.