VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



C to ASM a compiler in the development (very early stages)

by David Yang (3 Submissions)
Category: Complete Applications
Compatability: Visual Basic 5.0
Difficulty: Advanced
Date Added: Wed 3rd February 2021
Rating: (4 Votes)

THis program translates a subset of C into asm, currently, it supports looping (for, while), conditions (if), maths (+,*,-,/), boolean operators (&&, ||), arrays(partly)
This outputs asm code that should work, the output is currently generic asm code, without conforming to the rules of any specific asm compiler, but that can be easily taken care of.
THis program is written in excel Visual basic, because my version of Visual basic was deleted, and i lost my visual basic installation cd. anyway, you can still run it. TO view the source code, press ALT+F11 to enter a editor, much like the normal VB editor (sorry about that...)
Sample Code Translation is below (in the "Windows API section" below):

API Declarations
int main()
{
msgbox(hitme(5,6));
};
int hitme(int a,int b)
{
a=a*a+b*b;
return a;
};
TRANSLATES TO::
const \\ --String Constants
code \\ --Code Section
\\ --Function: main
Func main
push ebp
mov ebp, esp
Push 6
Push 5
call hitme
Push eax
call msgbox
pop ebp
retn
\\ --Function: hitme
Func hitme
push ebp
mov ebp, esp
add esp, 2
mov ebx, [ebp-12]
mov eax, [ebp-12]
imul ebx
mov ebx, eax
mov ecx, [ebp-8]
mov eax, [ebp-8]
imul ecx
mov ecx, eax
add ecx, ebx
mov [ebp-8], ecx
sub esp, 2
pop ebp
retn

Rate C to ASM a compiler in the development (very early stages)

Download C to ASM a compiler in the development (very early stages)

Download C to ASM a compiler in the development (very early stages) (99 KB)

C to ASM a compiler in the development (very early stages) Comments

No comments have been posted about C to ASM a compiler in the development (very early stages). Why not be the first to post a comment about C to ASM a compiler in the development (very early stages).

Post your comment

Subject:
Message:
0/1000 characters