home *** CD-ROM | disk | FTP | other *** search
- page 60,132
- title coretest deluxe
- ; Version 1.0
- ; written by David Fox
- ; copyright (C) 1986
- ;
- .sall
- if1
- include macros.lib
- endif
- codeseg segment
- assume cs:codeseg,ds:codeseg
- org 100h ;for COM files
- start:
- push es ;for restoring at end
- cld ;forward
- cls
- locate 3,20 ;sign on and
- print signon
- locate 4,20 ;print copyright notice
- print copynote ;
- mov ax,0 ;set
- mov es,ax ;segment 0 through ES
- mov ax,es:[413h] ;get memory size
- push ax ;to print out to user
- locate 5,20
- print rammsg ;'You have '
- call bindec ;on screen
- pop ax
- mov dl,64 ;in terms of
- div dl ;highest block->A=640K
- mov lastblock,ax
- print kmsg ;'K of memory.'
- locate 6,20
- print askfile ;Ask user if he wants to send error
- inkey ;messages to a file.
- mov isfile,al ; for later testing in error proc
- cmp al,'y'
- je getfile
- cmp al,'Y'
- je getfile
- jmp short nofile
- getfile:
- locate 6,20
- print blank1 ; blank out a message
- locate 6,20
- print filemsg
- input buffer ; Get file name from user.
- lea bx,buffer + 1 ; get actual length of input
- xor ch,ch ; make sure ch =0
- mov cl,[bx] ; and get length.
- lea bx,buffer + 2 ; ->actual start of input
- putz:
- inc bx ; one more time
- loop putz ; terminate with
- ; max characters read...
- mov byte ptr [bx],0 ; Now it's an asciiZ string.
- open buffer+2 ; Open the file.
- mov handle,ax ; save the handle
- extend ax ; OPEN EXTEND file
- nofile:
- locate 7,20
- print beginmsg ;'Begin Ramtest'
- xor ax,ax ; es -> block begin
- testlp:
- push ax
- locate 10,20
- pop ax
- call setup ; setup test & print out block message
- testlp1:
- ; first test to see if es:bx is in range of
- ; cs:start to cs:endloc
- call getsegs
- ; compare ch and al, if equal, same segment.
- cmp al,ch
- jne goon
- sameseg:
- ; now compare bx to see in range of begloc-endloc
- ; if so, skip memory check in this area
- cmp bx,begloc
- jge nexttest
- jmp short goon
- nexttest:
- cmp bx,endloc
- jle skipit
- goon:
- ; to save time, just print out every 16 locations tested.
- call chkdiv ; check divisibility by 16
- jne skip
- push bx ; print address out
- locate 10,50
- call binhex
- pop bx
- skip:
- mov ax,es ; Are we in segment zero?
- or ax,ax
- jnz nozero ; skip test if yes
- ; Check first if address in range of
- ; used interrupts. If so, disable them.
-
- cmp bx,21h*4+4 ; last address of used interrupt
- jle skipit ; go if not less to re-enable interrupts
- nozero:
- mov al,es:[bx] ; save it
- call test0 ; test all zeros
- jz okay ; all right
- call error ; if not...error
- okay:
-
- call testff ; test all ones
- jz okay1 ; all right
- call error ; if not...error
- okay1:
- call test55 ; test alternating pattern 55
- jz okay2 ; all right
- call error ; if not...error
- okay2:
- call testaa ; test alternating pattern aa
- jz okay3 ; all right
- call error ; if not...error
- okay3:
- mov es:[bx],al ; restore byte
- skipit:
- dec bx ; another
- jnz testlp1 ; byte
- mov ax,es ; another
- inc ax
- mov es,ax ; segment
- cmp ax,lastblock ; done yet
- jl testlp ; go get another block if not
- print completemsg ; 'Completed'
- pop es
- close handle ; Close file.
- int 20h ;back to dos
- ;
- ; PROGRAM DATA
- ;
- signon db 'C O R E T E S T DELUXE 1.0$'
- copynote db '(C) 1986 by David E. Fox $'
- rammsg db 'You have $'
- kmsg db 'K of memory$'
- beginmsg db 'Begin Ramtest',13,10,'$'
- completemsg db 'Completed Ram Test',13,10,'$'
- lastblock dw ?
- zerosw db ?
- save dw ?
- testmsg db 'Testing 64K Block # $'
- errormsg db 'Error at Address $'
- datemsg db 'Date is '
- askfile db 'Do you want errors to be sent to a file (y/n) $'
- asklen equ $-askfile
- blank1 db (asklen+1) dup (' '),'$'
- filemsg db 'Enter file name -->$'
- filelen equ $-filemsg
- filesize dd 0
- org filesize
- filelow dw ?
- filehigh dw ?
- blank2 db (filelen+1) dup (' '),'$'
- buffer equ $ ; Set up for keyboard read
- maxsiz equ 64
- maxcnt db maxsiz ; Maximum count of buffer
- realcnt db ? ; Actual Characters read
- inbuf db (maxsiz+1) dup (0) ; Input buffer, forced ASCIIZ
- ; string.
- crlf db 10,13,'$'
- handle dw ? ; File handle
- filebuf db 80 dup (0) ; buffer area
- buflen dw ? ; buffer length
- curseg dw ? ; current seg:offset
- curoff dw ? ; location at memtest error
- begloc dw start ; storage for 20-bit seg:offset
- begseg db 0 ; representation
- endloc dw lastloc ; of program's starting and
- endseg db 0 ; ending locations
- fileon db 0 ; switches for sending output
- isfile db ? ; (errors) to an error file
- ;
- chkdiv proc near
- mov cl,4
- mov save,bx
- shr bx,cl ; After shifting back and forth,
- shl bx,cl ; equality means that BX is divisible
- cmp bx,save ; by 16.
- mov bx,save
- ret
- chkdiv endp
- ;
- binhex proc near
- ;Converts a 16 bit number to hexadecimal Ascii on screen.
- ;
- push bp ; set up
-
- mov bp,sp ; stack
- ; [bp] = saved bp
- ; 2[bp] = return address (near)
- ; 4[bp] = our data
- mov bx,4[bp]
- mov ch,4
- rotate:
- mov cl,4
- rol bx,cl
- mov al,bl
- and al,0fh
- add al,30h
- cmp al,3ah
- jl printit
- add al,7
- printit:
- mov dl,al
- mov ah,fileon ; check send to file buffer
- or ah,ah
- je nosend1
- mov byte ptr [di],dl ; send char to buffer
- inc di
- nosend1:
- mov ah,2
- int 21h
- dec ch
- jnz rotate
- pop bp
- ret
- binhex endp
- bindec proc near
- ;Converts a 16 bit number to Decimal Ascii on screen.
- ;
- push bp ; set up
-
- mov bp,sp ; stack
- ; [bp] = saved bp
- ; 2[bp] = return address (near)
- ; 4[bp] = our data
- mov bx,4[bp]
- mov zerosw,'y'
- mov cx,10000d
- call decdiv
- mov cx,1000d
- call decdiv
- mov cx,100d
- call decdiv
- mov cx,10d
- call decdiv
- mov cx,1
- call decdiv
- pop bp
- ret
- bindec endp
- decdiv proc near
- mov ax,bx
- cwd
- div cx
- mov bx,dx
- mov dl,al
- add dl,30h
- cmp dl,30h
- jz itzero
- mov zerosw,'n'
- jmp short noblank
- itzero:
- cmp zerosw,'y'
- jnz noblank
- cmp cx,1
- jz noblank
- mov dl,' '
- noblank:
- mov ah,fileon ; check send to file buffer
- or ah,ah
- je nosend
- mov byte ptr [di],dl ; send char to buffer
- inc di
- nosend:
- mov ah,2
- int 21h
- ret
- decdiv endp
-
-
- getsegs proc near
- mov ax,cs ; cs/16--actual seg.
- mov cl,4
- shr ax,cl
- mov begseg,al
- mov ch,al
- mov ax,es
- shr ax,cl
- mov endseg,al
- ret
- getsegs endp
-
- setup proc near
- push ax
- print testmsg ;'Testing block'
- pop ax
- mov es,ax ; initial segment: 0
- push ax ; Print out block # in
- call bindec ; Decimal
- pop ax
- xor bx,bx ; es:[bx] es:0000-es:FFFF
- ret
- setup endp
-
- settle proc near
- mov cx,500
- setlp:
- loop setlp
- ret
- settle endp
-
- error proc near ; Error procedure
- mov cx,256
- ;
- ; Load the byte in question with successive values from 0-255
- ; to check if a real hard error exists. If none, return.
- ;
- errlp:
- inc byte ptr es:[bx]
- loop errlp
- mov es:[bx],al ; restore byte
- mov curseg,es ; save off where we are
- mov curoff,bx
- call settle ; wait a bit
- cmp es:[bx],al ; then compare
- jnz real_error ; If not equal now, there's problems!
- ret
- ;
- real_error:
- mov dl,7 ; Beep
- mov ah,5 ; the keyboard
- int 21h
- push es
- call binhex ; Print out segment
- pop es
- mov dl,':' ; a ':'
- mov ah,5
- int 21h
- push bx ; And offset of error
- call binhex
- pop bx
- print crlf ; and end with cr-lf.
- cmp isfile,'y' ; send to file?
- je fileit
- cmp isfile,'Y'
- je fileit
- ; didn't want a file, go back
- ret
- fileit:
- mov fileon,1
- push es
- push cs
- pop es ;new es for string move routines
- lea si,datemsg ; move date
- lea di,filebuf ; to file
- mov cx,length datemsg
- rep movsb
- mov byte ptr [di],' ' ; move a space
- inc di ; to buffer
- mov ah,2ah ; get dos
- int 21h ; date in cx:dx
- push dx
- mov cl,8
- shr dx,cl ; prepare to get month
- call bindec ; send it out
- mov byte ptr [di],'/' ; and a '/'
- pop dx
- push dx
- xor dh,dh ; get day
- call bindec ; send it out
- pop dx
- mov word ptr [di],0a0dh ; send CR/LF
- add di,2
- lea dx,filebuf ; calculate
- sub di,dx ; actual buffer length
- writeseq handle,di,filebuf ; write to file
- lea si, errormsg ; move error message
- lea di, filebuf ; to filebuffer
- mov cx, length errormsg-1 ; don't send '$'
- ; ^ this has nothing to do
- ; with my financial
- ; situation
- rep movsb
- mov byte ptr [di],' ' ; move a space
- inc di ; to buffer
- push curseg ; current segment
- call binhex ; send it out
- mov byte ptr [di],':' ; send colon
- push curoff ; current offset
- call binhex ; send it out
- add sp,2 ; balance stack
- mov word ptr [di],0a0dh ; send CR/LF
- add di,2 ; get actual length
- lea dx, filebuf
- sub di,dx
- writeseq handle,di,filebuf ; and send it out
- pop es ; restore es
- mov fileon,0
- error endp
- test0 proc near
- mov byte ptr es:[bx],0 ; test all zeros
- call settle ; wait a bit
- cmp byte ptr es:[bx],0 ; is it a 0?
- ret
- test0 endp
-
- testff proc near
- mov byte ptr es:[bx],0ffh ; test all ones
- call settle ; wait a bit
- cmp byte ptr es:[bx],0ffh ; is it all ones?
- ret
- testff endp
-
- test55 proc near
- mov byte ptr es:[bx],55h ; test alternating pattern 1
- call settle ; wait a bit
- cmp byte ptr es:[bx],55h ; is it right?
- ret
- test55 endp
-
- testaa proc near
- mov byte ptr es:[bx],0aah ; test alternating pattern 2
- call settle ; wait a bit
- cmp byte ptr es:[bx],0aah ; is it right?
- ret
- testaa endp
- lastloc equ $ ; last location of program
- main endp
- codeseg ends
- end start