[comp.unix.wizards] Hand Assembling for the VAX..

kishore@ms.uky.edu (Kishore K. Seshadri) (03/19/88)

I've been trying to hand assemble some stuff for the MicroVAX II that I work
on. However I find the byte-backwards (ok, maybe byte-different..) stuff on 
the VAX really confusing. I've looked over the Architecture reference manual
but it hasn't been very helpful. The question I had is : given a BRW instructionthat looks like      BRW 1040 (Branch Word) what does the bit pattern look
like? (assuming the 1040 is in hex). Also BRW seems to allow a maximum 
displacement of 16 bits. What does one use to make bigger jumps? 
	Also if I obtain the address of a function bar using nlist, the actual
function seems to starts a few bytes after the value returned by nlist. These
few bytes are probably used to hold some status info. I've been trying to 
figure out the exact size of this area. 
	If there are any assembly hackers out there, I'd be glad for any help...

charles@ubc-bdcvax.UUCP (04/01/88)

>/***** ubc-bdcvax:comp.unix.wizards / e!kishore /  4:10 am  Mar 19, 1988*/
>The question I had is : given a BRW instructionthat looks like
>BRW 1040 (Branch Word) what does the bit pattern look
>like? (assuming the 1040 is in hex). Also BRW seems to allow a maximum 
>displacement of 16 bits. What does one use to make bigger jumps? 
>	Also if I obtain the address of a function bar using nlist, the actual
>function seems to starts a few bytes after the value returned by nlist. These
>few bytes are probably used to hold some status info. I've been trying to 
>figure out the exact size of this area. 

At least, on a VAX 11/750 a routine actually starts 2 bytes after
the address given for its name by nlist(3).  Perhaps for larger than
16 bit range branches, you have to implement the branch with a jmp
and surround it with a small local negated logic jump.

--
Charles Mathieson, Biosciences Data Centre, University of British Columbia
UUCP:	<charles@ubc-bdcvax.UUCP> or     Internet: charles@bdc.ubc.ca
	{decvax!ihnp4!alberta,watmath,uw-beaver}!ubc-vision!ubc-bdcvax!charles

keith@stratus.UUCP (Keith Edwards) (04/03/88)

>/***** ubc-bdcvax:comp.unix.wizards / e!kishore /  4:10 am  Mar 19, 1988*/
>The question I had is : given a BRW instructionthat looks like
>BRW 1040 (Branch Word) what does the bit pattern look
>like? (assuming the 1040 is in hex). Also BRW seems to allow a maximum 
>displacement of 16 bits. What does one use to make bigger jumps? 
>	Also if I obtain the address of a function bar using nlist, the actual
>function seems to starts a few bytes after the value returned by nlist. These
>few bytes are probably used to hold some status info. I've been trying to 
>figure out the exact size of this area. 

Here's the output for a brw #^x1040

                                                                                                                          page 1

                                    0000  00000000    1 	.entry _main,0
                                          00000002    2 
                              1040 8f 31  00000002    3 	brw #^x1040
                                          00000006    4 
                                          00000006    5 	.end _main
                                          00000006    6 

The Vax puts the more significant byte of each word at the higher addresses.

You can use the JMP instruction, which allows a 32-bit address target for
branches of longer that 16 bits.

The first 16-bit word of each function is a register mask which specifies
the registers which are to be saved on the stack when the procedure is
called.  The top 4 registers (PC, SP, AP, and FP) get saved automatically,
and you can't save r0 or r1 (which are used for function-returned values).
So to save all the registers you can save, use a register mask of ^x0ffc.

Hope this helps!

-keith