Posts: 2020
Threads: 133
Joined: July 26, 2017
Reputation:
5
RE: Arithmetic Expression Compiler
May 25, 2019 at 2:28 pm
(May 10, 2019 at 7:45 am)Smaug Wrote: (January 2, 2019 at 3:01 am)FlatAssembler Wrote: So, I'd like to share my first steps in designing programming languages. As some of you know, for the last 11 months or so, I've been developing a program called Arithmetic Expression Compiler. It's written mostly in JavaScript and it converts directives from my own programming language (at first just arithmetic expressions) to FlatAssembler-compatible and i486-compatible (let's pretend it's i486-compatible, I haven't bothered to actually test it on anything else than my 12-year-old PC with 1Ghz Celeron processor) assembly. Recently, using the Duktape framework, I extended it to be able to not just compile single directives, but entire simple programs written in files.
So, here is one of the first programs I've written in the first programming language I've made myself:
Code: ;Advanced example: implementing the permutation algorithm.
AsmStart
debug=0
macro pushIntToStack x
{
sub esp,4
fld dword [x]
fistp dword [esp]
}
macro pushPointerToStack x
{
sub esp,4
lea ebx,[x]
mov [esp],ebx
}
macro pushStringToStack x
{
sub esp,4
mov dword [esp],x
}
format PE console
entry start
include 'win32a.inc'
section '.text' code executable
start:
jmp enterNumber$
enterNumber db "Enter a whole number (1 - 1'000'000).",10,0
enterNumber$:
pushStringToStack enterNumber
call [printf]
pushPointerToStack original
jmp floatSign$
floatSign db "%f",0
floatSign$:
pushStringToStack floatSign
call [scanf]
jmp permutationString$
permutationString db "The permutations of its digits are:",10,0
permutationString$:
pushStringToStack permutationString
call [printf]
AsmEnd
numberOfDigits:=0
i:=0
While i<10
countDigits[i]:=0
i:=i+1
EndWhile
While original>0
numberOfDigits:= numberOfDigits + 1
lastDigit:= mod( original , 10 )
countDigits[ lastDigit ]:=countDigits( lastDigit ) + 1
original:= (original - lastDigit) / 10
EndWhile
AsmStart
if debug=1
AsmEnd
i:=0
While i<10
subscript:=4*i
AsmStart
fld dword [subscript]
fistp dword [subscript]
mov ebx,[subscript]
pushIntToStack (countDigits+ebx)
pushStringToStack integerSign
call [printf]
AsmEnd
i:=i+1
EndWhile
AsmStart
pushStringToStack newLineString
call [printf]
AsmEnd
AsmStart
end if
AsmEnd
topOfMyStack:=1
myStack[(numberOfDigits+1)]:=0
While topOfMyStack>0
currentNumberOfDigits:=myStack ( topOfMyStack * ( numberOfDigits + 1 ) )
i:=0
While i<currentNumberOfDigits
currentNumber(i):=myStack ( topOfMyStack * ( numberOfDigits + 1 ) + ( i + 1 ) )
i:=i+1
EndWhile
AsmStart
if debug=1
AsmEnd
i:=0
While i<currentNumberOfDigits
subscript:=i*4
AsmStart
fld dword [subscript]
fistp dword [subscript]
mov ebx,[subscript]
pushIntToStack (currentNumber+ebx)
pushStringToStack integerSign
call [printf]
AsmEnd
i:=i+1
EndWhile
AsmStart
pushStringToStack newLineString
call [printf]
AsmEnd
AsmStart
end if
AsmEnd
topOfMyStack:=topOfMyStack-1
If currentNumberOfDigits=numberOfDigits
i:=0
While i<numberOfDigits
subscript:=i*4
AsmStart
fld dword [subscript]
fistp dword [subscript]
mov ebx,[subscript]
pushIntToStack (currentNumber+ebx)
pushStringToStack integerSign
call [printf]
AsmEnd
i:=i+1
EndWhile
AsmStart
pushStringToStack newLineString
call [printf]
AsmEnd
Else
i:=0
While i<10
counter:=0
j:=0
While j<currentNumberOfDigits
If currentNumber(j)=i
counter:=counter+1
EndIf
j:=j+1
EndWhile
If counter<countDigits(i)
topOfMyStack:=topOfMyStack+1
myStack(topOfMyStack*(numberOfDigits+1)):=currentNumberOfDigits+1
j:=0
While j<currentNumberOfDigits
myStack(topOfMyStack*(numberOfDigits+1)+(j+1)):=currentNumber(j)
j:=j+1
EndWhile
myStack (topOfMyStack * (numberOfDigits + 1) + (j + 1) ) := i
EndIf
i:=i+1
EndWhile
EndIf
EndWhile
AsmStart
invoke system,_pause
invoke exit,0
_pause db "PAUSE",0
integerSign db "%d",0
newLineString db 10,0
section '.rdata' readable writable
original dd ?
result dd ?
lastDigit dd ?
numberOfDigits dd ?
countDigits dd 11 dup(?)
subscript dd ?
myStack dd 1000 dup(?)
topOfMyStack dd ?
counter dd ?
i dd ?
currentNumber dd 11 dup(?)
currentNumberOfDigits dd ?
j dd ?
section '.idata' data readable import
library msvcrt,'msvcrt.dll'
import msvcrt,printf,'printf',system,'system',exit,'exit',scanf,'scanf'
AsmEnd
You can download the source code of my compiler there, there is a link there to a ZIP-archive containing the source code and instructions on how to compile it using CLANG or GCC (000webhost doesn't allow me to host executable files):
http://flatassembler.000webhostapp.com/compiler.html
I've designed this programming language to be as easy to integrate with Assembly as possible. The Assembly code C compilers have to produce (trying to declare variables themselves, trying to declare functions themselves...) has to be almost completely rewritten if you are targeting a different assembly language compiler or a different operating system.
However, the solution I've made may be even worse than the problem. The programs written in that programming language are completely non-portable. Also, since my compiler tries to make as few assumptions as possible, it produces way inferior Assembly code than any decent C-compiler would. However, it seems to make no perceptible difference on a what's now a 12-year-old computer (the Assembly code a JavaScript JIT-compiler produces is probably even less optimal). Also, because of the design of my programming language, it often happens that a compiler doesn't catch an error such as using an undeclared variable and outputs syntactically invalid Assembly.
I am also dreaming about making a compiled LISP-like language in which you could write arithmetic expressions in both S-expressions and infix-expressions, but be able to use only S-expressions elsewhere (since they come very handy in string and array-manipulation). However, I probably won't have time for that in foreseeable future.
Basically, you're trying to write a computer algebera system, am I right? That is a very interesting task. Do you plan to develop it to some usable version or just write it to learn?
I myself made a simple parser for analytic expressions a year ago or so. I wrote it in C# since I had no intent to make it optimal or something (I also don't know low-level languages nearly good enaugh to get into optimization). The goal was to learn from practice some of the the principles of how systems like Maple and Matlab operate. The parcer could parse algebraic expressions into trees, differentiate in respect to a variable or to time and prepare Lagrange's DE's.
Wait, how did you make it output the derivative? It's certainly harder than making it output assembly, or even doing the basic algebraic operations.
Posts: 273
Threads: 2
Joined: November 19, 2014
Reputation:
9
RE: Arithmetic Expression Compiler
May 31, 2019 at 5:56 am
(This post was last modified: May 31, 2019 at 6:05 am by Smaug.)
(May 25, 2019 at 2:28 pm)FlatAssembler Wrote: (May 10, 2019 at 7:45 am)Smaug Wrote: Basically, you're trying to write a computer algebera system, am I right? That is a very interesting task. Do you plan to develop it to some usable version or just write it to learn?
I myself made a simple parser for analytic expressions a year ago or so. I wrote it in C# since I had no intent to make it optimal or something (I also don't know low-level languages nearly good enaugh to get into optimization). The goal was to learn from practice some of the the principles of how systems like Maple and Matlab operate. The parcer could parse algebraic expressions into trees, differentiate in respect to a variable or to time and prepare Lagrange's DE's.
Wait, how did you make it output the derivative? It's certainly harder than making it output assembly, or even doing the basic algebraic operations.
Unlike finding an indefinite integral, finding a derivative is a fully algorithmic procedure so it isn't decisively harder than doing basic algebraic operations. First you have to expand the initial expression to get rid of all the brackets. Then you have to go through all the terms and apply the chain rule which is somewhat similar to dealing with nested brackets. This step may take several iterations. While doing that it is handy to use 'delayed evaluation'. I. e. you just mark functions with a derivative sign and do not substitute anything from the table of derivatives. After doing so you obtain a tree which has derivatives of elementary functions as its leafs. The final step is to evaluate the leafs by substituting from the table.
Differentiating functions of time-dependant coortinates in respect to time is somewhat harder but it's basically the same thing.
Posts: 7259
Threads: 506
Joined: December 12, 2015
Reputation:
22
RE: Arithmetic Expression Compiler
May 31, 2019 at 7:17 am
(January 2, 2019 at 3:01 am)FlatAssembler Wrote: So, I'd like to share my first steps in designing programming languages. As some of you know, for the last 11 months or so, I've been developing a program called Arithmetic Expression Compiler. It's written mostly in JavaScript and it converts directives from my own programming language (at first just arithmetic expressions) to FlatAssembler-compatible and i486-compatible (let's pretend it's i486-compatible, I haven't bothered to actually test it on anything else than my 12-year-old PC with 1Ghz Celeron processor) assembly. Recently, using the Duktape framework, I extended it to be able to not just compile single directives, but entire simple programs written in files.
So, here is one of the first programs I've written in the first programming language I've made myself:
Code: ;Advanced example: implementing the permutation algorithm.
AsmStart
debug=0
macro pushIntToStack x
{
sub esp,4
fld dword [x]
fistp dword [esp]
}
macro pushPointerToStack x
{
sub esp,4
lea ebx,[x]
mov [esp],ebx
}
macro pushStringToStack x
{
sub esp,4
mov dword [esp],x
}
format PE console
entry start
include 'win32a.inc'
section '.text' code executable
start:
jmp enterNumber$
enterNumber db "Enter a whole number (1 - 1'000'000).",10,0
enterNumber$:
pushStringToStack enterNumber
call [printf]
pushPointerToStack original
jmp floatSign$
floatSign db "%f",0
floatSign$:
pushStringToStack floatSign
call [scanf]
jmp permutationString$
permutationString db "The permutations of its digits are:",10,0
permutationString$:
pushStringToStack permutationString
call [printf]
AsmEnd
numberOfDigits:=0
i:=0
While i<10
countDigits[i]:=0
i:=i+1
EndWhile
While original>0
numberOfDigits:= numberOfDigits + 1
lastDigit:= mod( original , 10 )
countDigits[ lastDigit ]:=countDigits( lastDigit ) + 1
original:= (original - lastDigit) / 10
EndWhile
AsmStart
if debug=1
AsmEnd
i:=0
While i<10
subscript:=4*i
AsmStart
fld dword [subscript]
fistp dword [subscript]
mov ebx,[subscript]
pushIntToStack (countDigits+ebx)
pushStringToStack integerSign
call [printf]
AsmEnd
i:=i+1
EndWhile
AsmStart
pushStringToStack newLineString
call [printf]
AsmEnd
AsmStart
end if
AsmEnd
topOfMyStack:=1
myStack[(numberOfDigits+1)]:=0
While topOfMyStack>0
currentNumberOfDigits:=myStack ( topOfMyStack * ( numberOfDigits + 1 ) )
i:=0
While i<currentNumberOfDigits
currentNumber(i):=myStack ( topOfMyStack * ( numberOfDigits + 1 ) + ( i + 1 ) )
i:=i+1
EndWhile
AsmStart
if debug=1
AsmEnd
i:=0
While i<currentNumberOfDigits
subscript:=i*4
AsmStart
fld dword [subscript]
fistp dword [subscript]
mov ebx,[subscript]
pushIntToStack (currentNumber+ebx)
pushStringToStack integerSign
call [printf]
AsmEnd
i:=i+1
EndWhile
AsmStart
pushStringToStack newLineString
call [printf]
AsmEnd
AsmStart
end if
AsmEnd
topOfMyStack:=topOfMyStack-1
If currentNumberOfDigits=numberOfDigits
i:=0
While i<numberOfDigits
subscript:=i*4
AsmStart
fld dword [subscript]
fistp dword [subscript]
mov ebx,[subscript]
pushIntToStack (currentNumber+ebx)
pushStringToStack integerSign
call [printf]
AsmEnd
i:=i+1
EndWhile
AsmStart
pushStringToStack newLineString
call [printf]
AsmEnd
Else
i:=0
While i<10
counter:=0
j:=0
While j<currentNumberOfDigits
If currentNumber(j)=i
counter:=counter+1
EndIf
j:=j+1
EndWhile
If counter<countDigits(i)
topOfMyStack:=topOfMyStack+1
myStack(topOfMyStack*(numberOfDigits+1)):=currentNumberOfDigits+1
j:=0
While j<currentNumberOfDigits
myStack(topOfMyStack*(numberOfDigits+1)+(j+1)):=currentNumber(j)
j:=j+1
EndWhile
myStack (topOfMyStack * (numberOfDigits + 1) + (j + 1) ) := i
EndIf
i:=i+1
EndWhile
EndIf
EndWhile
AsmStart
invoke system,_pause
invoke exit,0
_pause db "PAUSE",0
integerSign db "%d",0
newLineString db 10,0
section '.rdata' readable writable
original dd ?
result dd ?
lastDigit dd ?
numberOfDigits dd ?
countDigits dd 11 dup(?)
subscript dd ?
myStack dd 1000 dup(?)
topOfMyStack dd ?
counter dd ?
i dd ?
currentNumber dd 11 dup(?)
currentNumberOfDigits dd ?
j dd ?
section '.idata' data readable import
library msvcrt,'msvcrt.dll'
import msvcrt,printf,'printf',system,'system',exit,'exit',scanf,'scanf'
AsmEnd
You can download the source code of my compiler there, there is a link there to a ZIP-archive containing the source code and instructions on how to compile it using CLANG or GCC (000webhost doesn't allow me to host executable files):
http://flatassembler.000webhostapp.com/compiler.html
I've designed this programming language to be as easy to integrate with Assembly as possible. The Assembly code C compilers have to produce (trying to declare variables themselves, trying to declare functions themselves...) has to be almost completely rewritten if you are targeting a different assembly language compiler or a different operating system.
However, the solution I've made may be even worse than the problem. The programs written in that programming language are completely non-portable. Also, since my compiler tries to make as few assumptions as possible, it produces way inferior Assembly code than any decent C-compiler would. However, it seems to make no perceptible difference on a what's now a 12-year-old computer (the Assembly code a JavaScript JIT-compiler produces is probably even less optimal). Also, because of the design of my programming language, it often happens that a compiler doesn't catch an error such as using an undeclared variable and outputs syntactically invalid Assembly.
I am also dreaming about making a compiled LISP-like language in which you could write arithmetic expressions in both S-expressions and infix-expressions, but be able to use only S-expressions elsewhere (since they come very handy in string and array-manipulation). However, I probably won't have time for that in foreseeable future.
Designing your own computer language? Are you, like, a genius?
Posts: 2020
Threads: 133
Joined: July 26, 2017
Reputation:
5
RE: Arithmetic Expression Compiler
June 1, 2019 at 1:50 am
(This post was last modified: June 1, 2019 at 1:53 am by FlatAssembler.)
(May 31, 2019 at 5:56 am)Smaug Wrote: (May 25, 2019 at 2:28 pm)FlatAssembler Wrote: Wait, how did you make it output the derivative? It's certainly harder than making it output assembly, or even doing the basic algebraic operations.
Unlike finding an indefinite integral, finding a derivative is a fully algorithmic procedure so it isn't decisively harder than doing basic algebraic operations. First you have to expand the initial expression to get rid of all the brackets. Then you have to go through all the terms and apply the chain rule which is somewhat similar to dealing with nested brackets. This step may take several iterations. While doing that it is handy to use 'delayed evaluation'. I. e. you just mark functions with a derivative sign and do not substitute anything from the table of derivatives. After doing so you obtain a tree which has derivatives of elementary functions as its leafs. The final step is to evaluate the leafs by substituting from the table.
Differentiating functions of time-dependant coortinates in respect to time is somewhat harder but it's basically the same thing. You are making it sound so easy. How would you deal with the problems of deep and shallow copying in JavaScript while implementing that algorithm?
(May 31, 2019 at 7:17 am)Jehanne Wrote: (January 2, 2019 at 3:01 am)FlatAssembler Wrote: So, I'd like to share my first steps in designing programming languages. As some of you know, for the last 11 months or so, I've been developing a program called Arithmetic Expression Compiler. It's written mostly in JavaScript and it converts directives from my own programming language (at first just arithmetic expressions) to FlatAssembler-compatible and i486-compatible (let's pretend it's i486-compatible, I haven't bothered to actually test it on anything else than my 12-year-old PC with 1Ghz Celeron processor) assembly. Recently, using the Duktape framework, I extended it to be able to not just compile single directives, but entire simple programs written in files.
So, here is one of the first programs I've written in the first programming language I've made myself:
Code: ;Advanced example: implementing the permutation algorithm.
AsmStart
debug=0
macro pushIntToStack x
{
sub esp,4
fld dword [x]
fistp dword [esp]
}
macro pushPointerToStack x
{
sub esp,4
lea ebx,[x]
mov [esp],ebx
}
macro pushStringToStack x
{
sub esp,4
mov dword [esp],x
}
format PE console
entry start
include 'win32a.inc'
section '.text' code executable
start:
jmp enterNumber$
enterNumber db "Enter a whole number (1 - 1'000'000).",10,0
enterNumber$:
pushStringToStack enterNumber
call [printf]
pushPointerToStack original
jmp floatSign$
floatSign db "%f",0
floatSign$:
pushStringToStack floatSign
call [scanf]
jmp permutationString$
permutationString db "The permutations of its digits are:",10,0
permutationString$:
pushStringToStack permutationString
call [printf]
AsmEnd
numberOfDigits:=0
i:=0
While i<10
countDigits[i]:=0
i:=i+1
EndWhile
While original>0
numberOfDigits:= numberOfDigits + 1
lastDigit:= mod( original , 10 )
countDigits[ lastDigit ]:=countDigits( lastDigit ) + 1
original:= (original - lastDigit) / 10
EndWhile
AsmStart
if debug=1
AsmEnd
i:=0
While i<10
subscript:=4*i
AsmStart
fld dword [subscript]
fistp dword [subscript]
mov ebx,[subscript]
pushIntToStack (countDigits+ebx)
pushStringToStack integerSign
call [printf]
AsmEnd
i:=i+1
EndWhile
AsmStart
pushStringToStack newLineString
call [printf]
AsmEnd
AsmStart
end if
AsmEnd
topOfMyStack:=1
myStack[(numberOfDigits+1)]:=0
While topOfMyStack>0
currentNumberOfDigits:=myStack ( topOfMyStack * ( numberOfDigits + 1 ) )
i:=0
While i<currentNumberOfDigits
currentNumber(i):=myStack ( topOfMyStack * ( numberOfDigits + 1 ) + ( i + 1 ) )
i:=i+1
EndWhile
AsmStart
if debug=1
AsmEnd
i:=0
While i<currentNumberOfDigits
subscript:=i*4
AsmStart
fld dword [subscript]
fistp dword [subscript]
mov ebx,[subscript]
pushIntToStack (currentNumber+ebx)
pushStringToStack integerSign
call [printf]
AsmEnd
i:=i+1
EndWhile
AsmStart
pushStringToStack newLineString
call [printf]
AsmEnd
AsmStart
end if
AsmEnd
topOfMyStack:=topOfMyStack-1
If currentNumberOfDigits=numberOfDigits
i:=0
While i<numberOfDigits
subscript:=i*4
AsmStart
fld dword [subscript]
fistp dword [subscript]
mov ebx,[subscript]
pushIntToStack (currentNumber+ebx)
pushStringToStack integerSign
call [printf]
AsmEnd
i:=i+1
EndWhile
AsmStart
pushStringToStack newLineString
call [printf]
AsmEnd
Else
i:=0
While i<10
counter:=0
j:=0
While j<currentNumberOfDigits
If currentNumber(j)=i
counter:=counter+1
EndIf
j:=j+1
EndWhile
If counter<countDigits(i)
topOfMyStack:=topOfMyStack+1
myStack(topOfMyStack*(numberOfDigits+1)):=currentNumberOfDigits+1
j:=0
While j<currentNumberOfDigits
myStack(topOfMyStack*(numberOfDigits+1)+(j+1)):=currentNumber(j)
j:=j+1
EndWhile
myStack (topOfMyStack * (numberOfDigits + 1) + (j + 1) ) := i
EndIf
i:=i+1
EndWhile
EndIf
EndWhile
AsmStart
invoke system,_pause
invoke exit,0
_pause db "PAUSE",0
integerSign db "%d",0
newLineString db 10,0
section '.rdata' readable writable
original dd ?
result dd ?
lastDigit dd ?
numberOfDigits dd ?
countDigits dd 11 dup(?)
subscript dd ?
myStack dd 1000 dup(?)
topOfMyStack dd ?
counter dd ?
i dd ?
currentNumber dd 11 dup(?)
currentNumberOfDigits dd ?
j dd ?
section '.idata' data readable import
library msvcrt,'msvcrt.dll'
import msvcrt,printf,'printf',system,'system',exit,'exit',scanf,'scanf'
AsmEnd
You can download the source code of my compiler there, there is a link there to a ZIP-archive containing the source code and instructions on how to compile it using CLANG or GCC (000webhost doesn't allow me to host executable files):
http://flatassembler.000webhostapp.com/compiler.html
I've designed this programming language to be as easy to integrate with Assembly as possible. The Assembly code C compilers have to produce (trying to declare variables themselves, trying to declare functions themselves...) has to be almost completely rewritten if you are targeting a different assembly language compiler or a different operating system.
However, the solution I've made may be even worse than the problem. The programs written in that programming language are completely non-portable. Also, since my compiler tries to make as few assumptions as possible, it produces way inferior Assembly code than any decent C-compiler would. However, it seems to make no perceptible difference on a what's now a 12-year-old computer (the Assembly code a JavaScript JIT-compiler produces is probably even less optimal). Also, because of the design of my programming language, it often happens that a compiler doesn't catch an error such as using an undeclared variable and outputs syntactically invalid Assembly.
I am also dreaming about making a compiled LISP-like language in which you could write arithmetic expressions in both S-expressions and infix-expressions, but be able to use only S-expressions elsewhere (since they come very handy in string and array-manipulation). However, I probably won't have time for that in foreseeable future.
Designing your own computer language? Are you, like, a genius? Well, I've been studying various computer languages for, well, let's say 7 years or so. I happen to know one of them, JavaScript, enough to make a compiler for some simplified programming language in it. So, why not give it a try? You don't need to be a "genius" for that.
Posts: 273
Threads: 2
Joined: November 19, 2014
Reputation:
9
RE: Arithmetic Expression Compiler
June 1, 2019 at 1:24 pm
(June 1, 2019 at 1:50 am)FlatAssembler Wrote: You are making it sound so easy. How would you deal with the problems of deep and shallow copying in JavaScript while implementing that algorithm?
I didn't really came across such problems since I had no purpose to make the algorithm optimal. The purpose of the application as a whole was to accept a Hamiltonian or a Lagrangian as a text string and form a set of DE's to be solved numerically. This operation had to be done only once at the startup of the application. After than, only numerical computation had to be carried out. The numerical computation itself did not require much precision. The end purpose was to rougly compute curves for a short span of time for certain initial conditions that had to be compared. I used C# to implement this.
Posts: 2020
Threads: 133
Joined: July 26, 2017
Reputation:
5
RE: Arithmetic Expression Compiler
June 2, 2019 at 7:26 am
(June 1, 2019 at 1:24 pm)Smaug Wrote: (June 1, 2019 at 1:50 am)FlatAssembler Wrote: You are making it sound so easy. How would you deal with the problems of deep and shallow copying in JavaScript while implementing that algorithm?
I didn't really came across such problems since I had no purpose to make the algorithm optimal. The purpose of the application as a whole was to accept a Hamiltonian or a Lagrangian as a text string and form a set of DE's to be solved numerically. This operation had to be done only once at the startup of the application. After than, only numerical computation had to be carried out. The numerical computation itself did not require much precision. The end purpose was to rougly compute curves for a short span of time for certain initial conditions that had to be compared. I used C# to implement this.
I am not talking about making it efficient. I am talking about making it *work* in any programming language I know (I know nothing about C# right now).
Posts: 273
Threads: 2
Joined: November 19, 2014
Reputation:
9
RE: Arithmetic Expression Compiler
June 6, 2019 at 4:12 pm
(June 2, 2019 at 7:26 am)FlatAssembler Wrote: (June 1, 2019 at 1:24 pm)Smaug Wrote: I didn't really came across such problems since I had no purpose to make the algorithm optimal. The purpose of the application as a whole was to accept a Hamiltonian or a Lagrangian as a text string and form a set of DE's to be solved numerically. This operation had to be done only once at the startup of the application. After than, only numerical computation had to be carried out. The numerical computation itself did not require much precision. The end purpose was to rougly compute curves for a short span of time for certain initial conditions that had to be compared. I used C# to implement this.
I am not talking about making it efficient. I am talking about making it *work* in any programming language I know (I know nothing about C# right now).
Well, I just haven't come across that kind of a problem. Speaking of Java, I've never coded on it.
Posts: 2020
Threads: 133
Joined: July 26, 2017
Reputation:
5
RE: Arithmetic Expression Compiler
June 7, 2019 at 8:01 am
(June 6, 2019 at 4:12 pm)Smaug Wrote: (June 2, 2019 at 7:26 am)FlatAssembler Wrote: I am not talking about making it efficient. I am talking about making it *work* in any programming language I know (I know nothing about C# right now).
Well, I just haven't come across that kind of a problem. Speaking of Java, I've never coded on it.
Well, I only know very little Java. When I have to code in Java, I usually actually code in JavaScript and connect Java and JavaScript using the Rhino framework.
Posts: 2020
Threads: 133
Joined: July 26, 2017
Reputation:
5
RE: Arithmetic Expression Compiler
August 17, 2019 at 1:50 pm
On my website, I've uploaded some instructions about how to embed Assembly into C. Do you think they are understandable? Do you have some ideas how to write it better?
Posts: 2020
Threads: 133
Joined: July 26, 2017
Reputation:
5
RE: Arithmetic Expression Compiler
October 31, 2019 at 12:50 am
Just implemented the QuickSort algorithm in AEC (the programming language I made). You can see it here:
https://github.com/FlatAssembler/Arithme.../QuickSort
Right now, GCC produces assembly for an equivalent C code that's around 5 times faster than the assembly produced by the compiler I made for AEC. I don't even understand how the assembly code produced by GCC works. Learning assembly language is very frustrating, if you ask me.
|