Jump to content
IGNORED

Atari_Ace's Blog - APX Pascal Architecture, part four


RSS Bot

Recommended Posts

The last blog entry introduced the tools I'm using to explore the Pascal runtime, and included a preliminary (i.e. rough) disassembly. Now we'll start refining that disassembly and start discussing more of the opcodes.

Firstly, the last listing was erroneous around $B959 to $B991. There are strings there I somehow missed when spot checking the disassembly, so I've fixed up that part of the disassembly. There were also a couple of missing $9B's as well after strings, and the p-code disassembly had a couple of errors as well which I've now fixed.

Now let's discuss some more opcodes. The simplest opcode in the listing is opcode DB. It is just:

 
Another simple opcode is $DA, which disassembles as:
AF5F: BC 00 06          LDY EVALPAGE,XAF62: BD 02 06          LDA EVALPAGE+2,XAF65: 9D 00 06          STA EVALPAGE,XAF68: 98                TYAAF69: 9D 02 06          STA EVALPAGE+2,XAF6C: BC 01 06          LDY EVALPAGE+1,XAF6F: BD 03 06          LDA EVALPAGE+3,XAF72: 9D 01 06          STA EVALPAGE+1,XAF75: 98                TYAAF76: 9D 03 06          STA EVALPAGE+3,XAF79: 4C 9D 00          JMP NEXT_OP1
Some other simple stack-only opcodes are 30 (AND), 32 (OR), 34 (NOT), 36 (EOR), 38 (NEG), 40 (ADD) and 44 (SUB). All of these replace the top two values on the stack with the result of the operation.

Opcodes 60 and 70 oddly point to the same code, which looks like this:
​B1A9: 20 2F BE          JSR $BE2FB1AC: F0 3B             BEQ $B1E9B1AE: 30 39             BMI $B1E9B1B0: 10 44             BPL $B1F6
and 74 is similar:
BE2F: BD 02 06          LDA EVALPAGE+2,XBE32: DD 00 06          CMP EVALPAGE,XBE35: F0 0B             BEQ $BE42BE37: BD 03 06          LDA EVALPAGE+3,XBE3A: FD 01 06          SBC EVALPAGE+1,XBE3D: 09 01             ORA #1BE3F: 70 0A             BVS $BE4BBE41: 60                RTSBE42: BD 03 06          LDA EVALPAGE+3,XBE45: FD 01 06          SBC EVALPAGE+1,XBE48: 70 01             BVS $BE4BBE4A: 60                RTSBE4B: 49 80             EOR #$80BE4D: 09 01             ORA #1BE4F: 60                RTS
This difference here seems to be whether the 16-bit comparisons here are done signed or unsigned. The 6x opcodes are signed comparisons, and the 7x opcodes are unsigned comparisons. 60 is EQU and 70 is UEQU, which happen to have identical implementations, and 62 and 72 are similarly NEQ and UNEQ. 64, 66, 68 and 6A seem to be greater than (GT), less than (LT), greater than or equal (GTE) and less than or equal (LTE) respectively. 74, 76, 78 and 7A appear to be same, only unsigned.

To further complicate matters, the 8x opcodes also implement comparisons (the same six EQU, NEQ, GT, LT, GTE, LTE operations), but for other types than signed and unsigned integers. The second byte after determines the type, with 00 => bool, 01 => string (both from the stack, so both of these sequences consume 2 bytes), and 02, 03 and 04 being various byte comparisons consuming an additional 2 bytes after the type byte. So our simple p-code disassembler which assumes all opcodes but 2C are fixed size needs to be modified to handle these opcodes a little differently.

That's enough for this post. The runtime disassembly is certainly starting to make a bit more sense, but there are plenty of mysteries left to explore.

Attached File(s)


http://atariage.com/forums/blog/734/entry-15600-apx-pascal-architecture-part-four/
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...