On Wed, Oct 15, 2008 at 06:12:23PM +0200, Robert Millan wrote:
> On Wed, Oct 15, 2008 at 03:16:56AM +0100, Ben Hutchings wrote:
> > It's for a Motorola 56000 (aka DSP56000 or DSP56K) processor, which is a
> > different architecture but maybe with some similarities.  I doubt we
> > have any of the necessary tools but the code is short enough to hand-
> > assemble.
> 
> I found an assembler, "a56" (see http://www.zdomain.com/a56.html), which seems
> to be DFSG-free (BSD-style license).  I'll see about packaging it.

Gah, there's a bit more to this:

  - First I had to run "frodos" on bootstrap.asm to cleanup the CRLF.

  - Attached patch fixes a few errors spit by a56.  I think my other two fixes
    are correct, but I have no idea what the '<' / '>' candy is supposed to do
    (hints?).

  - Resulting offsets doen't match with the blob.  I still haven't figured out
    how are program code offsets mapped to the output file, but some parts
    don't match.  For example, the blob has a jump (0C 00 40) to 0x40
    (and so does a56 output, at offset 0x0 in both cases), but then code
    from the blob continues at 0xc0, unlike code from a56 which continues at
    0x40.  Is there some trick to this?

Attached as well is tobin.c, a small parser I've written to test this (it
reads a56 output and writes it to output file in binary form).

Also attaching the blob in binary form for convenience.

-- 
Robert Millan

  The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and
  how) you may access your data; but nobody's threatening your freedom: we
  still allow you to remove your data and not access it at all."
  - Remove '<' and '>' candy (FIXME: find out why)
  - Replace 'move' with 'movem' when accessing program memory
  - Rename a few labels to avoid duplicates (which a56 can't handle)

--- ../bootstrap.asm.old	2008-10-15 18:22:56.000000000 +0200
+++ ../bootstrap.asm	2008-10-15 19:08:26.000000000 +0200
@@ -51,19 +51,20 @@
         ; Copy DSP program control
         move    #real,r0
         move    #upload,r1
-        do      #upload_end-upload,<_copy
-        move    P:(r0)+,x0
-        move    x0,P:(r1)+
-_copy   movep   #>4,X:<<M_HCR
-        movep   #>$c00,X:<<M_IPR
+        do      #upload_end-upload,_copy
+        movem    P:(r0)+,x0
+        movem    x0,P:(r1)+
+        movep   X:<<M_HRX,Y:(r0)+
+_copy   movep   #4,X:<<M_HCR
+        movep   #$c00,X:<<M_IPR
         and     #<$fe,mr
         jmp     upload
 
 real
         org     P:$7ea9
 upload
-        movep   #>1,X:<<M_PBC
-        movep   #>0,X:<<M_BCR
+        movep   #1,X:<<M_PBC
+        movep   #0,X:<<M_BCR
 
 next    jclr    #0,X:<<M_HSR,*
         movep   X:<<M_HRX,A
@@ -81,18 +82,18 @@
         cmp     x0,A
         jeq     load_Y
 
-load_P  do      y0,_load
+load_P  do      y0,_load_P
         jclr    #0,X:<<M_HSR,*
         movep   X:<<M_HRX,P:(r0)+
-_load   jmp     next
-load_X  do      y0,_load
+_load_P jmp     next
+load_X  do      y0,_load_X
         jclr    #0,X:<<M_HSR,*
         movep   X:<<M_HRX,X:(r0)+
-_load   jmp     next
-load_Y  do      y0,_load
+_load_X jmp     next
+load_Y  do      y0,_load_Y
         jclr    #0,X:<<M_HSR,*
         movep   X:<<M_HRX,Y:(r0)+
-_load   jmp     next
+_load_Y jmp     next
 
 upload_end
         end
#include <stdlib.h>
#include <stdint.h>
#include <stdio.h>
#include <fcntl.h>
#include <sys/types.h>

main (int argc, char *argv[])
{
  uint8_t type;
  off_t offset;
  uint32_t native_value;
  uint8_t value[3];
  int fd;

  if (argc != 2)
    {
      fprintf (stderr, "Usage: %s output < input\n", argv[0]);
      exit (1);
    }

  fd = open (argv[1], O_WRONLY | O_CREAT | O_TRUNC, 0644);

  while (scanf ("%c %x %x\n", &type, &offset, &native_value) != EOF)
    {
      if (type != 'P')
	continue;

      value[0] = (native_value >> 16) & 0xff;
      value[1] = (native_value >> 8) & 0xff;
      value[2] = native_value & 0xff;

      pwrite (fd, value, 3, offset);
    }
}

Attachment: blob.bin
Description: Binary data

Reply via email to