Re: A1C XDF Additions
Posted: 2025 Jan 16, 16:41
Yeah that works nice! I didn't know the standard practice of ff being signed or that selecting word in windows calculator rolled it over for you :). I let grok know that it was wrong and here was the reply.
Unsigned Hex Addition:
0xB480 + 0xFF5D = 0xB3DD because:
0xB480 in decimal is 46208
0xFF5D in decimal is 65373
46208 + 65373 = 111581
111581 mod 65536 (for 16-bit address space) = 46077 which is 0xB3DD in hex.
If you're getting 0xB3DD, then your calculator is likely treating ff5d as an unsigned value. If you intended for ff5d to be treated as a signed number -163, you would need to check if your calculator has an option to switch between signed and unsigned arithmetic or if there's a way to indicate signed operations.
Code: Select all
76d7: c3,e8,b8,00 stw R0,[Re8+b8] [338] = 0;
76db: 6c,38,14 ml2w R14,R38 lR14 *= R38;
76de: 0d,01,14 shldw R14,1 lR14 <<= 1;
76e1: c3,e8,ba,16 stw R16,[Re8+ba] [33a] = R16;
76e5: 45,4f,00,fc,14 ad3w R14,Rfc,4f R14 = b3fd;
76ea: ac,da,1a ldzbw R1a,Rda wR1a = yRda;
76ed: 64,1a,14 ad2w R14,R1a R14 += R1a;
76f0: 69,02,00,14 sb2w R14,2 R14 -= 2;
76f4: ae,15,18 ldzbw R18,[R14++] wR18 = [R14++];
76f7: 6c,16,18 ml2w R18,R16 lR18 *= R16;
76fa: 0d,02,18 shldw R18,2 lR18 <<= 2;
76fd: be,14,16 ldsbw R16,[R14] swR16 = [R14];
7700: 64,16,1a ad2w R1a,R16 R1a += R16;
7703: d5,07 jnv 770c if (R1a > ffff) {
7705: de,08 jlt 770f if (R1a < 0) goto 770f;
7707: b1,ff,1a ldb R1a,ff R1a = ff;
770a: 20,10 sjmp 771c goto 771c; }
Code: Select all
Reg 0x33a = TQ_STAT_CAP
DO "NON-SHIFTING STATIC TV CALCULATION"
76e5: 45,4f,00,fc,14 ad3w R14,Rfc,4f R14 = b3fd;
76ea: ac,da,1a ldzbw R1a,Rda wR1a = yRda;
76ed: 64,1a,14 ad2w R14,R1a R14 += R1a;
76f0: 69,02,00,14 sb2w R14,2 R14 -= 2;
76f4: ae,15,18 ldzbw R18,[R14++] wR18 = [R14++];
76f7: 6c,16,18 ml2w R18,R16 lR18 *= R16;
76fa: 0d,02,18 shldw R18,2 lR18 <<= 2; #[ R18 *= 4]
76fd: be,14,16 ldsbw R16,[R14] swR16 = [R14];
7700: 64,16,1a ad2w R1a,R16 R1a += R16;
Code: Select all
NON-SHIFTING STATIC TV CALCULATION
GR_CM = 1 ---------------------------| TV_STAT = (TQ_STAT_CAP * SCSLP1) +
| SCINT1
|
| --- ELSE ---
|
GR_CM = 2 ---------------------------| TV_STAT = (TQ_STAT_CAP * SCSLP2) +
| SCINT2
|
| --- ELSE ---
|
GR_CM = 3 ---------------------------| TV_STAT = (TQ_STAT_CAP * SCSLP3) +
| SCINT3
|
| --- ELSE ---
|
| TV_STAT = (TQ_STAT_CAP * SCSLP4) +
| SCINT4
Code: Select all
b3fd: 58 byte 58 SCSLP1
b3fe: f5 byte f5 SCINT1
b3ff: 58 byte 58 SCSLP2
b400: f5 byte f5 SCINT2
b401: 39 byte 39 SCSLP3
b402: f5 byte f8 SCINT3
b403: 47 byte 58 SCSLP4
b404: eb byte eb SCINT4
b405: ff byte ff
b406: 50,00 word 50 TOTTV1
b408: a0,ff word ffa0 TOTTV2
b40a: 50,00 word 50 TOTTV3
b40c: a0,00 word a0 TOTTV4
I believe you are correct.efloth wrote: ↑2025 Jan 16, 18:19 Without knowing what Rda is I am guessing but this looks likely:
Code: Select all
b3fd: 58 byte 58 SCSLP1 b3fe: f5 byte f5 SCINT1 b3ff: 58 byte 58 SCSLP2 b400: f5 byte f5 SCINT2 b401: 39 byte 39 SCSLP3 b402: f5 byte f8 SCINT3 b403: 47 byte 58 SCSLP4 b404: eb byte eb SCINT4 b405: ff byte ff b406: 50,00 word 50 TOTTV1 b408: a0,ff word ffa0 TOTTV2 b40a: 50,00 word 50 TOTTV3 b40c: a0,00 word a0 TOTTV4
Why not put an rbase command in the SAD DIR and let it do the math?efloth wrote: ↑2025 Jan 16, 15:52 Any idea what address [Re2+ff5d] is referencing? I calculated it using wrap around but landed in code or outside the used program memory.
Code: Select all
6940: 45,d2,00,fc,e2 ad3w Re2,Rfc,d2 Re2 = b480; ...... 7551: b3,e3,5d,ff,3a ldb R3a,[Re2+ff5d] R3a = [Re2+ff5d];
Code: Select all
RBA E2 B480
Is there a way to set rbase for a specific code address range? In this case re2 is changed a few times:jsa wrote: ↑2025 Jan 16, 20:34Why not put an rbase command in the SAD DIR and let it do the math?efloth wrote: ↑2025 Jan 16, 15:52 Any idea what address [Re2+ff5d] is referencing? I calculated it using wrap around but landed in code or outside the used program memory.
Code: Select all
6940: 45,d2,00,fc,e2 ad3w Re2,Rfc,d2 Re2 = b480; ...... 7551: b3,e3,5d,ff,3a ldb R3a,[Re2+ff5d] R3a = [Re2+ff5d];
Code: Select all
RBA E2 B480
Code: Select all
423d: 45,e6,00,fc,e2 ad3w Re2,Rfc,e6 Re2 = b494;
6940: 45,d2,00,fc,e2 ad3w Re2,Rfc,d2 Re2 = b480;
878b: 45,ff,00,fe,e2 ad3w Re2,Rfe,ff Re2 = bd55;