variadic argument problem with longs for target pdp-11

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi there!  I'm hoping that someone can confirm my findings here, or at
least point me where I'm going wrong.

I'm working on bare metal with the pdp11-aout cross compiler. I've got a
simple vsprintf created that works for char, int, and string types, but
fails when it comes to longs. After a bit of debugging, I think the actual
issue is stack confusion in __builtin_va_arg.

For those unfamiliar with the pdp-11 architecture, a char is 1 byte, int
and short are 2 bytes, long is 4 bytes.

When I trace through the code, there is an address fault generated when R0
gets

Here, the long I used was 0xABCDEF (052746757 in octal):
(this snippet happens when getting the long argument using __builtin_va_arg)
003730 030004|015740 003720  MOV 16(R5),R0        # R0 now contains 015772,
which is the high word of the long argument
003734 030000|003734 172320  MOV #4,R1
003740 030000|015772 000004  ADD R0,R1
003742 030000|015776 015740  MOV R1,16(R5)
003746 030000|015772 015772  MOV (R0),R0        #  R0 now contains the high
word (0253)
003750 030000|000253 015776  MOV 2(R0),R1        # <<< R1 is now filled
erroneously with a pointer to 0253 instead of the stack

The last instruction attempts to fill R1 from a pointer to the vectors in
memory, which generates the address fault.

I'm more than happy to share test code, but didn't want to spam the group
unnecessarily.

Any help is appreciated!

Cheers,
Chris



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux