[comp.sys.ibm.pc] Microsoft Assembler

gemini@homxb.UUCP (Rick Richardson) (01/27/88)

We have a need to convert 8088 assembler code from an assembler
that operates like most UNIX assemblers to the Microsoft Assembler.
The conversion is not a one time deal.  We expect to convert
many times over the next few months.

We have a tool that does the conversion for us, except for the
following:

	The UNIX-style assembler is smart enough to use short or long
	jmp's, as well as to convert conditional jumps that would jump
	more than 128 bytes to the opposite jump around a long jump.

	We could find no way of doing this with the Microsoft 4.0 assembler.

The question is: is it possible to get this sort of feature from the
Microsoft 5.0 assembler?  is it possible to write a macro to do this?
or is it just plain not possible with the Microsoft tools?

johnl@ima.ISC.COM (John R. Levine) (01/28/88)

In article <1428@homxb.UUCP> gemini@homxb.UUCP (Rick Richardson) writes:
>We have a need to convert 8088 assembler code from an assembler
>that operates like most UNIX assemblers to the Microsoft Assembler.
>...
>The question is: is it possible to get [branch optimization] from the
>Microsoft 5.0 assembler?  is it possible to write a macro to do this?
>or is it just plain not possible with the Microsoft tools?

Generally speaking, you can't do it. MS assemblers have always done simple
branch optimization for backward unconditional branches, but not forward ones.
As a cruel joke, the 5.0 assembler puts out a warning "Jump within short
distance" when it notices a forward jump that it should have made short.
You're then supposed to stick a "short" keyword into the source code and
reassemble.

It gives you no help at all on conditional branches. I believe you could write
macros to optimize backward conditional branches, but you're out of luck again
for forward ones.  It will, of course, give you an error message if you try
to branch too far with a conditional jump, but it's up to you to fix the code.

Perhaps you could write a program which iteratively assembles a routine, then
looks at the error messages and adjusts the branches in the source code and
assembles it again until the error messages go away (up to some limit, there
are cases where the warning is unavoidable.)
-- 
John R. Levine, IECC, PO Box 349, Cambridge MA 02238-0349, +1 617 492 3869
{ ihnp4 | decvax | cbosgd | harvard | yale }!ima!johnl, Levine@YALE.something
Gary Hart for President -- Let's win one for the zipper.

hedrick@athos.rutgers.edu (Charles Hedrick) (02/02/88)

>Microsoft don't feel any pressure from competing products.  Maybe if
>Borland would come out with a Turbo assembler that *did* implement these
>algorithms, then Microsoft would get on the ball.

There is at least one competing assembler.  Mark Williams' C includes
its own assembler, loader, librarian, etc.  The whole package ("Let's
C") is less expensive than the Microsoft assembler.  This assembler is
based on Unix technology, and I believe does optimize jumps.  However
I have also had trouble getting it to compile some formats of call and
jump far.  (In general the Mark Williams technology is designed for
the small model.  If you pay $500, they'll give you a version of the
package where the C can handle the large model, but code compiled that
way has to be handled by the normal MSDOS loader.  It's not in the
format that their loader, etc., handles, and can't be debugged with
their debugger.)

brb@philabs.Philips.Com (Brian Bertan) (02/03/88)

In article <714@athos.rutgers.edu>, hedrick@athos.rutgers.edu (Charles Hedrick) writes:
> There is at least one competing assembler.  Mark Williams' C includes
> its own assembler, loader, librarian, etc.  The whole package ("Let's
> C") is less expensive than the Microsoft assembler.  This assembler is
> based on Unix technology, and I believe does optimize jumps.  However
> I have also had trouble getting it to compile some formats of call and
> jump far.  (In general the Mark Williams technology is designed for
> the small model.  If you pay $500, they'll give you a version of the
> package where the C can handle the large model, but code compiled that
> way has to be handled by the normal MSDOS loader.  It's not in the
> format that their loader, etc., handles, and can't be debugged with
> their debugger.)


Version 4.0 of the Mark Williams Compiler "Let's C", DOES include the
large model formats for MS-DOS object formats, and BOTH Large and Small
object formats can be debugged with CSD (also included).  The
proprietary object format is no longer supported.  Most of the features
of the $500.00 compiler are included with version 4.0 (at a fraction of
the cost), the exception being some of the minor utilities (e.g. grep,
diff).

There is also a neat new utility which allows object names to be edited from
other object files created for other compilers.

On the whole,  I am quite satisfied with this product (which cost less than
$50.00 :-) ).  I also find that they are quite good with phone support.  I
would however, like to see more library functions provided with this compiler.

Disclaimer:  These opinions are mine, and not my employers'.  I have no
connection with the Mark Williams company except as a satisfied customer.

Brian Bertan

Philips Labs
345 Scarborough Rd.
Briarcliff Manor, NY 10510
(914) 945-6309

philabs!brb

nelson@sun.soe.clarkson.edu (Russ Nelson) (01/27/99)

In article <1428@homxb.UUCP> gemini@homxb.UUCP (Rick Richardson) writes:
...
	   The UNIX-style assembler is smart enough to use short or long
	   jmp's, as well as to convert conditional jumps that would jump
	   more than 128 bytes to the opposite jump around a long jump.
The algorithms for doing this are well known, and easy to implement.  I
can only assume from the lack of them in MASM 5.0 that the programmers at
Microsoft don't feel any pressure from competing products.  Maybe if
Borland would come out with a Turbo assembler that *did* implement these
algorithms, then Microsoft would get on the ball.

	   We could find no way of doing this with the Microsoft 4.0 assembler.

   The question is: is it possible to get this sort of feature from the
   Microsoft 5.0 assembler?  is it possible to write a macro to do this?
   or is it just plain not possible with the Microsoft tools?

You can hack it up in a gross fashion but only for reverse jumps.
Just measure the distance between $ and the target, and issue the
appropriate code.  Unfortunately, there is no way to detect the usage
of this macro (and disable it) with a forward jump, and you will get
undefined symbol errors on pass 1.
-russ