PDA

View Full Version : Attempt to make fig-FORTH use drive C:



smp
April 3rd, 2015, 02:49 PM
Hello again, all,

In another thread, I was successful in getting an old version of fig-FORTH to assemble and run on my HP-110+ with one external 3.5 inch floppy disk drive.

Here is a brief description of this system:

MS-DOS 2.11 in ROM
500K system RAM
Drive A: is 384K RAM as a RAM-drive
Drive B: is a set of ROMs holding MS-BASIC, Lotus 1-2-3, and a terminal program
Drive C: is an external 3.5 inch 720K floppy disk

fig-FORTH was originally implemented to save and load your personally generated code directly to the floppy disk as 1K blocks of memory. That is, a FORTH screen of code was exactly 16 lines of 64 characters for exactly 1K. Screens are numbered and saved to floppy disk directly as 1K blocks of memory. The user types code into a screen numbered from 0 to n, and based on the screen number, that is which 1K block of memory is being operated on. When the user saves the screen to the floppy disk, again the screen number determines which 1K block gets written to the disk. fig-FORTH does not use the file system. It assumes that it has complete control of the floppy disk and uses MS-DOS service interrupts to write (or read) blocks (FORTH screens) directly to the floppy.

I run the fig-FORTH from my Drive C:. When I attempt to save my own FORTH code screens they get saved to my Drive A:. This, of course, fouls up whatever I already have stored in my RAM-drive.

So, I took a look at the code and I found where the drive and sector get figured out:



SEC_DSK EQU 360

;
SSEC PROC NEAR
; ( ADDR SEC# -- )
; THIS ROUTINE WILL SELECT THE HEAD & DRIVE
POP DI ;GET RETURN ADDR OFF STACK
POP AX ;GET SECTOR #
CMP AX,SEC_DSK ;IF SECTOR # > SEC_DSK THEN DR B
JB DR0
SUB AX,SEC_DSK
MOV DX,AX ;LOAD LOGICAL SECTOR #
MOV AL,1 ;SELECT DR B
JMP GSEC1
DR0: MOV DX,AX ;LOAD LOGICAL SECTOR #
MOV AL,0 ;SELECT DR A
GSEC1: POP BX ;TRANSFER ADDR
MOV CX,1 ;READ 1 SECTOR
PUSH DI ;PUT RETURN ADDR BACK
RET
SSEC ENDP


As you can see, the code assumes 360 1K sectors per disk, and discriminates between Drive A: and Drive B: by the sector number. If the sector number is 0-359 it must be Drive A: and if the sector number is 360 and above it must be Drive B:. This routine is called from both the write-sector and read-sector routines. Essentially the fig-FORTH code points to the drive and sector first, then performs the write or read action. Here, the 1K sectors are the 1K blocks or screens that I was describing above. It probably worked just great with the original one or two floppy disk drive PCs. You stuck your fig-FORTH floppy disk into Drive A: and booted fig-FORTH. Then you placed your fig-FORTH data disk into Drive A: and saved or loaded your own personal code from there. You even had the ability to have two floppy disks worth of code storage available in Drive A: and Drive B:.

What I would like to do is change the code to work with my Drive C:.

If anyone actually understands what in the world I am talking about here, I would appreciate any hints you may have on how I could alter this code to point to my Drive C: instead of being locked into using only Drive A:.

Thank you very much, in advance, for any thoughts or questions you may have.

smp

gslick
April 3rd, 2015, 04:05 PM
If you always want to read and write from drive C and only drive C you could try doing a simple modification to the SSEC routine to skip the sector number check and hard code loading AL with the value 2 to select drive C.

Original code:


WERR DB 'DISK WRITE ERROR $'
RERR DB 'DISK READ ERROR $'
;
SSEC PROC NEAR
; ( ADDR SEC# -- )
; THIS ROUTINE WILL SELECT THE HEAD & DRIVE
POP DI ;SAVE RETURN
POP AX ;SECTOR #
CMP AX,SEC_DSK ;B DRIVE?
JB DR0
SUB AX,SEC_DSK
MOV DX,AX ;LOAD LOGICAL SECTOR #
MOV AL,1 ;SELECT DR B
JMP GSEC1
DR0: MOV DX,AX ;DR A
MOV AL,0 ;SELECT DR A
GSEC1: POP BX ;TRANSFER ADDR
MOV CX,1 ;READ 1 SECTOR
PUSH DI ;GET THAT RETURN BACK
RET
SSEC ENDP
;
; RSEC
;
DB 84H
DB 'RSE'
DB 'C'+80H
DW BLOCK-8
RSEC DW $+2
CALL SSEC
PUSH SI ;PRESERVE INTERPRETER POINTER
PUSH BP ;RETURN POINTER
INT 25H
JNC DOK ;NO ERRORS
LEA DX,RERR
JMP DERR
;
; WSEC
;
DB 84H
DB 'WSE'
DB 'C'+80H
DW RSEC-7
WSEC DW $+2
CALL SSEC
PUSH SI
PUSH BP
INT 26H
JNC DOK
LEA DX,WERR
DERR: PUSH AX
MOV AH,9 ;STRING WRITE FNCN
INT 21H
POP AX ;ERROR CODE IN AX
; WRITE ERROR MESSAGE HERE
;
DOK: POPF ;POP FLAGS
POP BP ;RETURN STACK
POP SI ;INTERPRETER PNTR
JMP NEXT
;
; R/W
;
; ( ADDR SECTOR# FLAG (0=W, 1=R) --- )
DB 83H
DB 'R/'
DB 'W'+80H
DW WSEC-7
RSLW DW DOCOL
DW ZBRAN,OFFSET RSLW1-$
DW RSEC
DW BRAN,OFFSET RSLW2-$
RSLW1 DW WSEC
RSLW2 DW SEMIS


Modified code:


;
SSEC PROC NEAR
; ( ADDR SEC# -- )
; THIS ROUTINE WILL SELECT THE HEAD & DRIVE
POP DI ;SAVE RETURN
POP DX ;SECTOR #
MOV AL,2 ;SELECT DR C
GSEC1: POP BX ;TRANSFER ADDR
MOV CX,1 ;READ 1 SECTOR
PUSH DI ;GET THAT RETURN BACK
RET
SSEC ENDP

smp
April 3rd, 2015, 04:46 PM
If you always want to read and write from drive C and only drive C you could try doing a simple modification to the SSEC routine to skip the sector number check and hard code loading AL with the value 2 to select drive C.


Hi Glenn,

Thanks a million!

I was hoping that Drive C: might be AL=2, but I have not done a lot of direct interfacing into MS-DOS before.

I'll give this a try and post back with my results.

Thanks again!

smp

smp
April 4th, 2015, 03:19 PM
OK! Thanks very much to Glenn!

The suggested code patch worked like a dream. Now I have fig-FORTH fully implemented on my HP-110+ with an external floppy disk drive as Drive C:. I can start up fig-FORTH from my Drive A: (the RAM drive) and when I go to save or load FORTH code screens, the system always accesses the external floppy disk, Drive C:. With a 720K floppy disk, that will give me loads of storage to work with.

I have already typed in the simple line editor screens and saved them off to disk. It sure is weird to issue a DIR command from MS-DOS and get back the empty disk response, even though I already have a dozen screens saved there. But, that's the way fig-FORTH works. I will have to develop a sector-by-sector disk copy utility so I can make backup copies.

Thanks again.

smp