[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: New Assembler
Getting a lot of things working. All the functions below are now
working. This is really using CP/M properly! Bill - any issues with
compiling this?
; generic routines for assembly programs
; assemble using m80 and l80 (supersub zasm myfile)
; no dots in front of equ and org etc (this is
; different to tasm). For writing purely on a
; n8vem (eg wordstar) and compiling on the board
; but probably easier to write in notepad and
; then transfer to the board and compile there.
; 0. Warm boot
; 1. Read console - returns an ascii character
; 2. Write console - Sends an ascii character
; 3. Read reader
; 4. Write punch
; 5. Write list
; 6. Direct console input/output. Send FF to receive character status
; 7. Get I/O status of device
; 8. Set I/O status
; 9. Print buffer. Send entire string starting with address and ending
with $
; 10. Read buffer. Send address of buffer and return with filled
buffer
; 11. Interrogate console ready (If LSB is 1 then console character is
ready)
; 12. Lift disk head and return version number of CP/M
; 13. Reset disk system.
; 14. Select disk. 1=A, 2=B etc
; 15. Open file.
; 16. Close file.
; 17. Search for a file.
; 18. Search for next occurrence.
; 19. Delete file
; 20. Read sequentially the next 128 bytes.
; 21. Write sequentially the next 128 bytes.
; 22. Make new file and open it.
; 23. Rename file.
; 24. Return login vector (which disks are online).
; 25. Return current disk.
; 26. Set DMA address (to find data records in other parts of memory.
Usually boot+80H)
; 27. Get allocation vector (for STAT to calculate remaining space)
; 28. Write protect disk.
; 29. Get read/write status of disk.
; 30. Set file attributes (read only etc)
; 31. Get disk parameter block address.
; 32. Get or set user code.
; 33. Read randomly.
; 34. Write randomly.
; 35. Compute file size for random files.
; 36. Set random record position.
; From CP/M source code, these are the names of these functions in the
bdos section
;FUNCTNS:.DW WBOOT,GETCON,OUTCON,GETRDR,PUNCH,LIST,DIRCIO,GETIOB
; .DW SETIOB,PRTSTR,RDBUFF,GETCSTS,GETVER,RSTDSK,SETDSK,OPENFIL
; .DW CLOSEFIL,GETFST,GETNXT,DELFILE,READSEQ,WRTSEQ,FCREATE
; .DW RENFILE,GETLOG,GETCRNT,PUTDMA,GETALOC,WRTPRTD,GETROV,SETATTR
; .DW GETPARM,GETUSER,RDRANDOM,WTRANDOM,FILESIZE,SETRAN,LOGOFF,RTN
; .DW RTN,WTSPECL
fdos equ 0005H ; common entry point for bios and bdos
; ********************* Main ***************
; org 100h is not needed for .mac files
; test the routines here
ld de,test_string
call write_string
ld de,crlf
call write_string
; call read_buffer ; returns de ready for printout
; call write_string ; print it back out
call set_dma ; place for 128 bytes of data
call open_file
call read_seq
call close_file
; call delete_file
ret ; back to cp/m
;******************************************
; warm boot - function 0 of bios
warm_boot:
ld c,0
call fdos
ret
;******************************************
; readconsole - function 1 of bios. Character in A
read_console:
ld c,1
call fdos
ret
;******************************************
; write console - function 2 of bios. Character in E
write_console:
ld c,2 ; function number
call fdos
ret
;******************************************
; write string - function 9 of bios. Pass location of string in DE
; string ends in $
write_string:
ld c,9
call fdos
ret
;******************************************
; read buffer - reads in a line until CR - handles backspace/
corrections
; function 10 of bios
; uses readbuff as the location so need a db for this at the end of
the code
; first character in buffer = ignore
; second = number of characters
; third onwards = the characters
read_buffer:
ld c,10
ld de,readbuff
call fdos
ret
;******************************************
; open file. Function 15 of bios. Uses FCB for name
open_file:
ld c,15
ld de,fcb
call fdos
ret
;******************************************
; close file. Function 16 of bios
close_file:
ld c,16
ld de,fcb
call fdos
ret
;******************************************
; delete file. Function 19 of bios
delete_file:
ld c,19
ld de,fcb
call fdos
ret
;******************************************
; get record. Function 20 of bios. Stores 128 bytes in DMA
read_seq:
ld c,20
ld de,fcb
call fdos
ret
;******************************************
; write record. Function 21 of bios. Store 128 bytes from DMA
write_seq:
ld c,21
ld de,fcb
call fdos
ret
;******************************************
; create and open file. Function 22 of bios. Uses FCB for name
create_file:
ld c,22
ld de,fcb
call fdos
ret
;******************************************
; get drive - function 25 of bios, returns drive in A
; 0=drive A, 1=drive B. use add a,65 to change to a letter
get_drive:
ld c,25
call fdos
ret
;******************************************
; set DMA address to de. Function 26 of bios. So can read in data to
known location
set_dma:
ld c,26
ld de,0080H ; standard location for the DMA
call fdos
ret
;******************************************
;*** data ***
test_text: db "Hello world",0FFH
test_string: db "Hello World$"
prompt_string: db "Enter a character$"
crlf: db 13,10,"$"
readbuff: db "abcdefghijklmnopqrstuvwxyz$"
FCB: db 0,"TEST TXT",0,0,0,0,0
db " ",0,0,0,0,0
; ***********
end
; end of program