Skip to content

hatcatpat/feab

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

logo/example

an 8bit fantasy console and assembly language

feab is a fantasy console, similar to pico8 and tic80, and an 8bit assembly language inspired by (6502 or uxntal)

dependencies

  • ansi c
  • only dependency of the assembler/vm is stdio.h, and no dynamic memory is used
  • emulator uses SDL2

info

  • the console and program are stored in a single array, meaning that you are free to modify any byte of the console or program whenever you want. the only exceptions being the return stack, stack counter (sc) and program counter (pc), and program length

  • there are no registers, so all opcodes are applied to a given location in memory

  • labels act as functions or variables, depending on how you use them. a label is simply a location in memory, so you can either jump to that location (function), or modify the byte at that location (variable).

  • labels are unique (i.e., no 2 can have the same name), whereas sublabels (denoted by a '@') can be reused in each scope.

  • macros are of the form # NAME A B C D ... #

    • ascii letters, useful memory locations, and key bitflags are avaiable as macros by default
  • addresses are 16-bits wide (two 8-bits). if you use a label, it will be converted to a 16-bit number. numbers prefixed with a & will also be converted to a 16-bit number

  • numbers can be base-10, hexadecimal (ff), or binary (%01101100)

  • some key opcodes:

    • SET dest what -> memory[dest] = what
    • GET dest source -> memory[dest] = memory[source]
    • REF dest location -> memory[dest] = HIGH(location), memory[dest + 1] = LOW(location)
    • DEREF dest pointer -> memory[dest] = memory[memory[pointer] << 8 | memory[pointer + 1]]
    • JUMP address -> sets the PC to the given address
    • CALL address -> same as jump, but pushes the previous location on the return stack
    • RET -> returns to the previous location on the return stack
    • WAIT -> waits until the next frame
  • many opcodes also have a V (value) mode, which treats the first argument as a pointer to an address. this allows you to store addresses in variables, and modify the address that is pointed to

  • there are 4 colours (background, 1, 2, 3), each rgb component has 2 bits (0, 85, 170, 255)

  • there are 16 sprites, each with an (x,y) coordinate and sprite id. if the id is 16 the sprite will be hidden, otherwise it will draw the specified sprite data

  • sprites are 4x4 pixels and consist of 4 rows of the form 00 00 00 00, where each 2 bits determines the colour used for that pixel (00 is colour 0, 01 is color 1, etc)

  • to reload sprite data, the load_sprite flag (4) must be enabled

About

a virtual console and assembly language

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published