home *** CD-ROM | disk | FTP | other *** search
- ;------------------------------------------------------:
- ; Filename....: RAMCLEAR.ASM :
- ; Author......: Dennis L. Dias :
- ; Source ID...: NAN449 :
- ; CompuServe..: 73765,302 :
- ; Date........: 06/22/86 :
- ; Purpose.....: Fill RAM with zeros from the lowest :
- ; user segment to the top of memory. :
- ; Note........: Convert to .COM file. :
- ;------------------------------------------------------:
-
- CODE SEGMENT PARA
- ASSUME CS:CODE,DS:CODE
- ORG 100H ;.COM file format
-
- ; the amount of installed memory is stored at offset 02H
- START: MOV DX,CS ;reference lowest user seg
- MOV BX,02H ;get top of memory from
- MOV AX,[BX] ; PSP and place in BX
- MOV BX,AX ; for segment counter
- XOR AX,AX ;zero used for fill
- CLD ;forward direction
-
- ; all but the last segment is cleared with this loop
- CLEAR_LOOP: SUB BX,1000H ;next lower 64k seg
- CMP BX,DX ;lower than lowest?
- JBE LAST_SEG
-
- MOV ES,BX ;load seg reg
-
- XOR DI,DI ;initial offset
- MOV CX,8000H ;word count for 64k
-
- REP STOSW ;fill with zeros
-
- JMP CLEAR_LOOP ;next segment
-
- ; the last segment contains fewer than 64 kilobytes
- LAST_SEG: PUSH CS ;set ES to local seg
- POP ES
-
- LEA DI,RAM_START ;first byte after program
-
- AND DX,0FFFH ;clear high nibble
- MOV CL,4 ;shift count
- SHL DX,CL ;convert to offset value
-
- ; DX now contains the offset from the next lower 64k boundary
- ADD DX,DI ;plus offset of end of program
-
- XOR CX,CX ;set CX = # of bytes above
- SUB CX,DX ; prog not yet cleared
-
- REP STOSB ;fill what's left to clear
-
- INT 20H ;terminate program
-
- RAM_START LABEL BYTE ;first byte after program
- CODE ENDS ;end of segment
- END START ;indicate program entry point