jon@eps2.UUCP (03/24/87)
Hello, I may soon have the pleasure of porting about 10MB of code from our current machine to a new machine. 99% of it is in C, and about 1% in 680x0 assembly language. One of the problems I see is that on the old machine ints were 16-bits and on the new machine ints are 32-bits. Well, that's fine in C but in assembly language functions there are a bunch of lines which take function arguments off the stack and put them into registers like: movem 20(a6), d5-d7 which will now have to say: movem.l 20(a6), d5-d7 Also, the stupid assembler syntax is different so it really has to be: moveml a6@(20), d5-57 Has anyone ever had to do something similar? Any advice to offer? I guess I'll use awk, or write a program using lex to convert the asm stuff, even though I'll have to look at all the asm files anyway. Does anyone have a program to do this laying around? Thanks in advance. Bitchin' Camaro! Jonathan Hue Bitchin' Camaro! DuPont Design Technologies - Via Visuals Donuts on your lawn! (c) The Dead Milkmen, 1985 {amdcad!cae780,sun!sunncal}!leadsv!eps2!jon
nerd@percival.UUCP (03/26/87)
In article <67@eps2.UUCP> jon@eps2.UUCP (Jonathan Hue) writes: > >Hello, > >I may soon have the pleasure of porting about 10MB of code from our current >machine to a new machine. 99% of it is in C, and about 1% in 680x0 assembly >language. One of the problems I see is that on the old machine ints were >16-bits and on the new machine ints are 32-bits. Well, that's fine in C Be carefull, I've been bitten by int sizes before (I suspect anyone who has done system work in C has been too) most things seem to work but every now and then you find little details... >but in assembly language functions there are a bunch of lines which take >function arguments off the stack and put them into registers like: > movem 20(a6), d5-d7 The first thing I did when I ran into this sort of conversion was to go through the whole code and remove any assumed operand sizes, i.e. replace all occurences of move with move.w and movem's with movem.w, same applies to cmp, add, sub, etc... I find it a lot easier to deal with explicit size declarations. >which will now have to say: > movem.l 20(a6), d5-d7 Unless this used to be a 'short int', in which case it will probably still be a 16 bit move. >Has anyone ever had to do something similar? Any advice to offer? >I guess I'll use awk, or write a program using lex to convert the >asm stuff, even though I'll have to look at all the asm files anyway. As you say, you will have to go through and look at all these files by hand anyway, I found it easier to do it all by hand. Take it in small steps, first remove any implicit size references (specify the .w always) Then go through and carefully label each routine as to what size it used to deal with and what size it will deal with in the new version. Then go through and make the changes, one routine at a time testing each one as you change it. The think you can write scripts to do is the conversion from Motorola syntax to UNIX syntax, I can't help you here as I've only had the oportunity to work with Motorola standard assemblers. The biggest problem I had was when I tried to convert routines that I did not FULLY understand, the most memorable being a routine which was keyed towards 16 bit int's and used the upper and lower half of registers to store different values, using the swap dn instruction to access the two parts. Need I say what happend when I swaped the halfs of my 32 bit ints? The rest is history, I learned from my mistakes. Wish you luck pal... -michael -- If my employer knew my opinions he would probably look for another engineer. Michael Galassi, Frye Electronics, Tigard, OR ..!{decvax,ucbvax,ihnp4,seismo}!tektronix!reed!percival!nerd