d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Looking To Translate This C++ Code > Longshot, Traslating To 68k Asm
Add Reply New Topic New Poll
Member
Posts: 3,386
Joined: Oct 17 2008
Gold: 0.00
Dec 4 2012 09:31pm
https://gist.github.com/a3b5f805bf8e86f36d8f

that's the code i need to translate. op1 and 2 represent word length signed magnitude numbers.

i really have no idea where to start, any help would be appreciated! (and likely paid for!)

Member
Posts: 32,925
Joined: Jul 23 2006
Gold: 3,804.50
Dec 4 2012 09:46pm
a quick google search on c to assembly has several nice looking tutorials for this. that should be a good place to start.

https://www.google.com/search?q=c+to+68k+Asm
Member
Posts: 13,425
Joined: Sep 29 2007
Gold: 0.00
Warn: 20%
Dec 5 2012 10:24am
thats not hard to translate at all at least in x86 at&t system v syntax. i suggest throwing that function into a .c file and compile it with gcc with the -g flag on a linux machine followed by a objdump -d. that way you can see the system v syntax and you can kind of follow along.

all its doing is passing 2 memory addresses (not the pointer to the actual variable) to the function and then adding +8 to esp to store 2 local variables. everything after that i just a bunch of cmp statements and jumps to labels. its pretty straight forward.

the first couple of lines should look something like this in system v.

Code
.function
do_add:
addl 8, %esp
xorl 4(%esp), 4(%esp)
xorl 8(%esp), 8(%esp)   #create 2 local variables in our function and zero them out (set them as false (0))

first_if:
  cmpl -4(%esp), 4(%esp)
  jne second_if
  movl $1, 4(%esp) #set sign1 to true
  and -4(esp), 4(%esp)

second_if:
xxxxxxxx


something like that. not totally correct but you should get the jist of it.

also i suggest using #define statements to define names for your variables. will help aid you in creating asm code that looks more like the C code.

aka

Code
#define sign1 -4(%esp)


now you can use sign1 anywhere you would want to use that variable.

This post was edited by AbDuCt on Dec 5 2012 10:33am
Member
Posts: 4,605
Joined: Sep 15 2011
Gold: 9,464.00
Dec 5 2012 01:20pm
can't you just get gcc to cross compile that shit
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll