6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Fri Sep 20, 2024 9:55 am

All times are UTC




Post new topic Reply to topic  [ 138 posts ]  Go to page Previous  1 ... 5, 6, 7, 8, 9, 10  Next
Author Message
PostPosted: Fri Aug 11, 2017 9:26 pm 
Offline

Joined: Fri Jul 21, 2017 8:16 pm
Posts: 59
Ok! You are right! It doesn't work! ;-)

Before I go to bed - I want to post the latest status:

(These are my first steps. Please don't hit me!) and the OPHIS Assembler doesn't know STZ BRA PLX ...

Code:
.org $8600
   .alias ACIA $4080
   .alias ACIA_DATA ACIA+0
   .alias ACIA_STAT ACIA+1
   .alias ACIA_COMM ACIA+2
   .alias ACIA_CTRL ACIA+3
   .alias VIA $4010
   .alias VIA_DATA_B VIA+$0
   .alias VIA_DATA_A VIA+$1
   .alias VIA_DDR_B VIA+$2
   .alias VIA_DDR_A VIA+$3
   .alias VIA_T1CL VIA+$4
   .alias VIA_T1CH VIA+$5
   .alias VIA_T1LL VIA+$6
   .alias VIA_T1LH VIA+$7
   .alias VIA_T2CL VIA+$8
   .alias VIA_T2CH VIA+$9
   .alias VIA_SR VIA+$A
   .alias VIA_ACR VIA+$B
   .alias VIA_PCR VIA+$C
   .alias VIA_IFR VIA+$D
   .alias VIA_IER VIA+$E
   .alias VIA_ORA VIA+$F ; without handshake
   
SET_STACK:     LDX     #$FF         ;reset stack
              TXS

SET_ACIA:      LDA    #$00         ;reset status ACIA
              STA  ACIA_STAT     
              LDA  ACIA_DATA         ;unclear if neccessary
              LDA  #%00011110         ;set 9600 N 1
              STA  ACIA_CTRL
              LDA  #%00001011         ;set ACIA no parity no interrupt
              STA  ACIA_COMM   

SET_VIA:      LDA  #%11111111   
            STA    VIA_DDR_B 
            STA    VIA_DDR_A   
              LDA  #%00000000
              STA  VIA_ACR
              STA  VIA_PCR
              STA  VIA_IER
              STA    VIA_IFR


START:      ldx #$00
         


OUTPUT:    lda hello, x
         
         sta ACIA_DATA
         sta VIA_DATA_A
         pha
         stx $0001
         jsr DELAY
         ldx $0001
         pla
         beq INPUT
         inx
         bne OUTPUT


INPUT:      lda ACIA_DATA
         sta VIA_DATA_A
         beq INPUT            ; if no data try again
               

ECHO:      sta ACIA_DATA
         sta VIA_DATA_A
         
         lda #$00   
         beq   START

Delay:         LDX #$11
            LDY #$FF
StartOuterLoop: DEY
StartInnerLoop:   DEX
            TXA
            BNE StartInnerLoop
            TYA
            BNE StartOuterLoop
            RTS




hello:  .byte "Input Please:", 0



I have used this long delay to see whats going on.
My terminal writes garbage:


Attachments:
screenshot2.jpeg
screenshot2.jpeg [ 24.79 KiB | Viewed 4059 times ]
Top
 Profile  
Reply with quote  
PostPosted: Fri Aug 11, 2017 11:41 pm 
Offline

Joined: Tue Jun 08, 2004 11:51 pm
Posts: 213
Almost.
The way you wait for an input is not to read the input buffer.
I thought that was clear before.
You read the status register. When bit 3 is a one, that means
there is something there to read. Then you read the input data.
the buffer doesn't clear because you read it. The status bit
does clear when you read it when you read the input buffer.
I also prefer to always use 2 stop bits. Some com programs
don't work well at updating the screen if you use one stop bit.

You might find you loops easier to calculate if you do:
Code:
LDY #$11
LDX #0
L0:
  L1:
    DEX
  BNE L1
DEY
BNE L0

This is because the first inner loop, you only loop 255 times while
the rest you loop 256 times. Using 0 to start rather than $FF makes
the inner loop always do 256 times. It is easier to calculate.
Putting the DEY and the DEX in front of the branch means
you don't have to TXA or TYA to do a branch test.
If you need to adjust, you can add NOPs to the inner or outer loops.
Dwight


Top
 Profile  
Reply with quote  
PostPosted: Sat Aug 12, 2017 6:47 am 
Offline

Joined: Fri Jul 21, 2017 8:16 pm
Posts: 59
I made some progress.
While waiting for input I read the status register and output the content to some LED's (VIA_DATA_A)
bit 4 is always high
When I press a key the bit 3 goes high.
Then after lda from ACIA_DATA - bit 3 goes low again.
Now its time to study the manual again to see what this means :o :idea:

Code:
lda ACIA_STAT
         sta VIA_DATA_A
         jsr Delay
         jsr Delay
         jsr Delay
         lda ACIA_DATA
         sta VIA_DATA_A
         jsr Delay
         jsr Delay
         jsr Delay
         CMP 'Q
         bne INPUT


Top
 Profile  
Reply with quote  
PostPosted: Sat Aug 12, 2017 9:04 am 
Offline

Joined: Mon Mar 25, 2013 9:26 pm
Posts: 183
Location: Germany
Quote:
and the OPHIS Assembler doesn't know STZ BRA PLX ...


I'm quite sure that Ophis supports the full set of all 6502 and 65C02 instructions. But you need to set the "-c" commandline parameter to tell Ophis to use the 65C02 instruction set.

Mario.

_________________
How should I know what I think, until I hear what I've said.


Top
 Profile  
Reply with quote  
PostPosted: Sat Aug 12, 2017 11:47 am 
Offline

Joined: Fri Jul 21, 2017 8:16 pm
Posts: 59
Ophis and 65C02:
Thanks Mario!

Issues Serial Communication:
By the way: A lot of problems I had with the serial transfer was caused by using the USB ports for Arduino EEPROMing and for serial communication. Although I used different USB ports.
After restarting the Mac the serial communication worked fine. But as soon as I have used the Arduino the program the EEPROM the communication was disturbed. Closing the Arduino app didn't help. Only restarting the Mac. Maybe tehre is a driver still loaded. But I can not unload or unbind it.

Question Code:
Why does the program still branch if I enter "Q". Subroutine DELAY doesn't affect Accumulator.
So Comparing 'Q with Accumulator should result in Zero flag and BNE should not branch.


Code:

INPUT:         lda ACIA_STAT
            sta VIA_DATA_A
            and #%00001000         ; check bit3 (Receiver Data Register Full?)
            beq INPUT            ; branch if not set
            jsr Delay
            jsr Delay
            jsr Delay
            lda ACIA_DATA
            sta VIA_DATA_A
            sta ACIA_DATA
            jsr Delay
            jsr Delay
            jsr Delay
            cmp 'Q
            bne INPUT            ; if "Q" exit INPUT and back to START
               
         
            lda #$00   
            beq   START




Top
 Profile  
Reply with quote  
PostPosted: Sat Aug 12, 2017 11:53 am 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10938
Location: England
Not sure of the syntax, but possibly you mean to compare with the literal:
cmp #'Q

(Otherwise you are comparing with a zero page location)


Top
 Profile  
Reply with quote  
PostPosted: Sat Aug 12, 2017 12:08 pm 
Offline

Joined: Fri Jul 21, 2017 8:16 pm
Posts: 59
changed code to

Code:
cmp #'Q
            bne INPUT      


still branches.

According to the LED's the code is $51 after pressing "Q"
Maybe I should compare against this Hex value.


Top
 Profile  
Reply with quote  
PostPosted: Sat Aug 12, 2017 12:14 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10938
Location: England
It's not a question of Q vs q is it?

What does Delay look like?

Edit: and what about start? Does that start again? In which case, would you know if your test is passing or failing?


Top
 Profile  
Reply with quote  
PostPosted: Sat Aug 12, 2017 12:16 pm 
Offline

Joined: Fri Jul 21, 2017 8:16 pm
Posts: 59
yes! This works!
Code:
cmp #$51
            bne INPUT   


Top
 Profile  
Reply with quote  
PostPosted: Sat Aug 12, 2017 12:17 pm 
Offline

Joined: Fri Jul 21, 2017 8:16 pm
Posts: 59
Code:
START:         
            ldx #$00         

OUTPUT:       
            lda STRING, x
            CMP #$00
            beq INPUT            ; if end of null terminated byte
            sta ACIA_DATA
            sta VIA_DATA_A
            stx $0001
            jsr DELAY
            ldx $0001
            inx
            bne OUTPUT            ; if x > $FF

INPUT:         
            lda ACIA_STAT
            sta VIA_DATA_A
            and #%00001000         ; check bit3 (Receiver Data Register Full?)
            beq INPUT            ; branch if not set
            jsr Delay
            jsr Delay
            jsr Delay
            lda ACIA_DATA
            sta VIA_DATA_A
            sta ACIA_DATA
            jsr Delay
            jsr Delay
            jsr Delay
            cmp #$51
            bne INPUT            ; if no "Q" try again               
            lda #$00   
            beq   START

Delay:         
            LDY #$FF
            LDX #$00
            L0:
                 L1:
                   DEX
                 BNE L1
            DEY
            BNE L0
            RTS

STRING:  .byte "Input Please:", 0


Last edited by nei02 on Sat Aug 12, 2017 12:27 pm, edited 1 time in total.

Top
 Profile  
Reply with quote  
PostPosted: Sat Aug 12, 2017 12:19 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10938
Location: England
That's good! So 'Q means something different.


Top
 Profile  
Reply with quote  
PostPosted: Sat Aug 12, 2017 12:59 pm 
Offline

Joined: Fri Jul 21, 2017 8:16 pm
Posts: 59
This is the current status. I will optimise the ground connection and the write control cables.
For me it is a learning computer. I know it is not optimal.

I am now thinking if the next step could be to enter a little program via terminal which will be stored and executed in RAM.

Quote:
Greetings
Prompt "Please enter 1st line of code"
Load Input in address 0000
Prompt "Please enter 2nd line of code"
Load Input in address 0001
...
If Input = Q then exit input
Prompt: "Press P to start the program"
If Input = "P" then jump to 0000







Attachments:
IMG_1168.JPG
IMG_1168.JPG [ 2.88 MiB | Viewed 4026 times ]
Top
 Profile  
Reply with quote  
PostPosted: Sat Aug 12, 2017 3:10 pm 
Offline

Joined: Tue Jun 08, 2004 11:51 pm
Posts: 213
There is only one bit difference between upper and lower case.
You can use a 'or' mask or 'and' mask to change that bit. That
way your program will be case insensitive. That is a lot handier.
Do be careful to make sure it is a letter first and not a number.
How are you going to enter values? Most like Hex but it requires
converting to a byte value. It could be in binary for a start.
Also you'll need a way to error out and reset the address to the
desired location.
Tinker Dwight


Top
 Profile  
Reply with quote  
PostPosted: Sat Aug 12, 2017 7:11 pm 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8510
Location: Southern California
I'm not familiar with Ophis. Does there need to be a closing quote mark after the Q? Will it think it's a label or something else without the closing quote mark, instead of the ASCII value for Q?

_________________
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: Mon Aug 14, 2017 8:37 am 
Offline

Joined: Mon Mar 25, 2013 9:26 pm
Posts: 183
Location: Germany
Not sure what version of Ophis you're using, but
Code:
CMP #'Q

works fine for me.

Code:
...
        LDA K_BUFFER                        ; Get length
        CMP #1                        ; Is it 1?
        BNE ATryImm
        LDA K_BUFFER+1                      ; Get first char of operand
        JSR ToUpper
        CMP #'A                      ; Is it 'A?
        BNE ATryImm
        LDA #AM_ACCUMULATOR           ; Yes, is is accumulator mode
        STA AM                        ; Save it
        JMP GenerateCode
...


But it only works with letters, not with other characters.

Mario.

_________________
How should I know what I think, until I hear what I've said.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 138 posts ]  Go to page Previous  1 ... 5, 6, 7, 8, 9, 10  Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 81 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:  
cron