Commodore Basic as a Scripting Language

栏目: IT技术 · 发布时间: 4年前

内容简介:"Commodore BASIC" (cbmbasic) is a 100% compatible version of Commodore's version of Microsoft BASIC 6502 as found on the Commodore 64. You can use it in interactive mode or pass a BASIC file as a command line parameter.This source does not emulate 6502 cod

cbmbasic - Commodore BASIC V2 as a scripting language

"Commodore BASIC" (cbmbasic) is a 100% compatible version of Commodore's version of Microsoft BASIC 6502 as found on the Commodore 64. You can use it in interactive mode or pass a BASIC file as a command line parameter.

This source does not emulate 6502 code; all code is completely native. On a 1 GHz CPU you get about 1000x speed compared to a 1 MHz 6502.

Compatibility

It has been tested with

  • Mac OS X 10.4/10.5 i386/x86_64/ppc (GCC 3.3/4.0)
  • Debian Linux Etch (GCC 3.3/4.1)
  • Windows NT (Visual Studio 2005/2008)

Other CPUs, operating systems and compilers should work, too.

Windows users should also install the Microsoft Visual C++ 2005 SP1 Redistributable Package (x86).

Usage

You can use cbmbasic in interactive mode by just running the binary without parameters, or you can specify an ASCII-encoded BASIC program on the command line. You can also use cbmbasic as a UNIX scripting language by adding a hashbang line to your BASIC program and making it executable.

$ ls -l hello.bas 
-rwxr-xr-x  1 mist  staff  40  7 Apr 21:30 hello.bas
$ cat hello.bas 
#!/usr/bin/cbmbasic
PRINT"HELLO WORLD!"
$ ./hello.bas 
HELLO WORLD!

cbmbasic implements a small plugin system that lets developers add additional statements, functions etc. Right now, you can turn this on with "SYS 1" (turn off with "SYS 0"), and use the new statements LOCATE y , x (set cursor position), SYSTEM string (run command line command) and the extended WAIT port , mask , which implements the Bill Gates easter egg .

Internals

The core of the BASIC interpreter is in the file cbmbasic.c , which is platform, endianness and bitness independent. For all I/O, it calls out into runtime.c , so it should be possible to adapt this project for any OS by just changing runtime.c .

All function calls that the core interpreter can't handle end up in kernal_dispatch() in runtime.c , where a switch statement dispatches these to C functions. For Commodore BASIC, runtime.c has to support several Commodore KERNAL library routines. Some of them are very important (CHRIN, CHROUT) and some are only used for certain BASIC statements (LOAD, SAVE, OPEN, SETTIM). runtime.c does not implement all functions yet.

License

Feel free to use this project for any purpose, give credit if you like, and send back improvements to the authors, if you like, so that others can benefit from it. See source for license details.

Contact

Michael Steil , James Abbatiello


以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

怪诞行为学2

怪诞行为学2

[美]丹·艾瑞里 / 赵德亮 / 中信出版社 / 2010-1-9 / 42.00元

《怪诞行为学2:非理性的积极力量》编辑推荐:尝试用“非理性”的决策方式,彻底颠覆工作和生活中的“逻辑”,你将获得意想不到的成就感与幸福感!畅销书《怪诞行为学》作者卷土重来,掀起新一轮“非理性”狂潮。 《写给中国人的经济学》作者王福重、著名行为经济学家董志勇倾情作序。 诺贝尔经济学奖得主阿克尔洛夫、《免费》作者安德森高度评价。 《纽约时报》《哈佛商业评论》《波士顿环球报》等全球顶级......一起来看看 《怪诞行为学2》 这本书的介绍吧!

在线进制转换器
在线进制转换器

各进制数互转换器

RGB HSV 转换
RGB HSV 转换

RGB HSV 互转工具

HEX CMYK 转换工具
HEX CMYK 转换工具

HEX CMYK 互转工具