Writing to two memory address sequentially

JMP $FCE2
jrubin
Member
Member
Posts: 59
Joined: Sun Jun 29, 2014 8:00 pm
Location: Florida
Contact:

Re: Writing to two memory address sequentially

Post by jrubin »

Heres the updated code...... Im having a new problem at label GET55.

It is not reliably moving the code into A from $FB. I have no idea why.

Full code shown below, here is an excerpt of GET55

Code: Select all

GET55:
     ldy #$00
     jsr TESTACIA5
     ldy #$55
     jsr TESTACIA5
     ldx #$00
     jsr GETEEPROM
     lda $FB          : GET THE VALUE FROM FB 
     and #01         ; GET VFO A OR B         BIT0
     sta $C002      ; STORE IT IN C000
     lda $FB
     and #80         ; GET MEM OR VFO       BIT7
     sta $C003      ; STORE IT IN C001
     rts



Code: Select all

SENDBYTE:

;;;;;;;;;;;;;;;;;;;;;;;;;;;;SPECIAL CODE AREA TO SEND PACKET IN A LOOP FROM THE DATA
;;;;;;;;;;;;;;;;;;;;;;;;;;;;AT THE BOTTOM AT PTT:


     jsr GET55
     rts

TESTACIA5:
     lda   status
     and   #%00010000
     beq   TESTACIA5      ;wait for bit #4 to be set
     sty   data          ;give byte to ACIA
     rts

GET55:
     ldy #$00
     jsr TESTACIA5
     ldy #$55
     jsr TESTACIA5
     ldx #$00
     jsr GETEEPROM
     lda $FB          : GET THE VALUE FROM FB 
     and #01         ; GET VFO A OR B         BIT0
     sta $C002      ; STORE IT IN C000
     lda $FB
     and #80         ; GET MEM OR VFO       BIT7
     sta $C003      ; STORE IT IN C001
     rts

     
GETEEPROM:     
     lda GETEEPROMTAIL,x  
     tay
     jsr TESTACIA5
     inx
     cpx #$03
     bne GETEEPROM
     jsr RECVBYTE 
     rts
 
RECVBYTE:                 ;fetches a byte from the receive buffer.                      
      lda   recvcount     ;count of bytes in receive buffer
      beq   RECVEMPTY     ;buffer is empty, indicate to caller

      ldy   rhead         ;pointer to start of buffer
      lda   (rbuff),y     ;fetch byte out of buffer into 'A' register
      sta   $FB     ;location of getbyte is $c008
  ;    jsr $ffd2
      inc   rhead         ;point to next slot in buffer
      dec   recvcount     ;and add one to count of bytes in buffer

       ldy   rhead         ;pointer to start of buffer  
      lda   (rbuff),y     ;fetch byte out of buffer into 'A' register
      sta   $FC     ;location of getbyte is $c008
 ;     jsr $ffd2
      inc   rhead         ;point to next slot in buffer
      dec   recvcount     ;and add one to count of bytes in buffer
      clc                 ;indicate that we have a character
      rts                 ;return to your program


RECVEMPTY:
      sec                 ;or whatever flag your program uses to tell that the receive buffer was empty
      rts                 ;and return  

          
TERMINAL:
      jsr   RECVBYTE      ;see if there is a received byte in the recv buffer
      bcs   TERMTRYSEND   ;if not, continue      
;      jsr   $FFD2         ;if received byte, print it to the screen (CHROUT)


TERMTRYSEND:


jsr   $FFE4         ;try to get a character from the keyboard (GETIN)
      cmp   #$00          ;was there a keystroke available?
      beq   TERMINAL      ;no--go back to top of polling loop
;      cmp   #$03          ;check for STOP key
;      beq   TERMEXIT      ;  exit if pressed
;      jsr $FFD2
      jsr   SENDBYTE      ;have char--put it into the transmit buffer and then
      jmp   TERMINAL      ;  go back to top of polling loop

TRANSMIT_BUFFER = *+0
RECEIVE_BUFFER  = *+256

    
GETEEPROMTAIL:      
.byte $00,$00,$BB    


dudz
Member
Member
Posts: 140
Joined: Tue Jun 17, 2014 5:40 am
Contact:

Re: Writing to two memory address sequentially

Post by dudz »

Code: Select all

TRANSMIT_BUFFER = *+0
RECEIVE_BUFFER  = *+256
  
GETEEPROMTAIL:      
.byte $00,$00,$BB
see previous post
jrubin
Member
Member
Posts: 59
Joined: Sun Jun 29, 2014 8:00 pm
Location: Florida
Contact:

Re: Writing to two memory address sequentially

Post by jrubin »

I already have the data, the serial communication works fine.

its stored in FB and FC.
jrubin
Member
Member
Posts: 59
Joined: Sun Jun 29, 2014 8:00 pm
Location: Florida
Contact:

Re: Writing to two memory address sequentially

Post by jrubin »

the transmit receive buffer was moved to the bottom of the program. It still doesnt explain why it has to cycle twice to load FB into A
jrubin
Member
Member
Posts: 59
Joined: Sun Jun 29, 2014 8:00 pm
Location: Florida
Contact:

Re: Writing to two memory address sequentially

Post by jrubin »

Something's foul. each time I cycle the program I exhibit the following values

Code: Select all

(C:$c090) r
  ADDR AC XR YR SP 00 01 NV-BDIZC LIN CYC  STOPWATCH
.;f142 00 03 01 f4 2f 37 00100011 012 001    8531186
(C:$c090) 
(C:$2101) r
  ADDR AC XR YR SP 00 01 NV-BDIZC LIN CYC  STOPWATCH
.;2101 00 03 03 f6 2f 37 00100011 012 000   12172420
(C:$2101) 
(C:$20f5) r
  ADDR AC XR YR SP 00 01 NV-BDIZC LIN CYC  STOPWATCH
.;20f5 00 03 05 f4 2f 37 00100011 012 001   16138461
(C:$20f5) 
(C:$20f7) r
  ADDR AC XR YR SP 00 01 NV-BDIZC LIN CYC  STOPWATCH
.;20f7 00 03 07 f6 2f 37 00100011 012 001   21044726
(C:$20f7) 
(C:$f13e) r
  ADDR AC XR YR SP 00 01 NV-BDIZC LIN CYC  STOPWATCH
.;f13e 00 03 09 f4 2f 37 00100011 012 004   25335574
(C:$f13e) 
jrubin
Member
Member
Posts: 59
Joined: Sun Jun 29, 2014 8:00 pm
Location: Florida
Contact:

Re: Writing to two memory address sequentially

Post by jrubin »

Here it is in its entirety, thus far. GET55 still loaded the two bytes into FB and FC correctly, but required two cycles of the program to move it to C009 and the AND masked values to C000 and C001. I cant see why a simple lda, and, & sta wont work within the program , I know the issue is at lda $FB because if I do something like lda#$81 it works fine. Sure would be nice if i could get past this, after this I can proceed in loading all of the values into their correct locations.

Also I realise im using a keystroke to cycle this. If anyone knows how to perhaps with an interrupt have this run every two seconds that would be awesome

dudz is getting impatient with me, i havent done this in 25 years

im officially exhausted

Code: Select all

base  	    =    $DE00    ;base ACIA address
data  	    =    base
status   	    =    base+1
command    =    base+2
control  	    =    base+3
rhead    	    =   $A7      ;pointer to next byte to be removed from receive buffer
rtail    	    =   $A8      ;pointer to location to store next byte received
rbuff     	    =   $F7      ;receive-buffer vector
thead   	    =   $A9      ;pointer to next byte to be removed from transmit buffer
ttail    	    =   $AA      ;pointer to location to store next byte in transmit buffer
tbuff  	    =   $F9      ;transmit buffer
xmitcount 	    =   $AB      ;count of bytes remaining in transmit (xmit) buffer
recvcount     =   $B4      ;count of bytes remaining in receive buffer
errors           =   $B5      ;DSR, DCD, and received data errors information
xmiton   	    =   $B6      ;storage location for model of command register which turn both receive and transmit interrupts on
xmitoff  	    =   $BD      ;storage location for model of command register which turns the receive interrupt on and the
                      		      ;transmit interrupts off
NMINV     =   $0318    ;Commodore Non-Maskable Interrupt vector
OLDVEC    =   $03fe    ;innocuous location to store old NMI vector (two bytes)

;Call the following code as part of system initialization.
;clear all buffer pointers, buffer counters, and errors location
      *=  $2000      ;change to suit your needs
      lda   #$00
      sta   rhead
      sta   rtail
      sta   thead
      sta   ttail
      sta   xmitcount
      sta   recvcount
      sta   errors

;store the addresses of the buffers in the zero-page vectors
      lda   #<TRANSMIT_BUFFER
      sta   tbuff
      lda   #>TRANSMIT_BUFFER
      sta   tbuff + 1
      lda   #<RECEIVE_BUFFER
      sta   rbuff
      lda   #>RECEIVE_BUFFER
      sta   rbuff + 1
;            sta   rbuff 
      
;load control values     
      lda   #%10011100 ; 9600 baud
; lda   #%10011010  ; 4800 baud
      sta   control
;load command values      
      lda   #%00001001
      sta   command
      
      sta   xmitoff     ;store as a model for future use
      and   #%11110000 ;mask off interrupt bits, keep parity/echo bits
      ora   #%00000101 ;and set bits to enable both transmit and receive interrupts
      sta   xmiton      ;store also for future use      
      
NEWVEC:
      sei               ;A stray IRQ shouldnt cause any problems while were changing the NMI vector     
      lda   NMINV      ;get low byte of present vector
      sta   OLDVEC     ;and store it for future use
      lda   NMINV+1    ;do the same
      sta   OLDVEC+1   ;with the high byte
                       ;come here from the SEI if you're not saving
                       ;the old vector
      lda   #<NEWNMI   ;get low byte of new NMI routine
      sta   NMINV      ;store in vector
      lda   #>NEWNMI   ;and do the same with
      sta   NMINV+1    ;the high byte
      cli              ;allow IRQs again     
      
       jmp   TERMINAL   ;go to the example dumb-terminal subroutine  
      
NEWNMI:
     sei              ;the Kernal routine already does this before jumping
                       ;through the NMINV vector
      pha              ;save A register
      txa
      pha              ;save X register
      tya
      pha              ;save Y register       
      
      
      lda   status

;Now prevent any more NMIs from the ACIA

      ldx   #%00000011   ;disable all interrupts, bring RTS inactive, and leave DTR active
      stx   command       ;send to ACIA-- code at end of interrupt handler will re-enable interrupts

;Store the status-register data only if needed for error checking.
;The next received byte will clear the error flags.

      sta   errors        ;only if error checking implemented
      and   #%00011000   ;mask out all but transmit and receive interrupt indicators
      beq   TEST_DCD_DSR

RECEIVE:                  ;process received byte
      and   #%00001000   ;mask all but bit #3
      beq   XMITCHAR      ;if not set, no received byte - if youre using a transmit buffer, the interrupt must have been
                                       ;caused by transmit.  So, branch to handle.
      lda   data          ;get received byte
      ldy   rtail         ;index to buffer
      sta   (rbuff),y     ;and store it
      inc   rtail         ;move index to next slot
      inc   recvcount     ;increment count of bytes in receive buffer (if used by your program)  
       
XMIT:
      lda   xmitcount     ;if not zero, characters still in buffer fall through to process xmit buffer
      beq   TEST_DCD_DSR  ;no characters in buffer-- go to next check
       
XMITBYTE:
      lda   status        ;test bit #4
      and   #%00010000
      beq   TEST_DCD_DSR  ;skip if transmitter still busy

XMITCHAR:                 ;transmit a character
      ldy   thead
      lda   (tbuff),y     ;get character at head of buffer
      sta   data          ;place in ACIA for transmit

                          ;point to next character in buffer
      inc   thead         ;and store new index
      dec   xmitcount     ;subtract one from count of bytes in xmit buffer
      lda   xmitcount
      beq   TEST_DCD_DSR 
       
      lda   xmiton        ;model to leave both interrupts enabled
                                ;If you don't use DCD or DSR
      bne   NMICOMMAND    ;branch always to store model in command register   

TEST_DCD_DSR:
       
NMIEXIT:
      lda   xmitoff       ;load model to turn transmit interrupts off
;and this line sets the interrupt status to whatever is in the 'A' register.

NMICOMMAND:
      sta   command 
      
EXITINT:                  ;restore things and exit
      pla                 ;restore 'Y' register
      tay
      pla                 ;restore 'X' register
      tax
      pla                 ;restore 'A' register      
      
;If you want to continue processing the interrupt with the Kernal routines,
      jmp   (OLDVEC)      ;continue processing interrupt with Kernal handler      
;      
;NOTHING:
;      lda   #$00     ;or whatever flag your program uses to tell that the byte was not transmitted
;      rts                 ;and return  
      
SENDBYTE:

;;;;;;;;;;;;;;;;;;;;;;;;;;;;SPECIAL CODE AREA TO SEND PACKET IN A LOOP FROM THE DATA
;;;;;;;;;;;;;;;;;;;;;;;;;;;;AT RADIO ADDRESS 0055:

     jsr GET55
     rts

TESTACIA5:
     lda   status
     and   #%00010000
     beq   TESTACIA5      ;wait for bit #4 to be set
     sty     data                  ;give byte to ACIA
     rts

GET55:
     ldy #$00
     jsr TESTACIA5
     ldy #$55
     jsr TESTACIA5
     ldx #$00
     jsr GETEEPROM     
     lda $FB          ; GET THE VALUE FROM FB 
     sta $C009
     and #$01         ; GET VFO A OR B         BIT0
     sta $C000      ; STORE IT IN C000
     lda $FB
     and #$80         ; GET MEM OR VFO       BIT7
     sta $C001      ; STORE IT IN C001     
     rts
     
GETEEPROM:     
     lda GETEEPROMTAIL,x  
     tay
     jsr TESTACIA5
     inx
     cpx #$03
     bne GETEEPROM
     jsr RECVBYTE 
     rts
 
RECVBYTE:                 ;fetches a byte from the receive buffer.                      
      lda   recvcount     ;count of bytes in receive buffer
      beq   RECVEMPTY     ;buffer is empty, indicate to caller

      ldy   rhead         ;pointer to start of buffer
      lda   (rbuff),y     ;fetch byte out of buffer into 'A' register
      sta   $FB     ;location of getbyte is $FB
  ;    jsr $ffd2
      inc   rhead         ;point to next slot in buffer
      dec   recvcount     ;and add one to count of bytes in buffer

       ldy   rhead         ;pointer to start of buffer  
      lda   (rbuff),y     ;fetch byte out of buffer into 'A' register
      sta   $FC     ;location of getbyte is $FC
 ;     jsr $ffd2
      inc   rhead         ;point to next slot in buffer
      dec   recvcount     ;and add one to count of bytes in buffer
      clc                 ;indicate that we have a character
    
      ldy #$00  
      rts                 ;return to your program


RECVEMPTY:
      sec                 ;or whatever flag your program uses to tell that the receive buffer was empty
      rts                 ;and return  

          
TERMINAL:
      jsr   RECVBYTE      ;see if there is a received byte in the recv buffer
      bcs   TERMTRYSEND   ;if not, continue      
;      jsr   $FFD2         ;if received byte, print it to the screen (CHROUT)


TERMTRYSEND:


jsr   $FFE4         ;try to get a character from the keyboard (GETIN)
      cmp   #$00          ;was there a keystroke available?
      beq   TERMINAL      ;no--go back to top of polling loop
;      cmp   #$03          ;check for STOP key
;      beq   TERMEXIT      ;  exit if pressed
;      jsr $FFD2
      jsr   SENDBYTE      ;have char--put it into the transmit buffer and then
      jmp   TERMINAL      ;  go back to top of polling loop

GETEEPROMTAIL:      
.byte $00,$00,$BB  

TRANSMIT_BUFFER = *+0
RECEIVE_BUFFER  = *+16

* = * + (2*16) ; move program counter behind RECIEVE_BUFFER
    
  
Post Reply Previous topicNext topic

Who is online

Users browsing this forum: No registered users and 10 guests