Author Topic: Project thread: 68xx analysis cont'd  (Read 352 times)

0 Members and 1 Guest are viewing this topic.

Offline metertech58761Topic starter

  • Regular Contributor
  • *
  • Posts: 152
  • Country: us
Project thread: 68xx analysis cont'd
« on: August 14, 2023, 05:52:42 am »
Rather than continue to dribble threads on this ongoing bit of code analysis, I'll try to keep it all in one thread going forward?

;   Read 4044 latch (bit 0-2: pulse streams 0-2; bit 3: Ext. Input 3; bit 4-6: don't care; bit 7: Ext. Input 5)

      LDAA  extInput
      ANDB  #$08 ; evaluate External Input 3 bit
      BNE   app_997 ; Set inp3Flag if bit is 0
      INCB ; byte-saving equivalent of LDAB #$01
      STAB  inp3Flag

app_997   ANDA  #$07 ; now we look at KYZ0 - KYZ2 data
      EORA  NVR_03
      STAB  NVR_03
      ANDA  NVR_03

;   Initialization routine sets NVR_03 to 7

;   NVR_03 is just a placeholder until role is identified - then it will get a proper mnemonic

      ANDA  #$07
      LDAB  #$03
      LDX   #kyz0Pulse
app_9A8   BITA  #$01
      BEQ   app_9AF
      JSR   sub_60A
app_9AF   ABX ; advance to kyz1Pulse (and kyz2Pulse if needed)
      BNE   app_9A8
      PULX ; restore index to $0C00
;      app continues

;   Check 24-bit value to ensure it hasn't exceeded 9,999,999 (and reset if so)
sub_60A   PSHA
      LDD   $01,X ; increment value by one
      ADDD  #$0001
      STD   $01,X
      LDAA  $00,X ; Was the maximum exceeded?
      ADCA  #$00
      CMPA  #$98
      BNE   sub_62A
      CMPB  #$80
      BNE   sub_62A
      LDAB  $01,X
      CMPB  #$96
      BNE   sub_62A
      STAA  $02,X ; Zero out 24-bit value
      STAA  $01,X
sub_62A   STAA  $00,X ; Jumping here ensures upper byte was properly incremented

Here's what I think the above code does - correct me if I'm wrong?

After reading the latch at extInput, bit 3 is evaluated if 0, inp3Flag is set to 1 (it gets cleared elsewhere, and is only used once as a yes/no flag)

Then the remaining 3 bits are evaluated to determine which input bits have changed state. What is the purpose of the successive operations on NVR_03?

The result of the operations then carries forward in AccA, AccB is set to a fixed value of 3, and the index is set to address NVR_8C (24-bit value).

Bit 1 is tested, and if found to be 0, the next step is skipped.

The subroutine is called, where the current 24-bit value is advanced by 1, and reset if it exceeds 9,999,999 counts.

The index is advanced by 3, pointing it to kyz1Pulse, and if needed, advanced once more, to kyz2Pulse (all 3 bytes each).

AccA is shifted and the process repeated until empty and Z flag trips. In this case, as I don't care about the sign bit, should LSR be used instead of ASR?

(edited to update after further understanding and adjusted code accordingly)
« Last Edit: August 14, 2023, 05:15:07 pm by metertech58761 »

Offline metertech58761Topic starter

  • Regular Contributor
  • *
  • Posts: 152
  • Country: us
Re: Project thread: 68xx analysis cont'd
« Reply #1 on: September 05, 2023, 03:01:06 am »
Moving along...

SUBA  NVR_4D ; only other reference in code writes value $25 to this address
BPL   nmi_0AF ; if this branch is taken, several counters etc. are skipped
ADDA  NVR_4C ; only other reference in code writes value $5E to this address

In this code, these are the only instances where the address NVR_4E is used.

NVR_4C and NVR_4D get loaded at some point with the values indicated, but not right away when the unit is initialized.

Is this some kind of stand-alone counter? Or is it likely the now-missing second EPROM likely manipulates these addresses as well?

Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo