home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / basic / interpre / movbasic / basica.asm < prev    next >
Assembly Source File  |  1986-11-23  |  6KB  |  179 lines

  1. ;BASICA.COM EXEC routine
  2. ;  You must have the file SBASICA.COM on your disk for this to run.
  3. ;  
  4. ;This gets the BASICA interrupt vector, saves it,
  5. ;  runs SBASICA.COM  and then restore the BASICA interrupt 
  6. ;  when returning
  7. ;This even passes along any arguments passed to BASICA
  8. ;it sets error level -- 1 if load failed
  9. ;                       2 if not enough memory
  10. ;
  11. CODE    SEGMENT PARA  PUBLIC 'CODE'
  12.         ASSUME  CS:CODE
  13.         ASSUME  DS:CODE, ES:CODE
  14. MAIN    proc    far             ;start procedure
  15. START:  jmp     GO
  16. ;
  17. ;exec parameter strings
  18. ;
  19. PARAM   DW      (?)             ;segment address of environment
  20.         dw      offset COMMAND  ;command line
  21.         dw      CODE
  22.         dw      offset FCB1      ;FCB number 1
  23.         dw      CODE
  24.         dw      offset FCB2     ;FCB number 2
  25.         dw      CODE
  26. COMMAND db      25,'/C C:\GAMES\SBASICA.com '
  27. ;
  28. ;  To change the file to run modify the above line with the new path and
  29. ;  filename.  Be sure to change the value (currently 25) to the length of
  30. ;  the string plus 1.
  31. ;
  32. ComTail db      256 dup (0)     ;Place for the command tail
  33.         db      13,0      ;syntax
  34. PROGRAM db      'C:\COMMAND.COM',0               ;file to call
  35. FCB1    db      16 dup (0)
  36. FCB2    db      16 dup (0)
  37. OldBSeg label word
  38.         dw      0
  39. OldBOFs label word
  40.         dw      0
  41. ;
  42. ;note that for the 4A (Setblock) call you must
  43. ;leave ES alone (at PSP address)
  44. ;allocate 64K for the test program if possible
  45. ;
  46. GO:     PUSH    ES
  47.         PUSH    DS                      ;SAVE ES and ds
  48.         xor     ax,ax
  49.         mov     es,ax                   ;set es to base page
  50.         mov     ax,cs                   ;don't assume ds = cs!!
  51.         mov     ds,ax
  52.         mov     bx,0060h
  53.         mov     ax,es:[bx]              ;get Offset value of
  54.         mov     [OldBOfs],ax            ;  Basic vector
  55.         mov     bx,0062h
  56.         mov     ax,es:[bx]              ;and Segment
  57.         mov     [OldBSeg],ax            ; Store them both
  58.         POP     DS                      ; RESTORE DS
  59.         POP     ES                      ; RESTORE ES
  60.  
  61.         mov     si,0080h                ;location of command tail
  62.         lodsb                           ; get length of tail
  63.         or      al,al                   ;if zero then just skip it all
  64.         jz      SetBlock
  65.         push    es                      ;save es, need to set it to cs
  66.         mov     ax,cs
  67.         mov     es,ax
  68.         add     byte ptr CS:[Command],al   ;else add it to length already there
  69.         cbw                             ;make byte in al into word in ax
  70.         mov     cx,ax                   ;now cx has counter for loop
  71.                                         ;si already incremented to start of tail
  72.         add     cx,2                    ;will also get the cr and 0 at end of tail
  73.         mov     di,offset ComTail       ;di=destination for move
  74.         rep     movsb
  75.         pop     es                      ;get es back finally
  76.  
  77. SetBlock:
  78.         mov     AH,4Ah          ;setblock call
  79.         mov     BX,100h         ;reserve 64kb for test program
  80.         int     21h             ;call dos
  81.         jc      NOTENUF         ;not enough storage
  82. ;read address (2C) of PSP to
  83. ;read/write the environment settings
  84.         mov     SI,2Ch          ;address of env segment
  85.         mov     AX,[SI]         ;in PSP
  86.         mov     SI,offset PARAM ;save it into parameter block
  87.         mov     CS:[SI],AX
  88. ;now prepare for the EXECute subprogram call (4B)
  89. ;for this call you need DS,ES:CODE as above, so
  90.         mov     AX,CS 
  91.         mov     DS,AX
  92.         mov     ES,AX
  93. ;now set up the register to point to the program name
  94. ;and parameter block
  95. ;then EXECute
  96.         mov     DX,offset PROGRAM
  97.         mov     BX,offset PARAM
  98.         mov     AL,0            ;EXEC subtype
  99.         mov     AH,4Bh          ;EXEC
  100.         int     21h             ;call DOS
  101.         JC      LDERR           ;carry = load/exec error
  102. ;       if we got here, there was no error
  103. ;       CALL    STR$PRN
  104. ;       DB      'No error . . .',13,10,0
  105.  
  106.         mov     AL,0
  107.         jmp     alldone
  108. ;
  109. ; load error
  110. ;
  111. LDERR:  mov     AL,1            ;errorlevel 1
  112.         CALL    STR$PRN
  113.         DB      13,10,'ErrorLevel 1:  File Load error . . .',13,10,0
  114.         jmp     alldone
  115. ;not enough memory available
  116. NOTENUF:
  117.         CALL    STR$PRN
  118.         DB      13,10,'ErrorLevel 2:  Not enough memory . . .',13,10,0
  119.         MOV     AL,2            ;errorlevel 2
  120. ;exit
  121. alldone:        
  122.         XOR     AX,AX            ;Restores the Basic interrupt vector
  123.         MOV     ES,AX            
  124.         mov     ax,cs           ;again restore ds!
  125.         mov     ds,ax
  126.  
  127.         MOV     AX,[OldBOfs]    ;Restore the original BASIC values
  128.         mov     bx,0060h
  129.         MOV     ES:[bx],ax
  130.         MOV     AX,[OldBSeg]
  131.         mov     bx,0062h
  132.         MOV     ES:[bx],AX
  133.  
  134.         mov     AH,4Ch          ;EXIT
  135.         int     21h             ;end of program
  136. MAIN    endp
  137. ;
  138. ;
  139. STR$PRN PROC    NEAR                    ;IN LINE PRINT, NULL TERMINATE 
  140.         POP     AX                      ;GET RET ADDR 
  141.         PUSH    BX                      ;SAVE BX 
  142.         MOV     BX,AX                   ;PUT AX INTO BX STRLP:   
  143.         MOV     AL,[BX]                 ;GET CHAR 
  144.         INC     BX                      ;BUMP POINTER 
  145.         OR      AL,AL                   ;IS IT ZERO? 
  146.         JZ      STR$END 
  147.         CALL    PCHAR 
  148.         JMP     SHORT STRLP        
  149. STR$END:                                ;RETURN TO NEXT ADDRESS 
  150.         MOV     AX,BX                   ;PUT BX INTO AX TEMP 
  151.         POP     BX                      ;GET ORIG BX BACK 
  152.         PUSH    AX                      ;RET ADDR BACK ON STACK 
  153.         RET 
  154. STR$PRN ENDP 
  155. ;        
  156. STR$OUT  PROC  NEAR 
  157.         ;MESSAGE PRINTING SUBROUTINE 
  158.         ;      DX HAS ADDRESS OF MESSAGE ENDING WITH A '$' 
  159.         MOV        AH,09h 
  160.         INT        21H 
  161.         RET 
  162. STR$OUT ENDP 
  163.         ; 
  164.         ; 
  165.         ; 
  166. PCHAR   PROC  NEAR                      ;AL HAS CHAR TO PRINT 
  167.         PUSH       DX 
  168.         MOV        DL,AL 
  169.         MOV        AH,02h 
  170.         INT        21H 
  171.         POP        DX 
  172.         RET 
  173. PCHAR        ENDP ; 
  174. ;
  175. CODE    ends 
  176.         end
  177.  
  178.