Skip to content

Chip8/libc8lexer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 

Repository files navigation

libc8lexer

A lexer module for Chip-8 assembly.

Extra Link: Standard Chip-8 Instructions

Usage

Include the header file as a static/dynamic library file.

class libc8Lexer

//Source file content,read into string source
ADD V1, V2
SUB V2, V3
JP I
CALL I
libc8Lexer lexer(source);
if(lexer.Scan())
	{
	std::cout<<lexer.Output();
}

The output would be:

[Instruction]    (0 - 2) : ADD
[8 Bit Register]    (4 - 5) : V1
[Comma]    (6) : ,
[8 Bit Register]    (8 - 9) : V2
[Instruction]    (11 - 13) : SUB
[8 Bit Register]    (15 - 16) : V2
[Comma]    (17) : ,
[8 Bit Register]    (19 - 20) : V3
[Instruction]    (22 - 23) : JP
[Address Register]    (25) : I
[Instruction]    (27 - 30) : CALL
[Address Register]    (32) : I

There are also a member function of libc8lexer which returns the token list

std::vector<libc8Token>& libc8lexer::GetList()

Releases

No releases published

Packages

No packages published

Languages