Skip to content

maitesin/acc

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
inc
 
 
src
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

ARM C Compiler (ACC)

Build Status Coverity Scan Build Status codecov

ACC is a project that its only aim is to improve my knowledge of two topics, C language and ARM assembly. I think this is a good exercise to go deep into both topics.

Parser

The ACC is a LALR(1) parser, that means it is a Look-Ahead Left-to-Right parser.

Grammar

S -> int main "(" ")" "{" E "}"
E -> return I;
     | if "(" B ")" "{" E "}"
     | if "(" B ")" "{" E "}" else "{" E "}"
I -> [0-9]+
B -> I < I
     | I <= I
     | I == I
     | I >= I
     | I > I
     | ! B
     | "(" B ")"

Example

C code:

int main()
{
    if (1 < 2)
    {
	    if (4 > 10)
	    {
		    return 1;
	    }
	    else {
		    return 2;
	    }
    }
    return 0;
}

Assembly generated:

	.text
	.global main
main:
	mov r0, #1
	mov r1, #2
	cmp r0, r1
	bge if_else_0
	mov r0, #4
	mov r1, #10
	cmp r0, r1
	ble if_else_1
	mov r0, #1
	bx lr
if_else_1:
	mov r0, #2
	bx lr
if_else_0:
	mov r0, #0
	bx lr

About

ARM C Compiler (ACC) is project to improve my knowledge of C and ARM assembly

Resources

License

Stars

Watchers

Forks

Packages

No packages published