flat assembler
Message board for the users of flat assembler.
![]() Goto page 1, 2 Next |
Author |
|
revolution 12 Feb 2019, 10:35
I think the term you are looking for is porting.
So you want to port either fasmarm or fasmg (or both?) to run natively on the Android OS (which is using an ARM v7 CPU). Is that correct? |
|||
![]() |
|
Lost_Ghost123 12 Feb 2019, 10:41
Yes, exactly.
Is that how one replies? First time here... |
|||
![]() |
|
revolution 12 Feb 2019, 10:49
While porting is certainly possible, it is a lot of work. And chasing down bugs would take a while. You would need to rewrite the source by hand. And if Android enables alignment checking then you would also have to make sure all hword, word and dword reads/writes are suitably aligned. And keeping up with updates would be time consuming.
But there might be a be a better option. Use an emulator. QEMU comes to mind. I don't know if that runs on Android, I haven't tried it. If not, then there is likely some other emulator that can run x86 code on Android/ARM systems. Most probably you could run the Linux version of fasmg/fasmarm. fasmarm already has the ARM instructions included. If you choose fasmg then you will also need to write the ARM macros for it. |
|||
![]() |
|
Tomasz Grysztar 12 Feb 2019, 10:54
In theory you could probably write macros that would assemble x86 instructions in fasmg source into their ARM counterparts, with various caveats often leading to having to use multiple instructions to simulate a single x86 one. The result would be a terribly sub-optimal code, but it might work.
However, a good emulator may in fact end up running the original x86 code just as well if not better, if it uses dynamic recompilation. Windows on ARM should be able to run fasmg out of the box (I haven't tested it personally yet, but I see no reason why it shouldn't). I'm not sure what would be a good option for Android, though. As for the ARM instruction set macros themselves, for now we only have aarch64 ones by tthsqe. I was hoping revolution could one day become interested in playing with fasmg macros for ARM, being probably the most competent person to do that, but I understand that there are some hurdles. I may end up writing ones myself - I even consider doing it on stream one day. It could be an interesting opportunity to show how to solve various problems when implementing an architecture from ground up using fasmg macro language. |
|||
![]() |
|
Lost_Ghost123 12 Feb 2019, 11:00
Yes, I know all of that, I have Limbo x86 (port of QEMU) installed. Although running an entire operating system on my poor Xiaomi would be some bad user experience. About x86->Android emulator, I didn't stumble upon it, but I will search for it specifically.
So, if I choose the porting route, questions still stand: Is 80386.inc file just the instruction set, or does it also contain inner logic of fasmg? Also, how do I make my own instruction set? I looked into the manual and here, but haven't found anything. |
|||
![]() |
|
revolution 12 Feb 2019, 11:01
Tomasz Grysztar wrote: In theory you could probably write macros that would assemble x86 instructions in fasmg source into their ARM counterparts, with various caveats often leading to having to use multiple instructions to simulate a single x86 one. The result would be a terribly sub-optimal code, but it might work. |
|||
![]() |
|
revolution 12 Feb 2019, 11:05
Lost_Ghost123 wrote: Yes, I know all of that, I have Limbo x86 (port of QEMU) installed. Although running an entire operating system on my poor Xiaomi would be some bad user experience. About x86->Android emulator, I didn't stumble upon it, but I will search for it specifically. |
|||
![]() |
|
Lost_Ghost123 12 Feb 2019, 11:06
Hi Tomasz, just wanted to say that I really enjoy your streams, keep up the good content!
But isn't having to use multiple instructions on ARM for a single x86 one the only option with CISC->RISC? I will probably have to read more into that. Also I didn't actually know what aarch64 was, will look into it right now, thanks! |
|||
![]() |
|
Tomasz Grysztar 12 Feb 2019, 11:22
Lost_Ghost123 wrote: So, if I choose the porting route, questions still stand: Is 80386.inc file just the instruction set, or does it also contain inner logic of fasmg? Lost_Ghost123 wrote: Also, how do I make my own instruction set? I looked into the manual and here, but haven't found anything. revolution wrote: That process is really difficult in reality. The existence of the p flag (parity) alone makes it awkward. |
|||
![]() |
|
revolution 12 Feb 2019, 11:52
Tomasz Grysztar wrote:
|
|||
![]() |
|
Tomasz Grysztar 12 Feb 2019, 12:45
Even JP might not be that much problematic if used in specific context. As long as there is no label that one might jump to immediately in front of JP, it can be interpreted in conjunction with instruction that precedes it, and the parity computation can be added only in that specific place. Since x86 P flag is computed on 8 bits only, three shifts and then a bit test are enough to emulate it for purposes of JP/JNP.
|
|||
![]() |
|
revolution 12 Feb 2019, 13:04
If you know the exact circumstances then you can code special cases the handle them. But they only work only for that one source, and maybe only for that one version of that source, and hope nothing changes to break it in the next update. Those kinds of situations make me a bit nervous.
There is also the auxillary flag that ARM has no notion of. And anything that uses PUSHF/POPF needs to be examined to make sure the memory version of the flags is not being read or manipulated for specific bits. Alignment problems will require extra time to solve with rewriting the source to deal with discontinuities created by adjusting memory offsets. So it needs more than just a set of macros, it also needs a human to examine and adjust things to finalise it correctly. |
|||
![]() |
|
Lost_Ghost123 12 Feb 2019, 16:30
Ok, I've made a decision to write my own fasmg in C. I will try to implement all feachures from the manula and compile it for ARM. I know, the output will not be executable under ARM, but hey, it will be purely for my own education.
Now, Tomasz, Rev, are there any features that aren't included in the Tricky Stuff in Fasmg series that I have to implement or keep an eye out for? |
|||
![]() |
|
revolution 12 Feb 2019, 16:46
Lost_Ghost123 wrote: Ok, I've made a decision to write my own fasmg in C. Another way could be to write macros to decode the x86 source input and output equivalent ARM binary code. Then use fasmg to assemble an x86 source into ARM code. It would still need tweaking of the sources to comply with the Android OS interface, but the code in SYSTEM.INC is quite easy to adapt. So the process could be this:
|
|||
![]() |
|
guignol 12 Feb 2019, 17:04
|
|||
![]() |
|
guignol 12 Feb 2019, 17:08
nativecode GUI is what's for Android
ps One thing they did not solve for android, it's hints... _________________ qiq; |
|||
![]() |
|
Lost_Ghost123 12 Feb 2019, 17:23
Is that a link to a page about a processor of some kind? How is that relevant
Gui is for android, but I specifically said that I wanted fasmg to run from a termial emulator, so GUI is not needed. Or what were you trying to say, I don't get the purpose of your comment. |
|||
![]() |
|
guignol 12 Feb 2019, 17:31
Ay, the question is if revolution can make this portable mini surcompteur for 600$?
|
|||
![]() |
|
Tomasz Grysztar 12 Feb 2019, 17:36
Lost_Ghost123 wrote: Now, Tomasz, Rev, are there any features that aren't included in the Tricky Stuff in Fasmg series that I have to implement or keep an eye out for? This means, that by following the manual to the letter you should be able to get compatibility at level sufficient to be able to assemble the same sources correctly, except for possible bugs. But there is another layer to it. What the manual intentionally does not describe are the details of prediction algorithms in the code resolving process. These may vary from implementation to implementation, and the result might be that even though the same sources are resolved correctly by two assemblers, they may require a different number of passes to do so, or the optimization may end up a bit different, or in extreme case one assembler may be able to find a solution when another is not. The specific algorithms used by my version of fasmg are such that it is able to resolve code in the same way as fasm 1, but with some additional considerations due to much more complex character of fasmg's language (like arbitrary-size linear polynomials, etc.). Their specifics are such that it would be hard to untangle them from the details of design of this specific implementation - so it is very likely that by writing another one you'd end up with at least slightly different prediction-making behavior, unless you just take my source code and meticulously rewrite it in another language, routine after routine. |
|||
![]() |
|
Goto page 1, 2 Next < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.