Skip to content

Generation of x64 assembly that behaves like a stack machine

Notifications You must be signed in to change notification settings

rbbarbosa/x64_stack_machine

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tiny x86-64 stack machine

Generates x86-64 assembly code for evaluating simple expressions

  • Expression evaluation using a stack and one accumulator (%rax)
  • Syntax-directed translation: code is generated without a syntax tree

Reads infix expressions, implicitly converts them to postfix notation, then:

given a postfix expression, for each token:

if token is operand:

push accumulator (%rax) onto stack
accumulator (%rax) <- token value

if token is operator:

operand2 (%rbx) <- accumulator (%rax)
operand1 (%rax) <- pop value from the stack
accumulator (%rax) <- result of operation with operand1 and operand2

if end of expression reached:

pop top of stack

About

Generation of x64 assembly that behaves like a stack machine

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published