[comp.sys.handhelds] update to disassembler

grue@lance.hss.bu.oz (Frobozz) (12/20/89)

hiya,

Thanks to Alonzo Gariepy for confirming my doubts about the 81A... instructions
His fix is included below.
I also noticed some rather funny errors when jump and call instructions were
being output.  A new version of GETN seems to fix the problems (which
might have been only in my mind --- I was tired at the time I 'noticed'
them).  The new version of GETN should run faster than before and it is also
shorter (it appears to be a bottle neck during execution).  I cannot see
why there should be any difference between the two unless there are some
nasty side effects in the PEEK code.  That's why I think I am probably dreaming
up the problems.



I'd like to hear about any other bugs that appear in this program (it was
written in a bit of a hurry).





GETN [ 177E ]              ; load a nibble from memory at PC
  << PC #1h DUP2 + 'PC' STO PEEK NUM 48 -
    IF DUP 9 >
    THEN 7 -
    END
  >>

IN81 [ 5949 ]             ; instructions starting 81
  << GETN -> a
    <<
      IF a 8 <
      THEN a 4 < "RLN.w " "RRN.w " IFTE a 4 MOD 65 + CHR +
      ELSE
        IF a 11 <
        THEN GETN FIELDS {
          << GETN SWAP OVER 7 > "SUB" "ADD" IFTE SWAP + " #" + GETN 1 + ->STR +
              "," + SWAP 4 MOD 65 + CHR +
          >>
          << "SRB" SWAP + " " + GETN 65 + CHR + >>
          << GETN GETN
            IF DUP 7 >
            THEN 8 - ->STR "C"
            ELSE ->STR "A"
            END ROT {
              << ROT "MOVE" SWAP + " " + SWAP + ",R" + SWAP + >>
              << ROT "MOVE" SWAP + " R" + ROT + "," + SWAP + >>
              << ROT "SWAP" SWAP + " " + SWAP + ",R" + SWAP + >>
            } SWAP 1 + GET
          >> } a 7 - GET
        ELSE
          IF a 11 >
          THEN "SRB.w " 53 a + CHR +
          ELSE { "JUMP.a A" "JUMP.a C" "MOVE.a PC,A" "MOVE.a PC,C"
                    "SWAP.a A,PC" "SWAP.a C,PC" } GETN 1 - GET
          END
        END
      END
    >>
  >>
                                                     Paul Dale
seeya
SNIF

Language Centre              internet    : grue@lance.hss.bu.oz{.au}
Bond University              JANET       : grue%lance.hss.bu.oz@uk.ac.ukc
Gold Coast, Qld 4229         ARPA, bitnet: grue%lance.hss.bu.oz.au@uunet.uu.net
Australia                    UUCP        : ..!uunet!munnari!lance.hss.bu.oz!grue