Back to home page

DOS ain't dead

Forum index page

Log in | Register

Back to the forum
Board view  Mix view

MASM as standard, fixmem example (Announce)

posted by Rugxulo Homepage, Usono, 07.05.2025, 03:23

> I think it should be pretty obvious that number of passes has _almost
> nothing_ to do with quality (however one would define "quality").

A86 is one-pass and much faster than MASM or TASM. Isn't A386 your favorite assembler?

> When assembling/compiling, the file(s) are read from top to bottom and sometimes
> something at the top of the file will refer to something later in the file,
> or even in a different file, and the assembler/compiler will not know what
> to do with it. The most obvious thing it may not know is the size (Byte,
> Word, DWord, QWord, Array, Structure, etc.) but there could be other things
> it may need to "guess" on the first pass. If it guesses wrong, things can
> get ugly (or at least non-optimal). The usual way around these things is
> to make "unnecessary" declarations (usually about size) for anything that
> is a forward reference, which makes the code more cumbersome to write since
> it includes a bunch of unneeded/duplicate syntax.

I believe the traditional way around that problem is to "JMP Start" and then define your data so that the assembler knows where it is.

> In addition to sizes of data items, there are also issues related to sizes
> of JMPs (both conditional and non-conditional) and whether they are short
> or near

People always got choked up about short conditional jumps, but it's not THAT bad. Besides, MASM "ljmp", TASM "jumps", and even NASM "-O3" with "cpu 8086" can do a workaround for such out-of-range jumps. (The main worry is not to have a 386+ near jump in 8086 code. Some assemblers do not warn about that.)

In reality, saving a few bytes for jumps hardly makes a difference, so it's not worth worrying about (although only a few assemblers lack that optimization). A86 actually can only handle backwards conditional jumps automatically. Again, it's in the interest of speed (which was more obvious in pre-Pentium days).

> I really don't see how a single-pass assembler/compiler could work as well
> as a multi-pass, at least when it comes to producing the most efficient
> (smallest size) output without requiring the code writer to jump through a
> bunch of "unnecessary" hoops.

I had several strategies, just out of curiosity and completeness, to 100% match optimized outputs:

1). Use Sed or AWK to automate fixing from the listing .LST file to optimize. This still takes a few extra "passes", but it works. (I was sneaky and able to bundle the .sed or .awk inside the .BAT itself. It's not as complex as it sounds.) For example, A86 4.05 (forward short jumps) and NASM 0.97 (short jumps, explicit byte operands).

2). Some assemblers allow symbolic equates, so you can (in one "pass") read the entire .ASM and find all data declarations and put then in an .INC include file, e.g. "s_myWordVar equ word" so that "s_myWordVar[myWordVar]" works. For example, OpenWatcom WASM or A86 or NASM.

3). If that doesn't work, you can always do a second "pass", with Sed or whatever else, to explicitly change all instances of "s_myWordVar" to "word".

 

Complete thread:

Back to the forum
Board view  Mix view
22552 Postings in 2097 Threads, 401 registered users, 40 users online (0 registered, 40 guests)
DOS ain't dead | Admin contact
RSS Feed
powered by my little forum