stupidc

From Esolang
Jump to navigation Jump to search
This article is not detailed enough and needs to be expanded. Please help us by adding some more information.

stupidc is a vaguely C-style language that compiles directly to 6502 assembly natively. The compiler, although still in development, can be found at the GitHub repository, and is written in QuickBasic.[1]

NOTE: This information is outdated. I plan to update it in the future.

NOTE 2: i still haven't updated it yet.

(more info coming soon!)

Syntax

Symbol types

stupidc operates on a set of prefixes to identify what kind of value is in an argument.

Prefix Used by
% Variables
: Labels and constants
# Literal values
$ Subroutines
* Functions
. Built-in functions
& Modes
~ Inline subs
? Booleans

Reference guide

Built in

These are statements built-in to stupidc, or are part of a module.

Statements

<comment>

include(&library or #"filename");

system(&BE_6502); Note: This is planned to be able to accept other "system" declarations, but at the moment, it only works with &BE_6502 (Ben Eater 6502 computer)

if(condition, { code if true });

if(condition, { code if true }, { code if not true });

while(condition, { code } );

def(%variable);

mem(%variable, #elements);

data(:label, #value(s) or &*);

set(%variable, value);

asm(&"Assembly source to insert");

sub($subroutine, { code });

func(*function, { code });

return(value);

inline(~inline, { code });

reset({ code });

irq({ code });

nmi({ code });

irq(&on or off);

halt();

Functions

.and(value, value)

.or(value, value)

.xor(value, value)

.not(value)

.sum(value, value)

.diff(value, value)

.rotl(value, value)

.rotr(value, value)

.shiftl(value, value)

.shiftr(value, value)

.pullarg()

Booleans

?eq(value, value)

?ne(value, value)

?not(value)

?lt(value, value)

?gt(value, value)



stupidc.scl

This library is used to add more functionality to stupidc.

Inline subroutines

~push(value);

Functions

*b2s(value)

*i2s(value)

*pull(value)



lcd.scl

This is a library for communicating with a character LCD panel through the VIA.

Subroutines

$lcd.init(initcommand);

$lcd.print(string);

$lcd.print.chr(character);

Functions

*isready()



via.scl

This is a library for communicating to a W65c22/MOS-6522 chip (aka Versatile Interface Adapter).

timer functionality is not supported currently

Inline subroutines

~via.a.io(I/O modes);

~via.a(status);

~via.b.io(I/O modes);

~via.b(status);

Symbols

:via.a

:via.a.io

:via.b

:via.b.io


Sample programs

Hello world (with character LCD)

system(&BE_6502);
include(&lcd.scl);
$lcd.init(&f14_l1);

$lcd.print(#"Hello, world!");
halt();

Count to 255

system(&BE_6502);
include(&lcd.scl);
$lcd.init(&f8_l2);

def(%i);
set(%i, 0);
while(%i, { <loop until %i rolls back to 0, essentially loop 256 times>
  $lcd.print(*b2s(%i));
  $lcd.print.chr(#' '); <space character>
});
halt();

Count to 65525

system(&BE_6502);
include(&lcd.scl);
$lcd.init(&f8_l2);

mem(%i, 2); <we use an array because we need to guarantee that the two variables are next to each other.>
set(%i.0, #0); <make sure to init to 0! Note that using %i.0 is exactly the same as using %i>
set(%i.1, #0);

while(%i.1, {
  while(%i.0, {
    $lcd.print(*i2s(%i));
    $lcd.print(#' ');
    inc(%i.0);
  });
  inc(%i.1);
});
halt();
  1. Note: stupidc requires QB w/ PDS features, which are present in QuickBasic 7.0 and newer. This means that it cannot run in the more popular, but older version of QB, QuickBasic 4.5; nor can it run in the modern QB recreation that is QB64. It is, however, compatible with Visual Basic for DOS, but not any other version of Visual Basic. Confusing, right?
    Either way, you need to have some sort of DOS environment set up in order to enjoy the completely underwhelming experience that is stupidc.