Ignore:
Timestamp:
Apr 8, 2017, 12:27:20 AM (8 years ago)
Author:
Ben Rietbroek
Message:

Added some simple memory block functions [v1.1.1-testing]

CAUTION:
This is a testbuild !
AirBoot uses the BIOS to access disks and a small coding error can trash
partition tables or other vital disk structures. You are advised to make
backups of TRACK0 and EBRs before using this testbuild. More info at:
https://rousseaux.github.io/netlabs.air-boot/pdf/AirBoot-v1.1.0-manual.pdf

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bootcode/regular/other.asm

    r119 r121  
    643643MBR_TeletypeSyncPos     EndP
    644644
     645;------------------------------------------------------------------------------
    645646; 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;------------------------------------------------------------------------------
     653IsMemBlockZero  Proc    Near    Uses ax di es
    652654        push    ds          ; Segment to use
    653655        pop     es          ; Pop in ES because ES is required for scasb
    654656        mov     di, bx      ; Pointer to memblock
    655657        xor     al, al      ; Compare to zero
     658        cld                 ; Direction upwards
    656659        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 ES
    659660        ret
    660661IsMemBlockZero  EndP
    661662
     663;------------------------------------------------------------------------------
    662664; 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;------------------------------------------------------------------------------
    666670IsSectorZero    Proc    Near    Uses cx
    667671        mov     cx, sector_size ; Normal size of a sector (512 bytes)
     
    669673        ret
    670674IsSectorZero    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;------------------------------------------------------------------------------
     685FillMemBlock    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
     693FillMemBlock    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;------------------------------------------------------------------------------
     703ClearMemBlock   Proc    Near    Uses ax
     704        xor     al, al          ; Fill value
     705        call    FillMemBlock    ; Fill the memory block
     706        ret
     707ClearMemBlock   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;------------------------------------------------------------------------------
     716ClearSectorBuffer   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
     720ClearSectorBuffer   EndP
     721
Note: See TracChangeset for help on using the changeset viewer.