Post Reply 
Service module (SM1C) and peripherial flags
05-27-2024, 08:46 AM (This post was last modified: 05-27-2024 08:50 AM by ThomasF.)
Post: #1
Service module (SM1C) and peripherial flags
Hi,

I was pointed to a piece of code in the Service module for the HP41, which apparently checks or tests the peripheral flags.

For me, the code looks quite strange, I understand what the test tries to do, but I can't understand how it could or should work!

Apparently it loads a flag pattern in the C register, and then checks to see if the FI flags are set accordingly.
But I can't understand how the flags are updated, IMHO only specific hardware can drive the FI lines and setting of the flags, this is not possible by just software.

Code:
 We start by initializing the C register ...
 460A 04E          C=0 ALL
 460B 2DC          R= 13
 460C 3D0          LD@R F
 460D 3D0          LD@R F
 460E 3D0          LD@R F
 460F 3D0          LD@R F
 4610 09C          R= 5
 4611 3D0          LD@R F
 4612 3D0          LD@R F
 4613 3D0          LD@R F
 4614 01C          R= 3

 Now register C contains FFFF0000FFF000

 In the following code we check all FI flags - which actually matches the content of the C register!
 Remember that FI is active low, i.e. a low value on FI represents an active state (ie carry set).
  * If C[i] contains '0', the corresponding PF flag should be active (?FI= i -> carry), and if no carry we jump (JNC).
  * If C[i] contains 'F', the corresponding PF flag should not be active (?FI= i -> no carry), and if carry we jump (JC).

 4615 3AC          ?FI= 0
 4616 0DB          JNC +27 4631
 4617 32C          ?FI= 1
 4618 0CB          JNC +25 4631
 4619 22C          ?FI= 2
 461A 0BB          JNC +23 4631
 461B 02C          ?FI= 3
 461C 0AF          JC +21 4631  ; C[3] = F
 461D 06C          ?FI= 4
 461E 09F          JC +19 4631  ; C[4] = F
 461F 0AC          ?FI= 5
 4620 08F          JC +17 4631  ; C[5] = F
 4621 16C          ?FI= 6
 4622 07B          JNC +15 4631
 4623 2AC          ?FI= 7
 4624 06B          JNC +13 4631
 4625 12C          ?FI= 8
 4626 05B          JNC +11 4631
 4627 26C          ?FI= 9
 4628 04B          JNC +9 4631
 4629 0EC          ?FI= 10
 462A 03F          JC +7 4631  ; C[10] = F
 462B 1AC          ?FI= 11
 462C 02F          JC +5 4631  ; C[11] = F
 462D 36C          ?FI= 12
 462E 01F          JC +3 4631  ; C[12] = F
 Finally we check FI:13 and since C[13] is 'F' the flag should not be active, so we should jump (JNC)
 462F 2EC          ?FI= 13
 4630 01B          JNC +3 4633 ; C[13] = F

 We end up here if and only if any flag (i) mismatches the value in C[i]!
 I interpret that this is an "error" state, i.e. we jump here only if C[i] doesn't correspond to the actual flag!
 We set B[3] = 0, and sets cpu flag 11
 4631 022          B=0 @R
 ; B = .00FFFFFFF0...
 4632 188          SETF 11

 We only jump directly here from 4630 if (and only if) all FI flags corresponds to the valuec in C.
 4633 05E          C=0 MS

So after this test is executed, cpu flag 11 is set if any peripheral flag mismatches the value in C.
Maybe the pattern in C is only a reference to what is expected, but the values are not used by the code, it would only make sense if C is somehow shifted out on the FI bus - but I can't see how that could be done!

Or maybe if no peripheral is selected, does the value of C drive the FI-flags instead? This is something I have missed if that is the case!
But that would make no sense either - since normally no peripheral is selected, and any '0' in C[S] would then cause a service request (?FI= 13 aka ?SERV).

My next step is to try and write a small test program that executes this code, or just try to trace the Service module to see if this code works, or even if it is actually executed (maybe the code is left in the ROM but never used).

Maybe someone has some thoughts or ideas about this?

Cheers,
Thomas

[35/45/55/65/67/97/80 21/25/29C 31E/32E/33E|C/34C/38E 41C|CV|CX 71B 10C/11C/12C/15C|CE/16C 32S|SII/42S 28C|S 48GX/49G/50G 35S 41X]
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Service module (SM1C) and peripherial flags - ThomasF - 05-27-2024 08:46 AM



User(s) browsing this thread: 2 Guest(s)