6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Sat Nov 23, 2024 9:03 pm

All times are UTC




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: wdc compiler help needed
PostPosted: Tue Oct 08, 2019 9:39 am 
Offline
User avatar

Joined: Tue Nov 27, 2018 3:28 pm
Posts: 20
Location: Netherlands..
Hi all, after a long time i decided to pull out my w65c265sxb board again.

i started with the 'led blink' from http://www.mikekohn.net/micro/modern_6502.php.
follow directives, used the naken_asm compiler... and yes result, it works.

not a real fan of the "new" code style from naken_asm
so i decided to translate it to wdc compiler style... and here the troubles begin.

i can compile it, but it will not run on the board...
my guess it's some where in the 8/16 bit of the a/x/y
or in the mode where you switch between 8/16 bit part

where do i go wrong... here is the code...
(ps i just want to run it in 8 bit mode, 65c02 mode that is.. but have no clue how to set 8/16 bit modes in the wdc compiler)

Code:
   
        CHIP   65816
   LONGI   OFF
   LONGA   OFF
   org $1000
   
   start:
   ; Disable interrupts to protect from ROM routines running
   ;sei
   ; Set native mode
   ;clc
   ;xce
   ; Set A to 8-bit
   ;sep #$20
   ; Set X/Y to 16-bit
   ;rep #$10
         
main:
         sei
         cld
        
go:         jsr delay
         jsr on
         jsr delay
         jsr off
         jmp go
         
         ; on led
on:         lda #$00
           sta $df23
         rts
           
           ; led off
off:              lda #$ff
           sta $df23
           rts
           
delay:       ldy #$10
delay1:            ldx #$ff
delay2:            dex
           bne delay2
           dey
           bne delay1
           rts


Top
 Profile  
Reply with quote  
PostPosted: Tue Oct 08, 2019 10:31 am 
Offline
User avatar

Joined: Tue Mar 02, 2004 8:55 am
Posts: 996
Location: Berkshire, UK
The XCE instruction is used to control the processor state. So ..
Code:
  sec
  xce

.. will put the device in 65C02 'emulation' mode and the registers will be 8-bits -- no need for SEP/REP.

I wouldn't use port 7 for I/O. Many of the pins are used to generate chip select signals in the default configuration and will ignore the ports data register.

I tend to connect things to port 5 after ensuring DTR/DSR handshaking is disabled on the Uarts or there are some free pins on port 4 but as some are used for interrupts (e.g. 0 and 1) and ROM bank selection (e.g. 3 and 4) you need to set/clr only the free bits (e.g. 2, 5, 6 and 7) using TSB/TRB.

_________________
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: Tue Oct 08, 2019 6:48 pm 
Offline
User avatar

Joined: Tue Nov 27, 2018 3:28 pm
Posts: 20
Location: Netherlands..
Thx man.. that's the one..!

all works now..

still hard to figure out what to use at the beginning if you start a program.
setting 8/16 bits, native or emulation.. sep/rep, longi, longa, chip ect ect...
good thing there is nice documentation here at 6502.org ....

all restarts are hard in the beginning...


Top
 Profile  
Reply with quote  
PostPosted: Tue Oct 08, 2019 8:39 pm 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8546
Location: Southern California
I know you just copied JoeDavisson's routines, but here are just a few pointers anyway:
Quote:
(ps i just want to run it in 8 bit mode, 65c02 mode that is..

Note that running with 8-bit registers is separate from '02 emulation mode. You can still have 8-bit registers in '816 native mode.

SEI (set interrupt disable bit) and CLD (clear decimal-mode bit) are part of the reset sequence and the interrupt sequence; so there's no need to do them in the reset routine unless you might branch to it from a running program. Also, the '816 comes out of reset in '02-emulation mode; so if that's what you want, there's no need to explicitly tell it.

Rather than LDA #0, STA___, you can just use the STZ (store zero) instruction which is faster, takes less memory, and leaves the accumulator and status register alone.

If you know a register or memory location is 0 and you want to make it $FF (or $FFFF if A is 16-bit), you can just do DEC___ instead of LDA #$FF, STA___. If you use a memory location as a flag and want to set it and all that matters is whether it's 0 or not (and you branch on the Z flag), or you only look at the high bit (and then branch on the N flag), you can also just do DEC as long as you can know you're not decrementing so many time that the value again becomes 0 (in the first case) or positive (in the second case).

Your JMP GO could be replaced with BRA GO for a one-byte savings. The execution time is the same.

JSR's to a one-instruction subroutine can be replaced with a macro that just inlines that one instruction (like STZ $DF23) and then the descriptive macro name accomplishes the purpose of being clear about what you're doing, and the JSR/RTS overhead is eliminated.

Almost none of the 6502 primer is specifically about the '816, but you should find its programming tips page helpful anyway, at http://wilsonminesco.com/6502primer/PgmTips.html .

_________________
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  
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 62 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: