Title Checksum Generation Program for the MD-11 rom (27_Feb_84) ; ; Copyright 1984 ; Morrow Designs, Inc. ; San Leandro, Ca. ; ; bdos equ 5 ;Bdos Entry Point print equ 9 ; Print a String open equ 15 ; Open File close equ 16 ; Close File read equ 20 ; Read Sequential write equ 21 ; Write Sequential make equ 22 ; Make File setdma equ 26 ; Set the DMA Address fcb equ 5ch ;Start of the Default FCB .z80 aseg org 100h ;Open the file ld de,fcb ld c,open call bdos inc a jp nz,begin1 ld de,nofile ld c,print jp bdos ;error exit begin1: ld hl,buffer ld de,buffer+1 ld bc,8*1024-1 ;8k rom ld (hl),0ffh ;first cell inc hl ldir ld de,rdmsg ld c,print call bdos ;Print the reading checksum message ld a,0 ;set count push af ld de,buffer push de ld c,setdma call bdos ;Set the DMA Address to the buffer jp begin2 ; Read the File ;-------------- ; begin3: pop de pop af inc a push af ld hl,80h add hl,de push hl ex de,hl ld c,setdma call bdos begin2: ld de,fcb ld c,read call bdos or a jp z,begin3 ld de,check ld c,print call bdos ; Generate the ram checksum ;-------------------------- ; pop de ;discard ld hl,(buffer+5ch) ;get length of memtst ld b,h ld c,l ;length to bc ld hl,(buffer+5ah) ;get begin of memtst ld de,buffer add hl,de ;actual address ;the rom will move code to ram, into an even number of bytes of space ;the balance, less one byte for the checksum, will be filled with 0ffh ;thus, if the number of bytes of code is even, then the number of bytes ;remaining is even, less one makes odd. if odd, then we start with 0ffh ;since the v.parity of an odd number of bytes of 0ffh is 0ffh. ld a,c ;check length of code rrca ;move lsb to borrow ld a,0 ccf ;not borrow sbc a,0 ;if code count even fill odd, w/a=0ffh ;Checksum Loop clp: xor (hl) ;more parity inc hl ;pointer++ dec bc ;count-- ld e,a ld a,b or c ld a,e jp nz,clp ld (buffer+5eh),a ;ram checksum ; Generate Rom CheckSum ;---------------------- ; ld hl,buffer ld de,8*1024 ;length of test xor a gloop: xor (hl) ;checksum inc hl ;pointer++ dec de ;counter-- ld c,a ld a,d or e ld a,c jp nz,gloop ld hl,buffer+52h ;HL:= Start of manufacture's ID area ld b,8 ;B:= Count (number of bytes to ignore) lpN: xor (hl) ;Remove Manufacture's ID from checksum inc hl djnz lpN ld (buffer+5fh),a ;set Rom checksum ld de,wrtmsg ld c,print call bdos ;Print the Writing CheckSum Message ld de,fcb ld c,close call bdos ;Close the opened file ld de,fcb ld c,open call bdos ;Open the file again xor a ld (fcb+32),a ld de,buffer push de ld c,setdma call bdos ;Set the DMA address to start of buffer jp wloop1 ; Write the File back out to disk ;-------------------------------- ; wloop: pop de pop af dec a jp z,wcls push af ld hl,80h add hl,de push hl ex de,hl ld c,setdma call bdos wloop1: ld de,fcb ld c,write call bdos or a jp z,wloop ld de,werror ld c,print jp bdos ;error exit ; Close the Finished File ;------------------------ ; wcls: ld de,fcb ld c,close call bdos ld de,good ld c,print jp bdos ;success exit page ; Error Messages ;--------------- ; nofile: db 0dh,0ah,'No file by that name, Include ".COM"$' werror: db 0dh,0ah,'Write Error$' ; Status Messages ;---------------- ; rdmsg: db 0dh,0ah,'Reading File$' wrtmsg: db 0dh,0ah,'Writing File$' check: db 0dh,0ah,'Generating Checksum$' good: db 0dh,0ah,'Checksum Complete$' ; Data Areas ;----------- ; buffer: end