Skip to content

A simple C/C++ ASM assembler and interpreter for learning purpose

License

Notifications You must be signed in to change notification settings

onidev/SimpleAsm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SimpleAsm

A minimalist C++ ASM assembler and interpreter for learning purpose.

Technical

Five registers: ax, bx, cx, dx, ex.

A stack of size 1024.

10 instructions:

  • mov
  • push
  • load
  • store
  • add
  • sub
  • mul
  • jmp
  • jz
  • print

Instructions are 32 bits, and splitted in 4 bytes for the instruction number and the registres id: (Instr, Reg1, Reg2, Reg3).

Examples

Example of Fibonacci in Simple Asm

	mov ax 0  ; a = 0
	mov bx 1  ; b = 1
	mov cx 10 ; i = 10

loop:
	; while(i)
	load cx
	jz end
	
	; t = a + b
	load ax
	load bx
	add
	; a = b
	mov ax bx
	; b = t
	store bx
	
	load bx
	print

	; i--
	load cx
	push 1
	sub
	store cx
	
	jmp loop

end:

Examples of factorial in Simple Asm.

About

A simple C/C++ ASM assembler and interpreter for learning purpose

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages