6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Fri May 03, 2024 1:56 pm

All times are UTC




Post new topic Reply to topic  [ 8 posts ] 
Author Message
PostPosted: Fri Mar 31, 2017 12:34 am 
Offline
User avatar

Joined: Tue Oct 25, 2016 8:56 pm
Posts: 360
Hi again all,

I've been getting my head round WDC's official assembler (no easy feat I can tell you!), but I've come across something in one of their official examples (8LED_CCAH.asm to be exact) which doesn't make sense to me:

Code:
;This code is here in case the system gets an NMI.  It clears the intterupt flag and returns.
badVec:      ; $FFE0 - IRQRVD2(134)
   php
   pha
   lda #$FF
            ;clear Irq
   pla
   plp
   rti


The label "badVec" is mapped into the NMI vector. I... I don't understand what this code is supposed to be doing. To my mind, you could simply do the RTI on its own. It seems to put register A and P on the stack, set A to FF, then overwrite A and P with their original values as pulled from the stack... this just seems like a NOOP, or am I missing something?

_________________
Want to design a PCB for your project? I strongly recommend KiCad. Its free, its multiplatform, and its easy to learn!
Also, I maintain KiCad libraries of Retro Computing and Arduino components you might find useful.


Top
 Profile  
Reply with quote  
PostPosted: Fri Mar 31, 2017 12:53 am 
Offline
User avatar

Joined: Sun Jun 30, 2013 10:26 pm
Posts: 1927
Location: Sacramento, CA, USA
In the context you provided, it seems to be a bit of cycle-wasting nonsense to me too.

Mike B.


Top
 Profile  
Reply with quote  
PostPosted: Fri Mar 31, 2017 1:15 am 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8430
Location: Southern California
Wow, somebody sure messed up, huh?!

_________________
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?


Top
 Profile  
Reply with quote  
PostPosted: Fri Mar 31, 2017 2:30 am 
Offline

Joined: Sat Oct 20, 2012 8:41 pm
Posts: 87
Location: San Diego
Why is the (;clear Irq) comment located on a blank line?
Maybe something like sta zploc should be there?


Top
 Profile  
Reply with quote  
PostPosted: Fri Mar 31, 2017 3:10 am 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8430
Location: Southern California
Still, you don't need PHP and PLP, since they're an automatic, implied part of the interrupt sequence and RTI anyway. As least they didn't do SEI and CLI too!

_________________
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?


Top
 Profile  
Reply with quote  
PostPosted: Fri Mar 31, 2017 10:37 pm 
Offline
User avatar

Joined: Sun Dec 29, 2002 8:56 pm
Posts: 449
Location: Canada
The only thing I can think of here is if there is a register flag located at address $FFE2 where the LDA #$FF instruction is. Maybe the $FF is loaded into an I/O reg by a read cycle ? It does say that it's an NMI flag that is cleared so there must be some sort of FF.

_________________
http://www.finitron.ca


Top
 Profile  
Reply with quote  
PostPosted: Mon Apr 03, 2017 10:11 am 
Offline
User avatar

Joined: Tue Oct 25, 2016 8:56 pm
Posts: 360
In case context helps, here's the whole program:

Code:
; File: SIM_8LED_CCAH.asm
; 09/16/2016

     PW 128         ;Page Width (# of char/line)
     PL 60          ;Page Length for HP Laser
     INCLIST ON     ;Add Include files in Listing

            ;*********************************************
            ;Test for Valid Processor defined in -D option
            ;*********************************************
   IF   USING_02
   ELSE
      EXIT         "Not Valid Processor: Use -DUSING_02, etc. ! ! ! ! ! ! ! ! ! ! ! !"
   ENDIF




;****************************************************************************
;****************************************************************************
; End of testing for proper Command line Options for Assembly of this program
;****************************************************************************
;****************************************************************************


         title  "6502 xSimul8r Program V 1.00 - 8 LED Active High"
         sttl


; bgnpkhdr
;***************************************************************************
;  FILE_NAME: SIM_8LED_CCAH.asm
;
;  DATA_RIGHTS: Western Design Center
;               Copyright(C) 1980-2016
;               All rights reserved. Reproduction in any manner,
;               in whole or in part, is strictly prohibited without
;               the prior written approval of The Western Design Center, Inc (WDC).
;
;               Information contained in this publication regarding
;               device applications and the like is intended through
;               suggestion only and may be superseded by updates.
;               It is your responsibility to ensure that your application
;               meets with your specifications.  No representation or
;               warranty is given and no liability is assumed by
;               Western Design Center, Inc. with respect to the accuracy
;               or use of such information, or infringement of patents
;               or other intellectual property rights arising from such
;               use or otherwise.  Use of WDC's products
;               as critical components in life support systems is not
;               authorized except with express written approval by
;               WDC.  No licenses are conveyed,implicitly or otherwise,
;                        under any intellectual property rights.
;
;
;
;  TITLE: 8LED_CCAH
;
;  DESCRIPTION: This File describes the WDC Simulator Example Program.
;
;
;
;  DEFINED FUNCTIONS:
;          badVec
;                   - Process a Bad Interrupt Vector - Hang!
;
;  SPECIAL_CONSIDERATIONS:
;
;
;  SHARED_DATA:
;          None
;
;  GLOBAL_MODULES:
;          None
;
;  LOCAL_MODULES:
;          See above in "DEFINED FUNCTIONS"
;
;  AUTHOR: David Gray
;
;  CREATION DATE: September 16, 2016
;
;  REVISION HISTORY
;     Name           Date         Description
;     ------------   ----------   ------------------------------------------------
;     David Gray   09/16/2016   1.00 Initial
;
;
; NOTE:
;    Change the lines for each version - current version is 1.00
;    See -
;         title  "6502 xSimul8r Program V 1.00 - 8 LED Active High"
;
;
;***************************************************************************
;endpkhdr


;***************************************************************************
;                             Include Files
;***************************************************************************
;None


;***************************************************************************
;                              Global Modules
;***************************************************************************
;None

;***************************************************************************
;                              External Modules
;***************************************************************************
;None

;***************************************************************************
;                              External Variables
;***************************************************************************
;None


;***************************************************************************
;                               Local Constants
;***************************************************************************
;
;   VIA_BASE:   equ   $f0
   VIA_BASE:   equ   $7FC0      ;; base address of VIA port on SXB
   VIA_ORB:   equ   VIA_BASE
   VIA_IRB:   equ   VIA_BASE
   VIA_ORA:   equ   VIA_BASE+1
   VIA_IRA:   equ   VIA_BASE+1
   VIA_DDRB:   equ   VIA_BASE+2
   VIA_DDRA:   equ   VIA_BASE+3
   VIA_T1CLO:   equ   VIA_BASE+4
   VIA_T1CHI:   equ   VIA_BASE+5
   VIA_T1LLO:   equ   VIA_BASE+6
   VIA_T1LHI:   equ   VIA_BASE+7
   VIA_T2CLO:   equ   VIA_BASE+8
   VIA_T2CHI:   equ   VIA_BASE+9
   VIA_SR:      equ   VIA_BASE+10
   VIA_ACR:   equ   VIA_BASE+11
   VIA_PCR:   equ   VIA_BASE+12
   VIA_IFR:   equ   VIA_BASE+13
   VIA_IER:   equ   VIA_BASE+14
   VIA_ORANH:   equ   VIA_BASE+15
   VIA_IRANH:   equ   VIA_BASE+15

      CHIP   65C02
      LONGI   OFF
      LONGA   OFF

   .sttl "6502 xSimul8r Demo Code"
   .page
;***************************************************************************
;***************************************************************************
;                    6502 xSimul8r Demo Code Section
;***************************************************************************
;***************************************************************************
;
;Example code to controll 8 LEDs driven from the W65C22 VIA Port B

      org   $2000      ;Our program code will be at $2000

   START:
      sei

      cld
      ldx   #$ff      ; Initialize the stack pointer
      txs

; First, we initialize the VIA chip registers and set Port B to OUTPUTS
      lda   #$ff
      sta   VIA_DDRB   ; set all as outputs

; Now we initialize the X register to use to count from 0 - 255 (FF)
      ldx #$00
;This is our loop where we get a value from $3000 in memory and load it
;into VIA Port B Output Register.  If ran all at once, this will cycle through memory
;from $3000 - $30FF.  The content at each memory address will be output to Port B
;which will be visable on the 8 LEDs as a binary equivalent.
;This exercise is meant to be done in the xSimul8r using single stepping.  The user can
;load the memory at $3000 with any data they wish.
LOADER:
      lda $3000,x      ; Load the value that is in memory at 3000 + x index.
      sta VIA_ORB      ; Display value on LEDs.  Value can be seen in ORB register of VIA
      inx            ; Increment the value of X by 1
      bne LOADER      ; Branch to the label "LOADER" if the value of the X-register is not $00

;After 256 loops, the program is done and we give control back to the simulator.       
   IRQHandler:
      pla
      rti

;This code is here in case the system gets an NMI.  It clears the intterupt flag and returns.
badVec:      ; $FFE0 - IRQRVD2(134)
   php
   pha
   lda #$FF
            ;clear Irq
   pla
   plp
   rti

This_project_end:
WDCMON_RAM_START   EQU   $7C00
ROMSPACE EQU WDCMON_RAM_START-This_project_end  ;gives space left in the ROM BEFORE WDCMON TABLES

   IF ROMSPACE<0
      EXIT         "Not Enough Memory for This Application - bumping into WDCMON! ! ! ! ! ! ! ! ! ! ! !"
   ENDIF


   bits:   db   1
   cnt:   db   0
   wraps:   dw   0
   delay:   db   10

;***************************************************************************
;***************************************************************************
; New for WDCMON V1.04
;  Needed to move Shadow Vectors into proper area
;***************************************************************************
;***************************************************************************
   SH_vectors:   section
Shadow_VECTORS   SECTION OFFSET $7EFA
               ;65C02 Interrupt Vectors
               ; Common 8 bit Vectors for all CPUs

      dw   badVec      ; $FFFA -  NMIRQ (ALL)
      dw   START      ; $FFFC -  RESET (ALL)
      dw   IRQHandler   ; $FFFE -  IRQBRK (ALL)

           ends


;***************************************************************************

vectors   SECTION OFFSET $FFFA
               ;65C02 Interrupt Vectors
               ; Common 8 bit Vectors for all CPUs

      dw   badVec      ; $FFFA -  NMIRQ (ALL)
      dw   START      ; $FFFC -  RESET (ALL)
      dw   IRQHandler   ; $FFFE -  IRQBRK (ALL)

           ends

           end

_________________
Want to design a PCB for your project? I strongly recommend KiCad. Its free, its multiplatform, and its easy to learn!
Also, I maintain KiCad libraries of Retro Computing and Arduino components you might find useful.


Top
 Profile  
Reply with quote  
PostPosted: Mon Apr 03, 2017 3:46 pm 
Offline
User avatar

Joined: Sun Dec 29, 2002 8:56 pm
Posts: 449
Location: Canada
Having a schematic of the board would help too. Just to see if there's an NMI disable FF hooked up.

_________________
http://www.finitron.ca


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 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: