Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
MBASIC
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
{{Short description|Dialect of the BASIC programming language}} {{Infobox programming language | name = MBASIC | year = | designer = [[Microsoft]] | developer = [[Microsoft]] | latest release version = | latest release date = | implementations = | influenced_by = [[BASIC]] | influenced = | typing = | dialects = | paradigm = [[imperative programming|imperative]] | logo = | operating_system = [[CP/M]] | license = | website = {{url|www.microsoft.com}} | file_ext = }} '''MBASIC''' is the [[Microsoft BASIC|'''M'''icrosoft '''BASIC''']] implementation of [[BASIC]] for the [[CP/M]] operating system. MBASIC is a descendant of the original [[Altair BASIC]] interpreters that were among Microsoft's first products. MBASIC was one of the two versions of BASIC bundled with the [[Osborne 1]] computer. The name "MBASIC" is derived from the disk file name MBASIC.COM of the BASIC interpreter. MBASIC, like its predecessor family of 8-bit interpreters [[Microsoft BASIC]], were heavily inspired by [[Digital Equipment Corporation]] [[PDP-10]]'s [[BASIC-PLUS]]. == Environment == [[File:MBasic 5.21.jpg|thumb|MBasic 5.21 running on a Z80 CP/M system displayed on a monochrome monitor typical for that time]] MBASIC version 5 required a CP/M system with at least 28 KB of [[random-access memory]] (RAM) and at least one diskette drive. Unlike versions of [[Microsoft BASIC-80]] that were customized by [[home computer]] manufacturers to use the particular hardware features of the computer, MBASIC relied only on the CP/M operating system calls for all input and output. Only the CP/M console (screen and keyboard), [[line printer]], and disk devices were available. MBASIC in the uncustomized form had no functions for [[Computer graphics|graphics]], color, joysticks, mice, [[serial port|serial communications]], [[Ethernet|networking]], sound, or even a [[real-time clock]] function. MBASIC did not fully support the features of the host CP/M operating system, for example, it did not support CP/M's user areas for organizing files on a diskette. Since CP/M systems were typically single-user and stand alone, there was no provision for file or record locking, or any form of [[computer multitasking|multitasking]]. Apart from these limitations, MBASIC was considered at the time to be a powerful and useful implementation of BASIC. == Features == === Language system === MBASIC is an [[BASIC interpreter|interpreter]]. Program source text was stored in memory in tokenized form, with BASIC keywords replaced by one-byte tokens which saved memory space and speeded execution. Any line prefixed with a line number was stored as program text; BASIC statements not prefixed with a line number were executed immediately as commands. Programs could be listed on the screen for editing, or saved to disk in either a [[data compression|compressed]] binary format or as plain [[ASCII]] text. Every source line was identified with a number, which could be used as the target of a [[GOTO]] or [[GOSUB]] transfer. Only line editing commands were provided.<ref>CP/M products providing full-screen editing support required their own installation routines to customize the software for the specific [[computer terminal]] used as the system console. No support was provided within CP/M to standardize terminal capabilities.</ref> It was often beneficial to save a program as plain text and edit it with a full featured editor. Program text, [[Variable (computer science)|variables]], [[disk buffer]]s and the CP/M operating system itself all had to share the 64 kilobyte address space of the [[Intel 8080|8080]] processor. Typically when first starting MBASIC there would be less than 32 kB memory available for programs and data, even on a machine equipped with a full 64 kilobytes of RAM. Comment lines, prefixed with the <code> REM </code> keyword or an apostrophe, could be placed in the program text but took up valuable memory space, which discouraged BASIC users from fully documenting their code. To allow larger and more complex programs to be run, later versions of MBASIC supported functions that allowed portions of program text to be read in and executed under program control (the "[[chain loading|<code> CHAIN </code>]]" and <code> MERGE </code> statements). No support for "shell" command execution was provided, though this functionality could be duplicated by a determined programmer. A particular advantage of MBASIC was the full-text error messages provided for syntax and run-time errors. MBASIC also had a "trace" function that displayed line numbers as they were executed. While this occupied the same screen space as normal program output, it was useful for detecting conditions such as [[endless loop]]s. === Files and input/output === Data could be read and stored to disk as either sequential files (delimited by the CP/M convention of [[carriage return|CR]]/[[line feed|LF]] at the end of each line) or else as fixed-record-length random access files, which, given a sufficiently determined programmer, could be used to perform database-type record manipulation. The [[Microsoft Binary Format]] for [[floating point]] numbers was proprietary to the implementation, which meant that data could only be interchanged with other programs using ASCII text representation or else with extensive programming to convert the binary format. === Variables and data types === MBASIC supported the following data types: * 8-bit character data, in strings of length 0 to 255 characters; * 16-bit [[integer]]s; * 32-bit [[floating point]] (single precision), equivalent to six decimal digits, with a two-digit exponent; * 64-bit floating point (double precision), equivalent to sixteen decimal digits, with a two-digit exponent. String operators included substring selection, concatenation, assignment, and testing for equality. Arrays of the above types were allowed with up to 7 dimensions, but no functions or operators worked on arrays; for example, there was no assignment of arrays. Unlike some other BASIC implementations of the time, MBASIC did not provide support for [[matrix (mathematics)|matrix]] operations, [[complex number]]s, or a [[binary-coded decimal|decimal (BCD)]] data type for financial calculations. All floating point operations were carried out in software since typical CP/M systems did not have [[floating-point unit|floating point hardware]]. The built-in mathematics functions ([[sine and cosine|sine, cosine]], [[tangent]], [[natural logarithm|natural log]], [[exponential function|exponential]], [[square root]]) only gave single precision results. A software [[pseudorandom number generator]] was provided; this relied on the user to key in a seed number to obtain a sequence of numbers useful for games and some simulations. MBASIC permitted but did not require the <code> LET </code> keyword for assignment statements. Early versions of BASIC on [[microcomputer]]s were infamous for one- or two-character variable names, which made the meanings of variables difficult to recall in complex programs. MBASIC version 5 allowed identifiers up to 40 characters long, which permitted programmers to give variables readable names. === Program flow control === Program flow control in MBASIC was controlled by <code> IF...THEN...ELSE... </code> conditional tests, <code> WHILE...WEND </code> loops, and <code> GOTO </code> and <code> GOSUB </code> instructions. No <code> CASE </code> statement was available, although an <code> ON...GOTO... </code>(computed GOTO) provided multi-way branches. Subroutines had no parameters and all variables were global. MBASIC did not make [[structured programming]] mandatory for programmers and it was easy to write [[spaghetti code]]. == PEEKs, POKEs, and user functions == No discussion of BASICs on the [[8-bit computing|8-bit]] computers of the late '70s and early '80s would be complete without mentioning the importance of the [[PEEK and POKE]] functions for directly reading and writing to memory. Since these systems typically had no [[memory protection]], this allowed a programmer to access portions of the operating system, or functions that would not otherwise be available. This also provided opportunities for user programs to hang the system (by accident, usually). For example, a CP/M programmer might use a <code> POKE </code> function to allow BASIC to switch the console device to the serial port, if the system [[BIOS]] supported this. For machines with real-time clocks, a set of <code>PEEK</code> instructions might have been used to access the time. For more complex operations, MBASIC allowed user-defined functions that could be called from a BASIC program. These were typically placed in a reserved area of memory, or POKEd into string constants, as a series of [[Machine language|machine codes]] ([[opcodes]]). MBASIC also provided hardware <code>INP</code> and <code>OUT</code> instructions that read and wrote directly to the 8080 hardware input/output ports. This could be used to control peripheral devices from a BASIC program if the system hardware permitted. Any MBASIC programs that made use of <code>PEEK</code> and <code>POKE</code>, and of machine code user functions, were not portable between machines without modifications. == Successors to MBASIC == Besides Microsoft's BASIC-80 for CP/M, a variant of MBASIC was also available as for the [[Intel ISIS-II|ISIS-II]] operating system. [[MSX BASIC|MSX-BASIC]] is also a well known successor of MBASIC, featuring several extensions specific to the [[MSX]] machines. All the functions of CP/M MBASIC were available in the IBM PC disk-based [[BASICA]] or [[GWBASIC]] which made migration of programs from CP/M systems to PC-compatibles possible. The tokens used to represent keywords were different, so CP/M programs had to be saved in ASCII source form. Typically screen formatting escape sequences put into the CP/M version would be replaced with the cursor positioning commands found in the PC versions of BASIC, otherwise little rewriting would be needed. == BASCOM == Microsoft sold a CP/M BASIC [[compiler]] (known as '''BASCOM''') which used a similar source language to MBASIC. A program debugged under MBASIC could be compiled with BASCOM. Since program text was no longer in memory and the run-time elements of the compiler were smaller than the interpreter, more memory was available for user data. Speed of real program execution increased about 3 fold. Developers welcomed BASCOM as an alternative to the popular but slow and clumsy [[CBASIC]]. Unlike CBASIC, BASCOM did not need a [[preprocessor]] for MBASIC source code so could be debugged interactively.<ref name="iw19800818">{{Cite magazine |date=1980-08-18 |title=Editorial |url=https://books.google.com/books?id=az4EAAAAMBAJ&pg=PT47 |magazine=InfoWorld |page=8}}</ref> While approving of its superior edit-compile-run-debug loop compared to CBASIC, and stating that binaries ran far faster, [[Jerry Pournelle]] in December 1980 denounced Microsoft's requirement of a 9% royalty for each binary copy<ref name="pournelle198012">{{cite news | url=https://archive.org/stream/byte-magazine-1980-12/1980_12_BYTE_05-12_Adventure#page/n223/mode/2up | title=BASIC, Computer Languages, and Computer Adventures | work=BYTE | date=December 1980 | access-date=18 October 2013 | author=Pournelle, Jerry | pages=222}}</ref> and $40 for hardware-software combinations. The company also reserved the right to audit developers' financial records. Because authors' typical royalty rates for software was 10-25%, ''[[InfoWorld]]'' in 1980 stated that BASCOM's additional 9% royalty rate "could make software development downright unprofitable", concluding that "Microsoft has the technical solution [to CBASIC's flaws], but not the economic one".<ref name="iw19800818"/> == Importance of MBASIC == MBASIC was an important tool during the era of 8-bit CP/M computers. Skilled users could write routines in MBASIC to automate tasks that in modern-day systems would be performed by powerful application program commands or scripting languages. Exchange of useful MBASIC programs was a common function of computer [[users' group]]s. [[Type-in program|Keying in long BASIC listings]] from a magazine article was one way of "bootstrapping" software into a new CP/M system. At least one compiler for a high-level language was written in MBASIC, and many small games and utility programs ranging from a few lines to a few thousand lines of code were written. == Other uses == MBASIC is also the name of a commercial [[BASIC]] compiler for the [[Microchip Technology]] [[PIC microcontroller]] family developed by Basic Micro, Inc., unrelated to the CP/M interpreter. == References == {{Reflist}} {{Refbegin}} * Thom Hogan and Mike Iannamico, ''Osborne 1 User's Reference Guide'',(1982) Osborne Computer Corporation * David A. Lien, ''The BASIC Handbook'', 2nd Edition Encyclopedia of the BASIC Computer Language",(1981), Compusoft Publishing * ''BASIC 80 Reference Manual'', Microsoft Corporation, no date {{Refend}} {{BASIC}} [[Category:CP/M software]] [[Category:Discontinued Microsoft BASICs]] [[Category:BASIC programming language family]] [[Category:Microsoft programming languages]]
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)
Pages transcluded onto the current version of this page
(
help
)
:
Template:BASIC
(
edit
)
Template:Cite magazine
(
edit
)
Template:Cite news
(
edit
)
Template:Infobox programming language
(
edit
)
Template:Refbegin
(
edit
)
Template:Refend
(
edit
)
Template:Reflist
(
edit
)
Template:Short description
(
edit
)