Changeset 121 for trunk/bootcode/regular/other.asm
- Timestamp:
- Apr 8, 2017, 12:27:20 AM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bootcode/regular/other.asm
r119 r121 643 643 MBR_TeletypeSyncPos EndP 644 644 645 ;------------------------------------------------------------------------------ 645 646 ; Check if a memory block is all zeros 646 ; IN : BX pointer to memblock 647 ; CX length to check, zero length is interpreted as block is zero 648 ; OUT : ZF=1 block if all zeros 649 ; NOTE: Segment used is DS, which should be the same as ES 650 IsMemBlockZero Proc Near Uses ax di 651 push es ; Save ES just to be sure 647 ;------------------------------------------------------------------------------ 648 ; IN : BX pointer to memblock 649 ; : CX length to check, zero length is interpreted as block is zero 650 ; OUT : ZF=1 block if all zeros 651 ; NOTE : Segment used is DS, which should be the same as ES 652 ;------------------------------------------------------------------------------ 653 IsMemBlockZero Proc Near Uses ax di es 652 654 push ds ; Segment to use 653 655 pop es ; Pop in ES because ES is required for scasb 654 656 mov di, bx ; Pointer to memblock 655 657 xor al, al ; Compare to zero 658 cld ; Direction upwards 656 659 repe scasb ; Scan the block, will leave ZF=1 if all zeros 657 mov bx, di ; Update pointer (points past last byte compared)658 pop es ; Restore ES659 660 ret 660 661 IsMemBlockZero EndP 661 662 663 ;------------------------------------------------------------------------------ 662 664 ; Check if a loaded sector is all zeros 663 ; IN : BX pointer to memblock 664 ; OUT : ZF=1 block if all zeros 665 ; NOTE: Segment used is DS, which should be the same as ES 665 ;------------------------------------------------------------------------------ 666 ; IN : BX pointer to memblock 667 ; OUT : ZF=1 block if all zeros 668 ; NOTE : Segment used is DS 669 ;------------------------------------------------------------------------------ 666 670 IsSectorZero Proc Near Uses cx 667 671 mov cx, sector_size ; Normal size of a sector (512 bytes) … … 669 673 ret 670 674 IsSectorZero EndP 675 676 ;------------------------------------------------------------------------------ 677 ; Fill a memory block with a specific value 678 ;------------------------------------------------------------------------------ 679 ; IN : AL value to fill block with 680 ; : BX pointer to memblock 681 ; : CX length to fill, 0 fills nothing 682 ; OUT : ZF=1 if fill value was 0 683 ; NOTE : Segment used is DS 684 ;------------------------------------------------------------------------------ 685 FillMemBlock Proc Near Uses cx di es 686 push ds ; Segment to use 687 pop es ; Pop in ES because ES is required for scasb 688 mov di, bx ; Pointer to memblock 689 cld ; Direction upwards 690 rep stosb ; Fill the memory block with value in AL 691 test al, al ; Set ZR if fill value used is 0 692 ret 693 FillMemBlock EndP 694 695 ;------------------------------------------------------------------------------ 696 ; Fill a memory block with zeros 697 ;------------------------------------------------------------------------------ 698 ; IN : BX pointer to memblock 699 ; : CX length to fill, 0 fills nothing 700 ; OUT : Nothing 701 ; NOTE : Segment used is DS 702 ;------------------------------------------------------------------------------ 703 ClearMemBlock Proc Near Uses ax 704 xor al, al ; Fill value 705 call FillMemBlock ; Fill the memory block 706 ret 707 ClearMemBlock EndP 708 709 ;------------------------------------------------------------------------------ 710 ; Clears a sector buffer 711 ;------------------------------------------------------------------------------ 712 ; IN : BX pointer to sector buffer 713 ; OUT : Nothing 714 ; NOTE : Segment used is DS 715 ;------------------------------------------------------------------------------ 716 ClearSectorBuffer Proc Near Uses cx 717 mov cx, sector_size ; Normal size of a sector (512 bytes) 718 call ClearMemBlock ; Clear the sector buffer 719 ret 720 ClearSectorBuffer EndP 721
Note:
See TracChangeset
for help on using the changeset viewer.