flat assembler
Message board for the users of flat assembler.
![]() Goto page 1, 2 Next |
Author |
|
cwpjr 03 Jul 2012, 06:11
Or am I envisioning a translator?
|
|||
![]() |
|
revolution 03 Jul 2012, 08:17
You might be better off with a VM on the ARM to emulate the x86. Doing an opcode translation is not a trivial matter.
|
|||
![]() |
|
rugxulo 05 Jul 2012, 21:46
Uh, a VM on the ARM?? Bad idea, huge overkill, buggy, hard to find, etc. Preferable would probably be a cross-assembler (e.g. NASM built by Android NDK).
I know that jslinux has Venksi's 8086 DOS assembler ("cd /tmp && cp /var/root/dos/* . && runcom asm.com hpigot.s"), if that helps any, but I'm not sure how you get that result back. Can't remember, it does have some minimal cut and paste between host and guest, but I don't think it worked on my Android tablet (or only one way or ...). Hmmm, seems clipboard is there, presumably only host to guest, not sure how to send back otherwise ("nc" ???). |
|||
![]() |
|
revolution 05 Jul 2012, 23:53
rugxulo wrote: Uh, a VM on the ARM?? Bad idea, huge overkill, buggy, hard to find, etc. A line-by-line compiler-time translation can never be as efficient as a runtime VM. VMs have the advantage of knowing the runtime state. |
|||
![]() |
|
Tonymac32 06 Jul 2012, 14:10
Are we talking about an 8086 16-bit program, or an 80386+ 32-bit program? How many lines of assembly code? DOSBox has an ARM port that works quite well (it was able to start Dex4u back in 07 on my Jornada 720). Otherwise, if this is for a bare-metal distro, I'd recommend re-writing the code for the ARM.
|
|||
![]() |
|
cwpjr 07 Jul 2012, 23:45
Source x86 code is 80386+ 32-bit program. Will get LOC but know it compiles to @ 8K.
Last edited by cwpjr on 08 Jul 2012, 00:11; edited 1 time in total |
|||
![]() |
|
cwpjr 07 Jul 2012, 23:59
Vis the VM comments, pretty cool thoughts but I think I could say I'm interested in a port without the pain vs a emulation/translation. Many large fast processors could host an 80386+ VM and run the native compiled code, but my target is a small, cheap, low power Cortex M0.
So I may be thinking of a translator than analyzes the 80386+ register / ISA usage and maps them to the ARM ISA / registers. Assuming a simple re-map then I would use FASM ARM to cross compile to my target. Here meaning cross compile because I would not be compiling ARM assembly code on an ARM native machine environment. So what may be confusing here (to me at least!) is that I have a porting job. However traditional porting is between hi-level languages or between same language compilers. This port is a low level, in other words assembly language which represents a particular CPU's Instruction set / register set and resource (interrupts, exception and memory handling) to another CPU's assembly language. Since the source x86 and target ARM instruction sets are not to far apart in simple usage I guess I'm thinking this type of port could be *software* assisted. |
|||
![]() |
|
revolution 08 Jul 2012, 00:38
I would suggest a rewrite, *human* assisted. You will likely lose too much in terms of readability, performance and space usage if you go with a mechanical line-by-line translation.
|
|||
![]() |
|
cwpjr 08 Jul 2012, 03:21
Ok I know the code *real well* but if no one is into this *matrix* translation I will do the human version. I just thought that the accumulated knowledge of architectures could be useful, in even an analytical output that suggests their similarities and differences in common usage...
What I don't know real well is my target architecture, it's similarities and it's best or better, innovative uses. Technical reference manuals and Architecture documents could be better if they would address their applicability for various run-time environments, like JVM vs "C", vs interpreters, etc. |
|||
![]() |
|
Dex4u 08 Jul 2012, 12:53
Bit late now, but if you write it using fasm macros you could just translate the macro code.
See here: http://board.flatassembler.net/topic.php?t=14233 |
|||
![]() |
|
revolution 08 Jul 2012, 16:49
A quick little puzzle for those familiar with ARM code.
Translate line-by-line the following x86 code into equivalent ARM code. You can use any sort of register mapping you please, but make it consistent. e.g. eax == r0 (or whatever): Code: mov ecx,0x01020304 mov al,3 mov ah,7 add al,ah daa shld ecx,eax,cl rcr dh,6 jpe .x ;... .x: This is not as easy as it might first appear. Remember that you have to make each line do just as the x86 CPU would do without assuming anything about what the previous or following lines might do or need. Strictly line-by-line. Last edited by revolution on 09 Jul 2012, 00:33; edited 1 time in total |
|||
![]() |
|
cwpjr 08 Jul 2012, 21:06
Line by line translation is the hardest. I'd characterize it as Line Blind every line. Yet it seems simple, Mr. Revolution. Glad to see a funster in action!
My part in this instigation was to look for multiple scoped analysis if not useful translation, but I remember that assembler allows for the ultimate control and optimization. And soldering is like knitting to me; a soothing, productive craft! _________________ Developing ARM Electronic Hobby Bench Stuff! |
|||
![]() |
|
Tonymac32 08 Jul 2012, 21:29
Indeed, soldering can be therapeutic. I'm working on ARM for robotics and control applications. I miss some of the x86 data handling instructions, but absolutely love the flexibility of the ARM architecture and instruction set.
|
|||
![]() |
|
revolution 08 Jul 2012, 23:40
cwpjr wrote: Line by line translation is the hardest. I'd characterize it as Line Blind every line. Yet it seems simple, ... cwpjr wrote: ... Mr. Revolution. |
|||
![]() |
|
cwpjr 09 Jul 2012, 02:51
I regret my gender assumption but will say for myself that it was meant as a respectful nod to your hand in this wonderful forum.
As for now I am just wading through the ARM sites for manuals to find ISA info I can digest, so I'm not qualified yet. Yet I'm intrigued: I feel there is a Zen lesson in your simple exercise I will get to it. Education comes in many forms. BTW: My .sig is about a good friend who has called on me to do SW for his "waiting for first proto-boards" hw scheme. _________________ Developing ARM Electronic Hobby Bench Stuff! |
|||
![]() |
|
cwpjr 09 Jul 2012, 03:07
BCD and shift logic instructions first clue to wizardry, but jpe nails this as a test of binary register arithmetic and flag results knowledge methinks.
Is this analysis relevant to an accurate translation? |
|||
![]() |
|
revolution 09 Jul 2012, 03:35
cwpjr wrote: BCD and shift logic instructions first clue to wizardry, but jpe nails this as a test of binary register arithmetic and flag results knowledge methinks. It is mostly a way of demonstrating why a naive 1-to-1 translation fails to take advantage of the ARM CPU. And in fact would make the ARM CPU look really pathetic. But instead if one were to take the "proper" approach and examine what is being done and then code it in ARM natively the result is entirely different and much more elegant. Of course for this little puzzle such an examination is not allowed. |
|||
![]() |
|
cwpjr 09 Jul 2012, 03:56
by "entirely different and much more elegant." are you referring to what TonyMac32 referred to in loving the "flexibility" of the ARM instruction set and architecture?
I love simplicity and therefore RISC but my view hasn't prevailed. So I guess I'll have to embrace the flexibility. Reminds me of the generic processing architecture joke, which has two settings "Food and Word" 8>) |
|||
![]() |
|
cwpjr 09 Jul 2012, 04:02
BTW: as a newby to ARM this site seems useful:
http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.set.architecture/index.html All the comments in this thread are greatly appreciated, really. i am getting a jist that ARM is special and deserves attention to what it brings to assembly programming. Thinking i should change my id here to grasshopper.... Last edited by cwpjr on 09 Jul 2012, 04:08; edited 1 time in total |
|||
![]() |
|
Goto page 1, 2 Next < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.