I have a simulator implemented and somewhat working (have not tested all
instructions yet), and trying to run the startup code generated by the
assembler exposed a "weirdness" I had not noticed before:
The assembler insists that you put these startup macros in, so I used the
samples found in Demo/Dummy/Dummy.asm :
------------------- Cut here -------------
.CHIP PMS150
//{{PADAUK_CODE_OPTION
.Code_Option Under_20mS_VDD_Ok No
.Code_Option LVR 2.5V
.Code_Option Security Disable// Security Disable
//}}PADAUK_CODE_OPTION
.WRITER O_S
.ADJUST_IC SYSCLK=IHRC/8, IHRC=16MHz, VDD=5V;
------------------- Cut here -------------
Here is a disassembly of what it generates:
0000: 1700 MOV A,0x00
0001: 0085 MOV IO.0x05,A
0002: 0FE4 SET1 IO.0x04.7 // B7 documented as "reserved"
0003: 1700 MOV A,0x00
0004: 0082 MOV IO.0x02,A
0005: 1700 MOV A,0x00
0006: 008B MOV IO.0x0B,A
0007: 173C MOV A,0x3C
0008: 0083 MOV IO.0x03,A
0009: 1FFE CALL 03FE // ?? This is the problem ??
000A: 12FF CEQSN A,0xFF
000B: 181C GOTO 001C
000C: 0FD1 SET1 IO.0x11.6
000D: 0981 CLEAR MEM.0x01
000E: 1709 MOV A,0x09
000F: 05C0 MOV MEM.0x00,A
0010: 0D90 T1SN IO.0x10.4
0011: 1810 GOTO 0010
0012: 0FD0 SET1 IO.0x10.6
0013: 0013 DZSN A
0014: 1813 GOTO 0013
0015: 08C0 DZSN MEM.0x00
0016: 1813 GOTO 0013
0017: 0ED0 SET0 IO.0x10.6
0018: 0901 INC MEM.0x01
0019: 07C1 MOV A,MEM.0x01
001A: 008B MOV IO.0x0B,A
001B: 180E GOTO 000E
// .. user code goes here
03F8: 0000 NOP
03F9: 0000 NOP
03FA: 0000 NOP
03FB: 0000 NOP
03FC: 0000 NOP
03FD: 0000 NOP
03FE: 1FFF CALL 03FF
03FF: 1F9D CALL 039D
As you can see, it generates a CALL to address 0x3FE which contains all
ones which is the default value for unused locations, and happens to
translate to "CALL 03FF".
Prior to doing this, they set Bit7 of IO.4 which is the interrupt enable
register, and Bit7 is documented as "reserved".
Following the CALL 03FE they test the accumulator value for 0xFF, and
going in to the call, it is clearly 0x3C - so they expect that this CALL
can modify the accumulator.
I'm wondering if setting IO.4.7 is mapping some special code, perhaps
"RET immediate" into the reserved area in order to retrieve some chip
dependant value, but I have no way to test this. It is also possible
that the progammer automatically programs some calibration value into
this location, however that leads to two questions:
1) What does the ICE do in this case?
2) The obtained value is only used to either 1) continue the startup
code, or 2) jump directly to the user code bypassing the remainder
of the startup code, why would the writer be making this decision
For that matter why would anything not under user control be
doing this?, it does not appear to be a calibration value as it is
lost 4 instructions later having not been used.
Could someone with the ICE look into this and see what is happening?
Thanks,
Dave