Author Topic: Converting arithmetic expressions to Assembly  (Read 614 times)

Offline UniverseIsASimulation

  • Jr. Member
  • *
  • Posts: 7
Converting arithmetic expressions to Assembly
« on: February 15, 2018, 07:48:11 PM »
Hey, guys!
New here. I've just made a simple web-app that attempts to convert arithmetic expressions to i486-compatible assembly:
Arithmetic expression to assembly converter
I've tried to test it (using Flat Assembler), and to me it seems like it produces correct results. However, I am not a professional programmer, so I would like to hear from some experts.
« Last Edit: February 15, 2018, 07:49:47 PM by UniverseIsASimulation »

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2292
  • Country: us
Re: Converting arithmetic expressions to Assembly
« Reply #1 on: February 15, 2018, 10:37:42 PM »
Hi UniverseIsASimulation,

Welcome to the forum.

Your web-app is impressive (once it wakes up), but attempting to assemble it results in a long string of syntax errors. If it works in Fasm, better stick to Fasm. Nasm syntax and Fasm syntax are quite similar, but not exactly the same. "2f" etc. seem to be a problem...

Best,
Frank


Offline UniverseIsASimulation

  • Jr. Member
  • *
  • Posts: 7
Re: Converting arithmetic expressions to Assembly
« Reply #2 on: February 16, 2018, 07:09:01 AM »
The app is just 600 lines of code, almost all in JavaScript.
What's a more portable syntax for "mov [result],2f"? In FASM, that means "Store the 32-bit floating-point value 2.0 on the address that the pointer 'result' points to.".

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2292
  • Country: us
Re: Converting arithmetic expressions to Assembly
« Reply #3 on: February 16, 2018, 07:18:35 PM »
Code: [Select]
mov dword [result],  __float32__(2.0)

I guess. If you're looking for "portable" you're in the wrong church.

Best,
Frank


Offline UniverseIsASimulation

  • Jr. Member
  • *
  • Posts: 7
Re: Converting arithmetic expressions to Assembly
« Reply #4 on: February 17, 2018, 01:32:29 PM »
Uf, that doesn't work in FASM.

I'll stick to FASM though. Programs that try to generate assembly which is supposed to be portable usually target GAS (which is available on both PC and MAC, and uses the same syntax for all x86 architectures), but GAS has a very tough syntax, do we agree?

So, it takes 600 lines of JavaScript to convert arithmetic expressions to Assembly. How many lines of code does it take to convert that Assembly to the machine code? Is it even possible to do in JavaScript or would I have to learn another programming language to do that? I am not planning to actually attempt to do that, I am just curious.

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2292
  • Country: us
Re: Converting arithmetic expressions to Assembly
« Reply #5 on: February 18, 2018, 03:23:06 AM »
Yeah, Gas has a pretty bad reputation, but Nasm is no prize in this case.

I don't know anything about Javascript.

Best,
Frank


Offline UniverseIsASimulation

  • Jr. Member
  • *
  • Posts: 7
Re: Converting arithmetic expressions to Assembly
« Reply #6 on: March 31, 2018, 04:54:05 PM »
Is there some part of programming you would recommend me to learn so that I can start making some money? Nobody is going to pay me for being able to make a web-app that converts arithmetic expressions to i486-compatible assembly. The only programming language I know well enough right now to be able to do that in is JavaScript.

Offline UniverseIsASimulation

  • Jr. Member
  • *
  • Posts: 7
Re: Converting arithmetic expressions to Assembly
« Reply #7 on: April 28, 2018, 04:32:01 PM »
OK, I get it. This isn't a good forum for such questions.

Offline UniverseIsASimulation

  • Jr. Member
  • *
  • Posts: 7
Re: Converting arithmetic expressions to Assembly
« Reply #8 on: June 27, 2018, 01:09:33 PM »
Anyway, the web-app has been improved in quite a lot of ways since I last posted here. Now it has syntax highlighting and the diagnostic messages have been substantially improved.

Offline UniverseIsASimulation

  • Jr. Member
  • *
  • Posts: 7
Re: Converting arithmetic expressions to Assembly
« Reply #9 on: June 28, 2018, 09:32:56 AM »
I'd like to get some feedback. I used to think that web-app can be useful. Or can it be actually?

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2292
  • Country: us
Re: Converting arithmetic expressions to Assembly
« Reply #10 on: June 29, 2018, 03:27:05 AM »
I really don't know what to tell you, UniverseIsASimulation. I personally don't have any arithmetic expressions I need converted to assembly language. If I did, I'd probably want to do it myself, "by hand". But that's just me.

Last I looked, the Fasm Forum was a lot more active than this Forum. Have you posted there? Get any feedback? Do you get any traffic on your web-app? I'm impressed that you could do it, but I really have no need of it. Wish I could tell you something more encouraging!

Best,
Frank