delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/10/02/07:15:27

From: Gary AT bbs DOT st DOT net DOT au (Gary)
Newsgroups: comp.os.msdos.djgpp
Subject: Newbie,Intel-AT&T conv
Date: 02 Oct 97 20:39:27
Organization: Soft-Tech +61-7-3869-2666
Lines: 107
Message-ID: <df2_9710022049@softtech.st.net.au>
References: <607m3p$805$3 AT vnetnews DOT value DOT net>
NNTP-Posting-Host: sun.st.net.au
Cache-Post-Path: sun.brisnet.org.au!unknown AT softtech DOT brisnet DOT org DOT au
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Hello all,
	  I'm a beginner here and I need some,lots of help in converting Intel
 to the At&T syntax,the code that i'm trying to convert was written for the
 Borlands4.0 Tasm asembler,I have used both Nasm and the utility prg Ta2as,
 while the latter does not do a complete correct conversion i am able to edit
 the code without too much difficulty,however,some of my editing i'm not sure
 of,even though i get no errors assembling the file,I'm not sure if it's
 correct,I have run into a few problems that I cannot fathom out and I wish to
 post them here and see if someone is kind enough to help me with these querys.
 I must metion here that I'm new to assembly language and do not have all that
 much knowledge of it as yet,and all the querys here relate to converting from
 Intel to AT&T syntax.I have over a period of the last few months followed this
 echo and gleaned a few clues,but most importantly,been able to get doc's and
 such mentioned on this echo to help me and I have read the faq on this,but
 this dos'nt mean I understand it.
 Here goes...

 Query 1: I have in a include file a expression..
          Color equ ebp-4  converts to  .equ Color, ebp-4
 I get no errors with this,however it does not seem right as the registers I
 believe need to be prefixed by the % character,I have tried prefixing it with
 the % character,and a error occurs and if I do -4(%ebp)still a error.How do I
 go about converting this.

 Query 2: In the file that includes the include file there is a expression..
	 .data			  .data
	 COLOR dw ?  converts to  COLOR: .short ?
	 SX    dd ?	"      "  SX:    .int   ?
 I get a error if I leave in the "?" character,is this conversion correct,also
 I believe that "Color" and "COLOR" are different from each other,they're both
 referenced through the program as follows.. but not in the same file
	 mov [word ptr COLOR],ax  to  movw %ax,COLOR
	 mov [word ptr Color],ax  to  movw %ax,Color
 To the way i figure it the variable" Color" has something to do with
 referencing the base pointer register,how do i go about the right conversion
 for this to work.Am I correct in assuming that "COLOR" & "Color" are seperate
 variables to each other.What confuse's me here is the fact that "COLOR" has
 the directive .short and used in the prg as "word ptr",are these two
 expressions the same,ie,.short and word.

 Query 3: This relates to indirect memory referencing,in the faq in one of the
 examples given it states..
	   *Intel:*  [foo]    *AT&T:* foo(,1)
 How does one know that one is indirectly referencing a memory location,I
 presume "foo" is a variable maybe in the form as the "Color" variable given
 above,ok that makes sense to me,but if any variable is enclosed by [ ],does
 this mean it has to follow the above criteria.In Brennans guide to inline
 assembly,it states that you must suffix the instruction with b,w,or l to
 specify the width of the destination register,then states the equivalent
 forms for Intel are byte ptr,word ptr,dword ptr but that is for only when you
 are referencing memory.

 Query 4:
 How does one tell which is the BASE or INDEX if one of them is missing, are
 there registers that can only be used for BASE and only for INDEX,or are they
 inter_changeable and can be put into anyone of those two,ie,BASE,INDEX,also
 can SCALE be a predetermined value and put into a variable.

 Query 5:Does it matter in what order the base,index,scale are put,like
 Intel's    [ebx  +   4   *  eax   + _array]
             base + scale * index  +  disp
 now GAS dos'nt choke if I do this...
            _array(%ebx,4,eax)
 yet would this be legal.
 I have noticed that GAS does not pick up many obvious errors,notably that when
 this code was converted,it would not convert edx and would append the "$" on
 to the front of it and never picked it up,yet it assembled with these
mistakes.

 Query 6:I have come across two words,"large" and "short" in Borlands code,the
 word "short"is used in the Jxx and jmp instruction's such as..
       jge short inbetween
       .
       inbetween:
 The word "large" is used as per..
       mov [dword ptr _x_xNext],large 64
       cmp edx,large 4096
 I deleted the "short" from the Jxx and jmp instructions and in the case of the
 others I did as follows "movl $64,_x_xNext" and "cmpl $4096,%edx" have I done
 the correct conversion here for "short & large"if not could you advise as to
 what it should be.

 Query 7: I have an instruction "rep  stosd" doing what I read in the DJGPP
 QuickAsm guide by putting the stosd instruction on the next line I get a error
 as such "no such 386 instruction" now if I use "stosl" it assembles without a
 error,I have a prg that gives me the instruction set yet it only mentions the
 suffixes "b,w,d" is this,"stosl" wrong,if so,how do I go about it correctly.

 Query 8: I have some code as per...
 call [dword ptr ebp+saFnc] where "saFnc" has been defined as a member of a
 struct as per  ".equ saFnc, 17" and also in a  "C" header file as a member in
 a struct declaration as...       void (*Fnc)(void);
 and another call as per...  call [dword ptr _FloorCeilRtn] now this variable
 was mentioned at the to of the file as...  extrn _FloorCeilRtn:dword    which
 was stripped out in the conversion process,it is also mentioned in a .c file
 as...   void (*FloorCeilRtn)(void); .
 They have been converted as follows "calll saFnc(%ebp)" and "calll
 _FloorCeilRtn" is this a valid instruction,I get no errors on this,this one
 has me more than puzzled as I can put the suffixes "b & w"there with no errors
 yet have not seen in any readings mention of these,I have seen mention of
 lcall but I think that applys to far calls.
 Thanking you all in anticipation of your help,I apologise for this lengthy cry
 of help and if I have strayed from the subject of this newsgroup please tell
 me so.
 Gary LLoyd.
 <glloyd AT bbs DOT st DOT net DOT au>

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019