6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Sun May 05, 2024 12:46 pm

All times are UTC




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Wed Feb 17, 2016 9:15 pm 
Offline

Joined: Thu Jan 14, 2016 5:24 pm
Posts: 27
I'm trying to disassemble some code and cannot reconcile it with my interpretation of the datasheet.

During the initialization we have

Code:
lda #$00
sta viabifr
sta viaaifr
lda #$80
sta viabier
sta viaaier


I'm guessing this is attempting to disable interrupts but seems wrong.

I don't see what writing all zeros will achieve, the Rockwell datasheet reads

Quote:
... individual flag bits can be cleared by writing a "1" into the appropriate bit of the IFR.


The write to the IER looks equally odd, the datasheet says

Quote:
Selected bits in the IER can be set by writing to the IER with bit 7 in the data word set to a 1.
...
For each zero, (of bits 6 to 0) the corresponding bit will be unaffected.


So this looks like a no-op.

Am I misunderstanding the datasheet or is the code nuts?


Top
 Profile  
Reply with quote  
PostPosted: Wed Feb 17, 2016 10:02 pm 
Offline
User avatar

Joined: Fri Dec 11, 2009 3:50 pm
Posts: 3352
Location: Ontario, Canada
srowe wrote:
So this looks like a no-op.
I agree.

Of course the IFR and IER are cleared anyway by a reset. So maybe the code snippet was included "to be on the safe side," and the author never realized it accomplished nothing.

-- Jeff

_________________
In 1988 my 65C02 got six new registers and 44 new full-speed instructions!
https://laughtonelectronics.com/Arcana/ ... mmary.html


Top
 Profile  
Reply with quote  
PostPosted: Thu Feb 18, 2016 10:10 am 
Offline
User avatar

Joined: Tue Mar 02, 2004 8:55 am
Posts: 996
Location: Berkshire, UK
Yep. You clear the enables by reading them and writing back the value
Code:
    64 00:0004: AD CE 7F                     lda     VIA1_IER                ; Ensure no via interrupts
    65 00:0007: 8D CE 7F                     sta     VIA1_IER
    66 00:000A: AD EE 7F                     lda     VIA2_IER
    67 00:000D: 8D EE 7F                     sta     VIA2_IER

Writing to the flag register doesn't always work. Some of the interrupt flags can only be cleared by updating other registers.

_________________
Andrew Jacobs
6502 & PIC Stuff - http://www.obelisk.me.uk/
Cross-Platform 6502/65C02/65816 Macro Assembler - http://www.obelisk.me.uk/dev65/
Open Source Projects - https://github.com/andrew-jacobs


Top
 Profile  
Reply with quote  
PostPosted: Wed Sep 09, 2020 10:13 am 
Offline

Joined: Tue Jul 07, 2020 10:35 am
Posts: 40
Location: Amsterdam, NL
My interpretation of the datasheet is that if you want to disable all interrupts on the VIA, then you actually would write:
Code:
LDA %01111111  ;; a bit 7 `0` means any bit 0-6 `1`s are a "clear"
STA VIA1_IER
STA VIA2_IER

Quote:
Yep. You clear the enables by reading them and writing back the value

This can't be right. Reading the IER wouldn't achieve this because the datasheet says it will _always_ return a 1 for bit 7 and writing 0s _always_ ignores that particular bit. So, for example, if you had all interrupts enabled:
Code:
LDA VIA1_IER  ;; A is now %11111111
STA VIA1_IER  ;; a bit 7 `1` means any subsequent bit 0-6 `1`s are a "set", not a "clear"


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: