• Please review our updated Terms and Rules here

MACRO 11 Cross assembler

Activmaker

Experienced Member
Joined
Apr 3, 2018
Messages
66
Location
Paris, France
Hi,

I downloaded Macro11 cross : here
and make a very simple program

Code:
.TITLE TEST.MAC VERSION 1

FIRST: MOV R1,1000
	  INC R1
	  MOV R2,1000
	  ADD R2,R1
      HALT

 .END

Using Macro11.exe I can obtain a test.obj (106 bytes). Then, using Pdp11GUI , I uploaded it into memory.
Using dissambler tool, I checked the memory , but I didn't see something similar to the source code. For more info , Macro11 didn't get out any errors , I can hav a listing of this very small program.

Where is my mistake ?.

My objective is to build some programs without any OS. (Tools, specific diag etc)...Is it possible with Macro11 cross ?
 
Having never used this cross-assembler this is just a guess. Normally assembly is "compiled" or assembled into an obj files.
This is then often (at least from when I used assembler long ago) then linked into an executable. Maybe you need to do the
linking? This allows multiple obj files or pieces to be put into one executable.
 
Hi,

I downloaded Macro11 cross : here
and make a very simple program

Code:
.TITLE TEST.MAC VERSION 1

FIRST: MOV R1,1000
	  INC R1
	  MOV R2,1000
	  ADD R2,R1
      HALT

 .END

Using Macro11.exe I can obtain a test.obj (106 bytes). Then, using Pdp11GUI , I uploaded it into memory.
Using dissambler tool, I checked the memory , but I didn't see something similar to the source code. For more info , Macro11 didn't get out any errors , I can hav a listing of this very small program.

Where is my mistake ?.

My objective is to build some programs without any OS. (Tools, specific diag etc)...Is it possible with Macro11 cross ?

That produces a relocatable code segment with no fixed load address. PDP11GUI might load that at 0. Maybe not.

I would add:
Code:
        .asect
        .=200

between the TITLE line and the label FIRST. Your code will then be put in an absolute section and will load at address 200.

Don
 
Addendum (since we still can't go back and edit previous posts):

Using the .ASECT directive is how most/all of the DEC standalone diagnostics (ie, no OS) were built. If you look at the listings you will see this.
 
More FYI. I wrote my own 'linker' when I used MACRO11 to assemble PDP-11 boot prom sources to .hex files.

Eg, here: https://www.ak6dn.com/PDP-11/ DIAGNOSTICS for my test programs, M9312 for DEC boot proms.

Available here: https://github.com/AK6DN/obj2bin It is a perl program.

Here is the Makefile I use to assemble my PDP-11 diagnostic programs (.mac macro11 source files) to .obj files and then multiple .obj files to .bin files for loading.

Code:
# makefile for pdp11 bin code

.PRECIOUS: %.obj

MACOPT ?= -d md -d me -e bex -yus
OBJOPT ?= --debug --verbose
DMPOPT ?= no
BEXOPT ?= yes

%.obj : %.mac
	@echo
	macro11 $< $(MACOPT) -l $*.lst -o $@
	@-perl -i -n -e 'print unless m/^\s*\d+\s+.nlist\s*$$/i;' $*.lst
ifeq ($(BEXOPT),no)
	@-perl -i -n -e 'print unless m/^\s+([0-7]{6})\s+(([0-7]{3}|[0-7]{6})\s+)+$$/i;' $*.lst
endif
	@-rm -f $*.lst.bak
ifeq ($(DMPOPT),yes)
	dumpobj $@ > $*.dmp
endif

%.bin : %.obj
	obj2bin.pl $(OBJOPT) --binary --log $(@:.bin=.log) --out $@ $+

# the end
 
I use macro11 and Don’s Perl script and they seem to work fine.

I will post my shell script for you later on.

I have made a minor tweak to Don’s Perl script to output a .bin file for programming large ROMs for embedded systems.

Dave
 
Thanks a lot guys. Using Don's script, it is working. I am not a specialist in perl, but it seems that the obj store Opcode in records with other informations. The script extract opcodes and absolute address to build the bin file.
@dave,I should also learn a lot of thing with your script, thanks
 
Thanks a lot guys. Using Don's script, it is working. I am not a specialist in perl, but it seems that the obj store Opcode in records with other informations. The script extract opcodes and absolute address to build the bin file.
@dave,I should also learn a lot of thing with your script, thanks

The DEC object file format .obj is based on relocation records that can be very simple 'place these bytes at these addresses' to medium simple 'place these bytes at the next free address' to very complex relocation instructions on memory words 'insert this computed symbol value at word x'.

Macro11 won't be generating most of these (usually if you use .ASECT there are just a bunch of data records to place at absolute addresses).

I based my coding of the program on the info in 'AA-PD6PA-TC_RT-11_Volume_and_File_Formats_Manual_Aug91.pdf' for RT11v5.6 available on bitsavers.
 
So, this is my shell script:

Code:
./macro11 -l dctem.lst -o dctem.obj dctem.mac >dctem.log.txt

# --verbose --debug --ascii --binary
#
./obj2hex.pl --verbose --ascii  --outfile=dctem.txt --objfile=dctem.obj
./obj2hex.pl --verbose --binary --outfile=dctem.bin --objfile=dctem.obj
./obj2hex.pl --verbose --hex    --outfile=dctem.hex --objfile=dctem.obj

# ./hex2bin dctem.hex

# hexdump -v -o dctem.bin >>dctem.log.txt

# hexdump -Cv dctem.bin >>dctem.log.txt

dctem.mac is my source file (obviously).

dctem.obj is the object file produced by the assembler.

dctem.txt and dctem.bin are two files produced by Don's PERL script in response to the --ascii and --binary switches respectively.

dctem.hex is the file produced by my modification to Don's PERL script in response to the --hex switch. This switch permits an output file to be produced that can be burnt into EPROMS for (say) a KXT11.

The commented out hex2bin program just takes my dctem.hex file and produces dctem.bin.

The commented out hexdump lines are just for debugging purposes.

-----

This is the 'top' and 'tail' of my rather large MACRO11 assembler source file:

Code:
; Modified by Dave Roberts for 16K RAM + 16K ROM (e.g. KXT11-AA M8063).

	.ASECT

TAB	=	011
LF	=	012
CR	=	015
SPACE	= 	040

etc...

.	=	40000		; DER

; DER New entry points for KXT11-AA

	JMP	START		; start
	JMP	RSTART		; restart / halt
	JMP	L37556		; re-enter monitor

etc...

The .ASECT tells the assembler that this is an ABSOLUTE block of code.

The 'LF = 012' defines a symbol (in this case the symbol for a Line Feed character).

The '. = 40000' defines the origin for the assembler to assemble all subsequent instructions and data at. This is where my EPROM is addressed to start at and where my PDP11 (actually a T11) starts execution from on a power up or reset condition.

The remaining 'stuff' is PDP11 instructions and data.

I have been lazy and not included an END statement...

I have built the MACRO11 application from sources to run on my iMac under OSX.

There is a utility called LINK11 (if I remember correctly) that I never had much success with. I think I did get it to work eventually, but it produced .SAV files that required further processing to do what I wanted. I gave up when Don sent me his PERL script that worked. I just had to persuade it to produce a HEX file that I could burn into EPROMs. Don's original produced small BOOTSTRAP ROMs with the --binary switch.

Hope this is of some help to you?

Don, not sure whether you want to include my modification in your script file? I can forward my modification to you if you want.

Dave
 
Last edited:
So, this is my shell script:

Code:
./macro11 -l dctem.lst -o dctem.obj dctem.mac >dctem.log.txt

# --verbose --debug --ascii --binary
#
./obj2hex.pl --verbose --ascii  --outfile=dctem.txt --objfile=dctem.obj
./obj2hex.pl --verbose --binary --outfile=dctem.bin --objfile=dctem.obj
./obj2hex.pl --verbose --hex    --outfile=dctem.hex --objfile=dctem.obj

# ./hex2bin dctem.hex

# hexdump -v -o dctem.bin >>dctem.log.txt

# hexdump -Cv dctem.bin >>dctem.log.txt

dctem.mac is my source file (obviously).

dctem.obj is the object file produced by the assembler.

dctem.txt and dctem.bin are two files produced by Don's PERL script in response to the --ascii and --binary switches respectively.

dctem.hex is the file produced by my modification to Don's PERL script in response to the --hex switch. This switch permits an output file to be produced that can be burnt into EPROMS for (say) a KXT11.

The commented out hex2bin program just takes my dctem.hex file and produces dctem.bin.

The commented out hexdump lines are just for debugging purposes.

-----

This is the 'top' and 'tail' of my rather large MACRO11 assembler source file:

Code:
; Modified by Dave Roberts for 16K RAM + 16K ROM (e.g. KXT11-AA M8063).

	.ASECT

TAB	=	011
LF	=	012
CR	=	015
SPACE	= 	040

etc...

.	=	40000		; DER

; DER New entry points for KXT11-AA

	JMP	START		; start
	JMP	RSTART		; restart / halt
	JMP	L37556		; re-enter monitor

etc...

The .ASECT tells the assembler that this is an ABSOLUTE block of code.

The 'LF = 012' defines a symbol (in this case the symbol for a Line Feed character).

The '. = 40000' defines the origin for the assembler to assemble all subsequent instructions and data at. This is where my EPROM is addressed to start at and where my PDP11 (actually a T11) starts execution from on a power up or reset condition.

The remaining 'stuff' is PDP11 instructions and data.

I have been lazy and not included an END statement...

I have built the MACRO11 application from sources to run on my iMac under OSX.

There is a utility called LINK11 (if I remember correctly) that I never had much success with. I think I did get it to work eventually, but it produced .SAV files that required further processing to do what I wanted. I gave up when Don sent me his PERL script that worked. I just had to persuade it to produce a HEX file that I could burn into EPROMs. Don's original produced small BOOTSTRAP ROMs with the --binary switch.

Hope this is of some help to you?

Don, not sure whether you want to include my modification in your script file? I can forward my modification to you if you want.

Dave

Sure send them along and I can include them in the git repo for obj2bin.pl
 
Hi,

I was busy these last days, I couldn't answer before.
So,I understood there is many file formats and many script ojb2hex and obj2bin. I suppose that obj2bin is a shortcut and avoid to make the step .hex using obj2toHex. I am correct ?

Now trying to compile this sample

Code:
.TITLE RESETMEM.MAC VERSION 1

.ASECT
.=200
START:                 MOV #157776,R1
LOOP1:                MOV #0,(R1)
                           DEC R1
                           DEC R1
                           CMP R1,#500
                           BNE LOOP1
                           HALT
 .END
I have some trouble with the the makefile. The first build is ok . If I changed something in the .mac nothing is rebuild. I ckecked that I didn't break any tabulation in makefile.
Maybe I don't use it correctly, I am using 'make resetmem.bin'. If I use a script like Dave, it is ok, but I don't have the benefice of a makefile.
I used makefile a very long time ago..I don't remember exactly how it works :)
 
No problem - we all have ‘other stuff’ to do at times!

Do you want to post your makefile and we will have a look?

This is why I just go for a simple script rather than a makefile!

You mention obj2bin and obj2hex utilities. Don’t confuse those utilities with the object file produced by the macro11 assembler and Don’s Perl script. They are completely different things.

Dave
 
Here's the contents of my Makefile:

Code:
# makefile for pdp11 bin code

.PRECIOUS: %.obj

MACOPT ?= -d md -d me -e bex -yus
OBJOPT ?= --debug --verbose

%.obj : %.mac
	macro11 $< $(MACOPT) -l $*.lst -o $@

%.bin : %.obj
	obj2bin.pl $(OBJOPT) --binary --log $(@:.bin=.log) --out $@ $+

# all the files to be made
BIN=memx.bin echo1.bin echo2.bin dl11.bin

all : $(BIN)

# the end

Where 'make' just remakes out of date files (short for 'make all', since all is the first target listed),
or 'make foo.bin' should remake just foo.mac to foo.bin, if needed,
or 'make all' to do all files that need update.
or 'make --always all' to force all files to rebuild.

obj2bin.pl is my perl program that acts as a PDP-11 linker, combining one (or more) .obj files to a loadable .bin file (or other formats that I implemented for specific applications, like M9312 boot PROM .hex file).

Don
 
Last edited:
here is win32 compilation of converter. Seems it works
 

Attachments

  • obj2bin.zip
    21.2 KB · Views: 6
Back
Top