Mixing QuickBASIC with As

 BBS: The MOONFLOWER
Date:   -  -   (15:32)             Number: 106
From: CONIC ELLIPSE #38 @6210      Refer#: NONE
  To:                               Recvd: YES 
Subj: Mixing QuickBASIC with As      Conf: (79) The Progra

I went off-line to respond to this message. When I came back, I couldn't find the question. But this is for the person who was having the problem. Linking Compiled BASIC with Assembly Language subroutines is easy. Here is a sample: This is a sample assembly program: ;**************************************************************************** ; Author: Allen L. Wyatt ; Date: 7/28/87 ; File: ULCASE.ASM ; Descrpt: Subroutine designed to convert a string to upper or lower case. ; Designed to be called from Compiled BASIC ; ; Format: CALL ULCASE(S$,X%) ; S$: Ponter to string to be converted ; X%: Controls conversion ; 0 = Convert to uppercase ; ? = Any other signifies convert to lower case ;**************************************************************************** PUBLIC ULCASE NAME ULCASE CODE SEGMENT BYTE PUBLIC 'CODE' ASSUME CS:CODE PARMB EQU 8 PARMA EQU 6 ;
- ULCASE PROC FAR PUSH BP MOV BP,SP MOV BX,[BP]+PARMB ;String descriptor address MOV CX,[BX] ;Get the string length JCXZ EXIT ;Passed nul string, so exit MOV DI,[BX+2] ;Start of string to convert MOV BX,[BP]+PARMA ;Address of action variable MOV AX,[BX] ;Get the actual number CMP AX,0 ;Converting to uppercase? JZ UPPER ;Yes, so go handle LOWER: CMP BYTE PTR [DI],'A' ;Is it < A ? JB L1 ;Yes, so skip character CMP BYTE PTR [DI],'Z' ;Is it > Z ? JA L1 ;Yes, so skip character OR BYTE PTR [DI],20h ;make lowercase (00100000b) L1: INC DI ;Next character LOOP LOWER ;Do it for all characters JMP EXIT ;All done - exit UPPER: CMP BYTE PTR [DI],'a' ;Is it < a ? JB U1 ;Yes, so skip character CMP BYTE PTR [DI],'z' ;Is it > z ? JA U1 ;Yes, so skip character AND BYTE PTR [DI],05Fh ;Make uppercase (01011111b) U1: INC DI ;Next character LOOP UPPER ;Do it for all characters EXIT: POP BP RET 2*2 ULCASE ENDP ;
- CODE ENDS END ULCASE And, here is the controlling Compiled BASIC program (QuickBASIC) (line numbers are not necessary, but he included them so I will too.) 10 ' ****************************************************************** 15 ' Title: ULCALL.BAS 20 ' Sample program to show calling of assembly language 30 ' subroutine from compiled BASIC. 40 ' Assembly Language routine converts string to upper or lowercase. 50 ' Written by Allen L. Wyatt, 7/28/87 60 ' Shortened by Conic Ellipse for NET space saving 70 ' ****************************************************************** 80 ' 100 ZERO%=0:ONE%=1 110 LINE INPUT "String to convert: ";A$ 120 IF A$="" THEN END 130 PRINT:PRINT "UPPERCASE:" 140 CALL ULCASE(A$,ZERO%) 150 PRINT A$ 160 PRINT "lowercase:" 170 CALL ULCASE(A$,ONE%) 180 PRINT A$ 190 GOTO 110 Of course this routine is already built in to BASIC but it is a pretty easy example to follow. The next step is to create an .OBJ file out of both programs. Then link them together as such: LINK ULCALL+ULCASE,,ULCALL or LINK ULCALL ULCASE,,; Both will give you a file called ULCALL.EXE How it works is that you are passing information via the stack. Information here was derived from "USING ASSEMBLY LANGUAGE" by Allen L. Wyatt from QUE Corporation in Carmel Indiana. (pages 63-66 and pages 122-123) I forget who mentioned this book in this sub some time ago, but thanks! I got a copy from the library and it is wonderful. It explains how to mix Assembly routines with BASIC (Interpretive and compiled), PASCAL, and 'C'. It explains DEBUG in compete detail and teaches you how to LINK your files, create and maintain Libraries, and even use the libraries from different languages for whatever you want. It also goes into some detail on Video memory, Accessing Hardware Ports and BIOS services, as well as the instruction sets on all of the chips (individually) 8086, 286, 386 and 8087. ISBN# 0-88022-297-2 $22.95 USA He used MASM 5.0 and QuickBASIC (I don't remember what version) but you should be able to convert it to TurboAssembler fairly easily (I hope :) Good Luck. [601-327-4693] ÚÄÄÄÄ ÄÄÄÄ¿ VNET @6210 ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄ THE NEON GARGOYLE ÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ WWIV @6102 ÀÄÄÄÄ Columbus, MS ÄÄÄÄÙ FIDO 1:361/203
Outer Court
Echo Basic Postings

Books at Amazon:

Back to BASIC: The History, Corruption, and Future of the Language

Hackers: Heroes of the Computer Revolution (including Tiny BASIC)

Go to: The Story of the Math Majors, Bridge Players, Engineers, Chess Wizards, Scientists and Iconoclasts who were the Hero Programmers of the Software Revolution

The Advent of the Algorithm: The Idea that Rules the World

Moths in the Machine: The Power and Perils of Programming

Mastering Visual Basic .NET