66 Commits

Author SHA1 Message Date
Olaf Seibert
8a2ba3adf0 Print flag names. 2015-05-27 01:37:16 +02:00
Olaf Seibert
bbaf56206e Allow extraction of Object LiBraries too.
Eliminate terminating 0 byte in macro buffers.
2015-05-24 17:37:08 +02:00
Olaf Seibert
da068e07c8 Make sure the -v argument show that this is not the same as previous versions. 2015-05-22 16:40:37 +02:00
Olaf Seibert
435cdb0b7f Separate out the string parsing for .include/.library file names and macro arguments.
They behave observably different from generic string parsing and trying
to account for them generically just gets in the way.
.rept is treated the same as a macro.
2015-05-22 16:36:16 +02:00
Olaf Seibert
536d1856f0 .IF B,< > is supposed to be TRUE
because spaces are blank.
Seen in Kermit, although perhaps the author didn't mean that (MESSAGE < >).
2015-05-22 01:32:45 +02:00
Olaf Seibert
60af942129 .RESTORE restores DOT too
this is how it should be according to page 6-42 of the manual.
Kermit does this ugly thing to backpatch some .word value:

     435 000070                         	dial$time	35.
       1 000070                         	modval	35.,dial.time
       1                                	.save
       2 000070                         	.psect	modinf
       3        000006                  	. = $$current + dial.time
       4 000006 000043                  	.word	35.
       5 000070                         	.restore
     436 000070                         	wake$string	<^E^M>

where the current program section already is modinf. So the .save stores
DOT, it's changed to a lower value (6) to backpatch, and .restore sets DOT
back to 70.
2015-05-22 00:13:54 +02:00
Olaf Seibert
9640d19a1f Default module name is ".MAIN.". 2015-05-21 23:32:14 +02:00
Olaf Seibert
8433503792 Make sure that undefined global symbols don't get reduced to 0 when negated
Test case:

        ; test complex relocations

        ; .globl  IE.ITS,IE.MON ; implicit
        mov     #-IE.ITS, space

space:  .word   IE.ITS    ; the only simple relocation
        .word   -IE.ITS   ; all others are complex relocations
        .word   ^C<IE.ITS>
        .word   IE.ITS + IE.MON
        .word   IE.ITS - IE.MON
        .word   IE.ITS * IE.MON
        .word   IE.ITS / IE.MON
        .word   IE.ITS & IE.MON
        .word   IE.ITS ! IE.MON
2015-05-21 23:21:19 +02:00
Olaf Seibert
b8a15a89b5 Implement .ENABL and .DSABL LC. 2015-05-21 22:24:31 +02:00
Olaf Seibert
168340c54c A bit more tweaking of output/listing. 2015-05-21 00:57:52 +02:00
Olaf Seibert
6c992f6406 Fix some warnings from clang. 2015-05-20 22:54:26 +02:00
Olaf Seibert
59711f17f2 Make trailing commas work in .BYTE and .WORD
16 000000 000123                  state:  .word   123    ; 1 word
      17 000002 000000                          .word          ; 1 word
      18 000004 000001  000000                  .word   1,     ; 2 words
      19 000010 000000  000002                  .word   ,2     ; 2 words
      20 000014 000000  000000                  .word   ,      ; 2 words
      21 000020 000000  000000  000000          .word   ,,     ; 3 words
      22 000026 000001  000000  000000          .word   1,,    ; 3 words
      23 000034 000000  000000  000003          .word   ,,3    ; 3 words
      24 000042 000001  000000  000003          .word   1,,3   ; 3 words
      25 000050 000001  000002  000003          .word   1,2,3  ; 3 words
2015-05-19 22:57:45 +02:00
Olaf Seibert
dbc3a55666 Store section size after .EVEN and .ODD
just in case it's the last thing in the section.
2015-05-19 22:42:55 +02:00
Olaf Seibert
b45cf742f7 A trailing comma in a macro call is an empty argument
which should also be counted for the purposes of .NARG.
2015-05-19 22:10:44 +02:00
Olaf Seibert
2488e02aae A few more small listing tweaks. 2015-05-19 22:09:53 +02:00
Olaf Seibert
859e8dbb1f List macro calls with the location of DOT
Like MACRO V05.05.
2015-05-19 21:17:15 +02:00
Olaf Seibert
2e06f50286 List values in the data column, not the location column. 2015-05-19 21:15:57 +02:00
Olaf Seibert
06a780cb94 Suppress spurious error message in RSX format version. 2015-05-19 21:15:24 +02:00
Olaf Seibert
6a6a9ee1eb Remove two optimizations that RSX Macro-11 apparently does not perform.
This is useful for comparing created files with the original assembler.
They can be put back later.
2015-05-19 01:00:05 +02:00
Olaf Seibert
12fdea5b21 Adapt the generating and dumping of object files to what is observed
in RSX-11M+ files. Use conditional compilation so the RT-11 version can
be restored.
2015-05-19 00:56:40 +02:00
Olaf Seibert
f34996452b Mark PSECT relocation also with a ' in the listing. 2015-05-19 00:50:17 +02:00
Olaf Seibert
4fabe28497 Make .narg work
it should count only non-keyword (actual) arguments.
2015-05-14 14:33:54 +02:00
Olaf Seibert
833d9186cc Make empty expressions in .byte and .word work
such as
        .byte   ,0
2015-05-14 14:32:46 +02:00
Olaf Seibert
e703403017 Bring .ENDM label in correspondence with the manual. 2015-05-12 22:59:21 +02:00
Olaf Seibert
1e9e8023b3 Fix my_searchenv(). 2015-05-12 22:42:39 +02:00
Olaf Seibert
74c2399c7d Remove some remaining logging. 2015-05-12 22:42:05 +02:00
Olaf Seibert
7e45c8a656 Change .ENDM name in self-redefining macros to be more forgiving
The original intent of the code, when faced with something like

	.MACRO	A
	.MACRO	B
	.ENDM	A

is to terminate the outer macro definition immediately.
However some macros redefine themselves, and that broke.
For now, detect self-redefinition and disable the early
end if there is one.

Since this does not match what's described on page 7-3,
this will change if it doesn't break my test cases.
2015-05-12 21:55:18 +02:00
Olaf Seibert
3fbb3cc6ad Add support for RSX-11M+ 4.6 MacroLiBrary files.
This version still contains lots of commented-out logging statements.
2015-05-12 21:45:23 +02:00
Olaf Seibert
a8b5272bb8 Nested delimited strings had an infinite loop.
The code for nested and unnested strings was mixed, thereby being too
simple for the nested case. I separated them, which is simpler than
the fixed combined version.
Detected by the macro call
        ..EMIT <$FAC=^D<fb$rea>>
2015-05-12 21:40:13 +02:00
Olaf Seibert
749b0a5d73 Add the .LIBRARY /string/ directive.
If no -p options or MCALL environment variable are given, pretend the
search path is the current directory ".".
2015-05-12 21:32:01 +02:00
Olaf Seibert
f75f5e1242 Change delimiters of local symbol blocks to be more like page 3-10 of the manual.
Also, to make Kermit sources work, only increase the local symbol block
counter if there actually was a local symbol used in the block.
This way, conditional inclusions (which include source text only in the
first pass) will have less potential for de-synchronisation between the
passes. After all, if the generated internal local symbol names do
not match, phase errors will result (showing themselves as strange label
redefinition problems).
2015-05-10 17:51:32 +02:00
Olaf Seibert
2bc55f39f3 Add debug flag to command line interpretation. 2015-05-10 17:39:38 +02:00
Olaf Seibert
a6ee20cdc1 Don't truncate the internal form of local symbols
Local symbols like 32768$ (and such long ones can be generated
automatically by macros) are suffixed with the "local symbol block number"
to make different labels in different local symbol blocks:
32768$12345.

However, this becomes longer than the regular symbol length (6).
So, to avoid changing these labels, they are not truncated at this length.

The listing code is updated to deal with the longest symbol name lengt
it encounters in the symbol table.
2015-05-10 17:36:58 +02:00
Olaf Seibert
fcc85aa5f5 Fix .asciz <expr>... where an overzealous parsing wants to parse too much of the remaining text
In particular, the example was
	.asciz <cr><lf>/<SOH>/
where it tried to make a division betweem <lf> and the delimited
string /<SOH>/.
2015-05-10 17:32:44 +02:00
Olaf Seibert
2c091595e9 Add option -yl1 to list pass 1 as well
Normally listing is suppressed during the first pass, because there are
many unresolved symbols, which will be better in pass 2.
Errors are also suppressed because most of them are spurious.

With the -yl1 option, listing during pass 1 is not suppressed.
If you give the option twice, you also get the error messages.
2015-05-10 01:12:36 +02:00
Olaf Seibert
21b5f2269f Spaces. Spelling. 2015-05-10 00:32:14 +02:00
Olaf Seibert
e55979b30d Add a symbol and section table dump at the end of the listing. 2015-05-10 00:04:41 +02:00
Olaf Seibert
32b8059cf8 Put code where it belongs. 2015-05-09 23:54:54 +02:00
Olaf Seibert
787625ab47 Somewhat more interesting error messages. 2015-05-09 23:52:40 +02:00
Olaf Seibert
a8b6c026db Correct comment. 2015-05-09 16:07:58 +02:00
Olaf Seibert
60511a5f81 Improve comment. 2015-05-09 16:04:50 +02:00
Olaf Seibert
e477f7bd80 The manual differs from the implementation...
at least the one of RSX M+ 4.6.
Inconsistent flags given to .PSECT seem to be simply combined, with
nothing special done after pass 1 when re-reading for 2. The situation
at the end of pass 2 wins.
2015-05-09 15:45:00 +02:00
Olaf Seibert
20f25b9dd9 Fix bug with .SAVE and .RESTORE
.SAVE didn't check for  stack overflow.
.RESTORE moved the stack pointer in the wrong direction.
2015-05-09 12:51:31 +02:00
Olaf Seibert
b4d3c9a094 Fix undefined macros in second pass when conditional inclusion is used...
Given the following conditional inclusion, as seen in RSX Kermit-11
sources:

        .if ndf, K11INC
        .ift
        .include /IN:K11MAC.MAC/
        .include /IN:K11DEF.MAC/
        .endc

macros defined in K11MAC.MAC are unknown when used later on.

The assembler keeps a running count of the line number (stmtno) and
stores it in the macro definition. In the second pass, it tries to avoid
cases of use-before-defined, because it doesn't really forget the
macros.

However, in this case, the second pass has fewer lines, because there
was some conditional inclusion... so when the macro is used in the
second pass, its running line number (including the skipped inclusions)
is lower than the line number where the macro was defined...

The line number check would also interfere when the /PASS:1 and /PASS:2
input file modifiers would be implemented.

It seems to me that in most normal cases, a use-before-defined is
already detected in the first pass, so the check is not really needed.

Therefore I have simply removed it.
2015-05-08 23:19:13 +02:00
Olaf Seibert
184fae4b67 Generalise argument string parsing,
not just for .include. Manual shows various delimiters.
2015-05-08 12:35:57 +02:00
Olaf Seibert
f01ee85a8f Allow whitespace before comma in two-general-operand instructions.
(it was allowed already in other cases such as SOB, JSR, ASH, ...).
2015-05-08 10:03:04 +02:00
Olaf Seibert
422285bb60 If a section is declared a second time, and flags...
are given, then they must be identical to the  first time.
See page 6-38 of AA-KX10A-TC_PDP-11_MACRO-11_Reference_Manual_May88.pdf .
2015-05-08 02:09:03 +02:00
Olaf Seibert
4849f7f039 Reset dot in all sections. write_globals() only does it...
if there is an object file.
2015-05-08 02:03:23 +02:00
Olaf Seibert
3b6637f82d Also add NOSAV flag to PSECT. 2015-05-08 00:41:18 +02:00
Olaf Seibert
6acf2971bd Add the "COM" flag to PSECT/CSECT: opposite of OVR. 2015-05-08 00:28:25 +02:00