home *** CD-ROM | disk | FTP | other *** search
- ;BASICA.COM EXEC routine
- ; You must have the file SBASICA.COM on your disk for this to run.
- ;
- ;This gets the BASICA interrupt vector, saves it,
- ; runs SBASICA.COM and then restore the BASICA interrupt
- ; when returning
- ;This even passes along any arguments passed to BASICA
- ;it sets error level -- 1 if load failed
- ; 2 if not enough memory
- ;
- CODE SEGMENT PARA PUBLIC 'CODE'
- ASSUME CS:CODE
- ASSUME DS:CODE, ES:CODE
- MAIN proc far ;start procedure
- START: jmp GO
- ;
- ;exec parameter strings
- ;
- PARAM DW (?) ;segment address of environment
- dw offset COMMAND ;command line
- dw CODE
- dw offset FCB1 ;FCB number 1
- dw CODE
- dw offset FCB2 ;FCB number 2
- dw CODE
- COMMAND db 25,'/C C:\GAMES\SBASICA.com '
- ;
- ; To change the file to run modify the above line with the new path and
- ; filename. Be sure to change the value (currently 25) to the length of
- ; the string plus 1.
- ;
- ComTail db 256 dup (0) ;Place for the command tail
- db 13,0 ;syntax
- PROGRAM db 'C:\COMMAND.COM',0 ;file to call
- FCB1 db 16 dup (0)
- FCB2 db 16 dup (0)
- OldBSeg label word
- dw 0
- OldBOFs label word
- dw 0
- ;
- ;note that for the 4A (Setblock) call you must
- ;leave ES alone (at PSP address)
- ;allocate 64K for the test program if possible
- ;
- GO: PUSH ES
- PUSH DS ;SAVE ES and ds
- xor ax,ax
- mov es,ax ;set es to base page
- mov ax,cs ;don't assume ds = cs!!
- mov ds,ax
- mov bx,0060h
- mov ax,es:[bx] ;get Offset value of
- mov [OldBOfs],ax ; Basic vector
- mov bx,0062h
- mov ax,es:[bx] ;and Segment
- mov [OldBSeg],ax ; Store them both
- POP DS ; RESTORE DS
- POP ES ; RESTORE ES
-
- mov si,0080h ;location of command tail
- lodsb ; get length of tail
- or al,al ;if zero then just skip it all
- jz SetBlock
- push es ;save es, need to set it to cs
- mov ax,cs
- mov es,ax
- add byte ptr CS:[Command],al ;else add it to length already there
- cbw ;make byte in al into word in ax
- mov cx,ax ;now cx has counter for loop
- ;si already incremented to start of tail
- add cx,2 ;will also get the cr and 0 at end of tail
- mov di,offset ComTail ;di=destination for move
- rep movsb
- pop es ;get es back finally
-
- SetBlock:
- mov AH,4Ah ;setblock call
- mov BX,100h ;reserve 64kb for test program
- int 21h ;call dos
- jc NOTENUF ;not enough storage
- ;read address (2C) of PSP to
- ;read/write the environment settings
- mov SI,2Ch ;address of env segment
- mov AX,[SI] ;in PSP
- mov SI,offset PARAM ;save it into parameter block
- mov CS:[SI],AX
- ;now prepare for the EXECute subprogram call (4B)
- ;for this call you need DS,ES:CODE as above, so
- mov AX,CS
- mov DS,AX
- mov ES,AX
- ;now set up the register to point to the program name
- ;and parameter block
- ;then EXECute
- mov DX,offset PROGRAM
- mov BX,offset PARAM
- mov AL,0 ;EXEC subtype
- mov AH,4Bh ;EXEC
- int 21h ;call DOS
- JC LDERR ;carry = load/exec error
- ; if we got here, there was no error
- ; CALL STR$PRN
- ; DB 'No error . . .',13,10,0
-
- mov AL,0
- jmp alldone
- ;
- ; load error
- ;
- LDERR: mov AL,1 ;errorlevel 1
- CALL STR$PRN
- DB 13,10,'ErrorLevel 1: File Load error . . .',13,10,0
- jmp alldone
- ;not enough memory available
- NOTENUF:
- CALL STR$PRN
- DB 13,10,'ErrorLevel 2: Not enough memory . . .',13,10,0
- MOV AL,2 ;errorlevel 2
- ;exit
- alldone:
- XOR AX,AX ;Restores the Basic interrupt vector
- MOV ES,AX
- mov ax,cs ;again restore ds!
- mov ds,ax
-
- MOV AX,[OldBOfs] ;Restore the original BASIC values
- mov bx,0060h
- MOV ES:[bx],ax
- MOV AX,[OldBSeg]
- mov bx,0062h
- MOV ES:[bx],AX
-
- mov AH,4Ch ;EXIT
- int 21h ;end of program
- MAIN endp
- ;
- ;
- STR$PRN PROC NEAR ;IN LINE PRINT, NULL TERMINATE
- POP AX ;GET RET ADDR
- PUSH BX ;SAVE BX
- MOV BX,AX ;PUT AX INTO BX STRLP:
- MOV AL,[BX] ;GET CHAR
- INC BX ;BUMP POINTER
- OR AL,AL ;IS IT ZERO?
- JZ STR$END
- CALL PCHAR
- JMP SHORT STRLP
- STR$END: ;RETURN TO NEXT ADDRESS
- MOV AX,BX ;PUT BX INTO AX TEMP
- POP BX ;GET ORIG BX BACK
- PUSH AX ;RET ADDR BACK ON STACK
- RET
- STR$PRN ENDP
- ;
- ;
- STR$OUT PROC NEAR
- ;MESSAGE PRINTING SUBROUTINE
- ; DX HAS ADDRESS OF MESSAGE ENDING WITH A '$'
- MOV AH,09h
- INT 21H
- RET
- STR$OUT ENDP
- ;
- ;
- ;
- PCHAR PROC NEAR ;AL HAS CHAR TO PRINT
- PUSH DX
- MOV DL,AL
- MOV AH,02h
- INT 21H
- POP DX
- RET
- PCHAR ENDP ;
- ;
- CODE ends
- end
-
-