How made Parser/Lexer? for my virtual machine

Started by Mangro, Aug 18, 2022, 04:21 PM

Previous topic - Next topic

Mangro

https://pastebin.com/xqBSpUiW


How made Lexer/Parser for my project - Virtual machine, i know its very small project. He can only change flags, change registers value's and just print registers

Can you help me to create compiler for this assembler, its works like:
machine <file.asm>
and he running, compiling file, starts machine
Registers: ax,bx,cx - free registers, cc - register for asl,asr,and another
About assembler look:
mova < number < 255 > --Mov number to register ax
movb < number < 255 > --Mov number to register bx
movc < number < 255 > --Mov number to register cx
movcc < number < 255 > --Mov number to register cc
asl < register >--ARIFMETIC SHIFT LEFT,get from cc register and if value 1 = ax, 2 = bx, 3 = cx
asr < register >--Arifmetic shift right
--And more

Please help who know how create compiler/parser/lexer
THANKS