Post Reply 
monic part 6: the mC programming language and compiler
06-27-2022, 04:37 AM (This post was last modified: 07-05-2022 04:09 AM by F-73P.)
Post: #15
RE: monic part 6: the mC programming language and compiler
(06-25-2022 02:04 PM)robve Wrote:  Some switcheroo, in case you've not seen it before Smile
- Rob

Thanks Rob, I haven't. Something to think about for a future version.

BTW, I've managed to run the remarkable program you recently posted for computing the digits of pi:

Code:

1 unsigned long a=10000,d;
2 unsigned b,c,e,*f,g;
3 main(){
4  printf("digits?");scanf("%u",&c);
5  c=7*c/2;c-=c%14;f=malloc(4*c+4);
6  for(;b-c;)f[b++]=a/5;
7  for(;d=0,g=c*2;c-=14,printf("%.4lu",e+d/a),e=d%a)
8   for(b=c;d+=f[b]*a,f[b]=d%--g,d/=g--,--b;d*=b);
9 }

It is interesting to compare the lengths of the C code and the translated bytecode, 15 lines vs 101:

[Image: 52186665417_fda3557de8.jpg]

[Image: 52186651987_1545c79465_n.jpg][Image: 52186651897_a9d222d99b_n.jpg][Image: 52187920694_85da5f9d62_n.jpg]
[Image: 52187671356_07421091fa_n.jpg][Image: 52186651612_6b914ef413_n.jpg][Image: 52187920489_d5f02e7b32_n.jpg]

I'll now add some display functions to the language in order to display the digits as the program runs.

The C language combines all the power of assembly language with all the ease-of-use of assembly language
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: monic part 6: the mC programming language and compiler - F-73P - 06-27-2022 04:37 AM



User(s) browsing this thread: 1 Guest(s)