;******************************************** ; Program Written by: HARRIS LANDSBERG c1985 ; Name: MORE.ASM using standard 8080 ASM code ; ; Designed as a MS-DOS More filter simulation ; when listing a file to the crt device. ; ; Comment: Will clear keyboard buffer if keys ; are held down too long accidently. One of ; my first attempts in Assembler. Control C ; at --more-- prompt will return to CP/M. ; ; Run: MORE [d:]filename[.ext], no "*" or "?" ;******************************************** bdos equ 0005H ;function call location fcb equ 005CH ;file control block dma equ 0080H ;dma buffer location dmal equ 128 ;dma length sline equ 23 ;lines per screen filel equ 11 ;filename.ext length rchr equ 1 ;read character function pchr equ 2 ;output character function drio equ 6 ;direct i/o function pstr equ 9 ;string output function open equ 15 ;open file function read equ 20 ;read sequential record sdma equ 26 ;set dma location ctrc equ 3 ;control c (break) lf equ 10 ;line feed cr equ 13 ;carriage return ctrz equ 26 ;file end charcter wildc equ '?' ;wildcard character iread equ 0FFH ;input using direct i/o ; start org 0100H ;start location ; lxi h,fcb+1 ;filename location mvi b,filel ;file length check mov a,m ;memory -> accumulator cpi wildc ;wildcard? jz invnam ;zero=invalid name inx h ;next position dcr b ;decrement count jnz check ;not zero=continue mvi c,sdma ;set dma location lxi d,dma call bdos mvi c,open ;open file lxi d,fcb ;name in fcb call bdos inr a ;test if found jz notf ;zero=not found rdfil mvi c,read ;read file lxi d,fcb ;name in fcb call bdos ana a ;test if end rnz ;not zero=end mvi b,dmal ;d=dma length lxi h,dma ;hl=dma location again mov a,m ;memory -> accumulator cpi ctrz ;end-of-file? rz ;zero=eof mov e,a ;reg a -> reg e cpi lf ;line feed? jnz nolf ;not zero=not lf lda line ;line variable -> reg a inr a ;increment sta line ;store back nolf inx h ! push h ;next position, save dcr b ! push b ;one less, save mvi c,pchr ;print character call bdos lda line ;line variable -> reg a cpi sline ;full screen? jnz nmore ;not zero=not full mvi c,pstr ;print string lxi d,more ;promt location call bdos xra a ;reset accumulator sta line ;store in line clkey mvi c,drio ;clear keyboard buffer mvi e,iread ;using direct i/o call bdos ana a jnz clkey ;again if not clear mvi c,rchr ;wait for character call bdos cpi ctrc ;break? jnz domore ;not zero=not break pop b ! pop h ;clean stack ret domore mvi c,pstr ;print character lxi d,crlf ;skip line call bdos nmore pop b ! pop h ;obtain stack info mov a,b ;reg b -> reg a ana a ;test jz rdfil ;zero=buffer finished jmp again ;more in buffer notf mvi c,pstr ;print string lxi d,fnot ;error message jmp bdos invnam mvi c,pstr ;print string lxi d,invn ;error message jmp bdos ; more db '--more--$' fnot db 'file not found$' invn db 'invalid filename$' line db 0 crlf db cr,lf,'$' ; end start