开发者

conversion of assembly

can somebody please explain is it possible to convert this snippet of the code to assembly of pdp11?

movq    %rdi, -8(%rbp)
    movl    %esi, -12(%rbp)
    movl    %edx, -16(%rbp)
    movl    -16(%rbp), %eax
    cltq
    leaq    0(,%rax,4), %rdi
    movq    -8(%rbp), %r8
    movl    -12(%rbp), %eax
    cltq
    leaq    0(,%rax,4), %rcx
    movq    -8(%rbp), %rsi
    movl    -16(%rbp), %eax
    cltq
    leaq    0(,%rax,4), %rdx
    movq    -8(%rbp), %rax
    movl    (%rdx,%rax), %eax
    addl    (%rcx,%rsi), %eax
    movl    %eax, (%rdi,%r8)
    movl    -12(%rbp), %eax
    cltq
    leaq    0(,%rax,4), %rdi
    movq    -8(%rbp), %r8
    movl    -16(%rbp), %eax
    cltq
    leaq    0(,%rax,4), %rcx
    movq    -8(%rbp), %rsi
    movl    -12(%rbp), %eax
    cltq
    leaq    0(,%rax,4), %rdx
    movq    -8(%rbp), %rax
    movl    (%rdx,%rax), %edx
    movl    (%rcx,%rsi), %eax
    subl    %edx, %eax
    movl    %eax, (%rdi,%r8)
    movl    -16(%rbp), %eax
    cltq
    leaq    0(,%rax,4), %rdi
    movq    -8(%rbp), %r8
    movl    -16(%rbp), %eax
    cltq
    leaq    0(,%rax,4), %rcx
    movq    -8(%rbp), %rsi
    movl    -12(%rbp), %eax
开发者_JAVA技巧    cltq
    leaq    0(,%rax,4), %rdx
    movq    -8(%rbp), %rax
    movl    (%rdx,%rax), %edx
    movl    (%rcx,%rsi), %eax
    subl    %edx, %eax
    movl    %eax, (%rdi,%r8)
    leave
    ret

it is only small part of all code that I have... also I has C code of the same program, I found that using gcc -S flag, I can get assembly code but can I convert it to the code of pdp11?


If I get you right you just want to run a C program. If that's right, you can see here that PDP-11 is supported by GCC 4.3.

http://en.wikipedia.org/wiki/GNU_Compiler_Collection#Architectures

Get GCC 4.3 sources, learn how to build a cross-compiler and your problem is solved.

No need to translate amd64 assembly to PDP-11


Given that the PDP-11 is a 16-bit processor, you'd be much better off running your C through a compiler that will produce 16-bit code instead of the 64-bit code you've posted. It's probably easier to translate from C source code to assembly (by hand) than from 64-bit Intel assembly to PDP-11 assembly by hand.

You might also want to look at Dennis Ritchie's primeval C compilers page. As I recall, he has a link to somebody who's gotten one or two of these old compilers to compile and run in modern C. Its targets the PDP-11 (though the source it accepts is NOT modern C). You might also look at the work that's been done on targeting the PDP-11 with lcc. I believe there's a complete, working implementation. Though I have no idea whether anybody has tested it recently, somewhere in the pcc archives, there should probably still be an ancient PDP-11 code generator (that was heavily used at one time).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜