6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Fri Sep 20, 2024 5:40 pm

All times are UTC




Post new topic Reply to topic  [ 11 posts ] 
Author Message
PostPosted: Thu Oct 01, 2020 3:43 pm 
Offline

Joined: Sat Apr 11, 2020 7:28 pm
Posts: 344
Hi. I'm trying to get a simple routine to print the current time in the screen, using the W65C265SXB-like computer.

My code is:

Code:
.cpu "65816"
.xl

*= $1100

SEI
CLC
XCE
REP #$30
SEP #$20
LDX #$1130
LDA #$00
JSR $E057 ; This subroutine reads the time and stores it as ASCII where Xreg is pointed to ($1130 in this case)
JSR $E04E ; This subroutine reads a string stored where Xreg is pointed to and prints it to the console (COM3 in my case).
brk


Well... the results are either:
  • does nothing
  • freezes the board

What am I doing wroing? This must be something of the most basic stuff that I'm missing. This is the very same SBC where the SXB hacker and ehBasic runs flawessly, so it's my wrong doing for sure.

Thanks.


Top
 Profile  
Reply with quote  
PostPosted: Thu Oct 01, 2020 5:28 pm 
Offline
User avatar

Joined: Fri Dec 11, 2009 3:50 pm
Posts: 3367
Location: Ontario, Canada
I'm certainly no expert on the SXB. But certainly the stack pointer needs to get initialized at some point. Was that already done before your code gets run?

-- 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 Oct 01, 2020 5:48 pm 
Offline

Joined: Sat Apr 11, 2020 7:28 pm
Posts: 344
Dr Jefyll wrote:
I'm certainly no expert on the SXB. But certainly the stack pointer needs to get initialized at some point. Was that already done before your code gets run?

-- Jeff


Thanks. That's my code. Everything you think is missing or wrong, is missing or wrong.


Top
 Profile  
Reply with quote  
PostPosted: Thu Oct 01, 2020 7:19 pm 
Offline
User avatar

Joined: Fri Dec 11, 2009 3:50 pm
Posts: 3367
Location: Ontario, Canada
tokafondo wrote:
That's my code.
Yes. But I'm imagining what you do in order to try the code. For example, perhaps the machine monitor program produces a prompt on the console, and you somehow respond to say, "run this." In that case the monitor would already have initialized S, and there's no need for you to do it again.

(You're not burning the code into an (E)EPROM, are you? If so, then maybe the monitor won't have had a chance to initialize S.)

Did you create your code by modifying an example borrowed from elsewhere? If so, does the UN-modified example work? Have you studied the SBX doc? (I haven't, and don't presently have time.)

BTW I notice your SEP instruction partially negates what the REP accomplished.
Code:
REP #$30  ;clears bit 5 and 4 of the P register
SEP #$20  ;sets   bit 5 of the P register


-- 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 Oct 01, 2020 9:17 pm 
Offline
User avatar

Joined: Tue Mar 02, 2004 8:55 am
Posts: 996
Location: Berkshire, UK
These utility routines must be called with JSL and not JSR.

The documentation does not say that read time preserves the registers so you should reload them before the call to put_str.

_________________
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: Thu Oct 01, 2020 9:36 pm 
Offline

Joined: Sat Apr 11, 2020 7:28 pm
Posts: 344
Dr Jefyll wrote:
BTW I notice your SEP instruction partially negates what the REP accomplished.


Thanks. I'm just being sure that I put the Acc and Registers in 16 bit mode, and then only the Acc in 8 bit mode.

I wrote the code by myself, and put that SEI, CLC, XCE instructions because it seems to me it's the standard way to initialize any code in the '816.

BitWise wrote:
These utility routines must be called with JSL and not JSR.


Thanks. Do that implies that Acc and Registrers should be both in 16 bit mode? Or can I JSL everywhere I'd need, no matter the data width?

BitWise wrote:
The documentation does not say that read time preserves the registers so you should reload them before the call to put_str.


I've searched for an opcode for that, and I can't find it. How do I reload the registers before calling put_str?


Top
 Profile  
Reply with quote  
PostPosted: Thu Oct 01, 2020 9:41 pm 
Offline
User avatar

Joined: Tue Mar 02, 2004 8:55 am
Posts: 996
Location: Berkshire, UK
Code:
.cpu "65816"
.xl

*= $1100

SEI
CLC
XCE
REP #$10
SEP #$20
LDX #$1130
LDA #$00
JSL $E057 ; This subroutine reads the time and stores it as ASCII where Xreg is pointed to ($1130 in this case)
LDX #$1130
LDA #$00
JSL $E04E ; This subroutine reads a string stored where Xreg is pointed to and prints it to the console (COM3 in my case).
brk

_________________
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: Thu Oct 01, 2020 10:07 pm 
Offline

Joined: Sat Apr 11, 2020 7:28 pm
Posts: 344
BitWise wrote:
Code:
.cpu "65816"
.xl

*= $1100

SEI
CLC
XCE
REP #$10
SEP #$20
LDX #$1130
LDA #$00
JSL $E057 ; This subroutine reads the time and stores it as ASCII where Xreg is pointed to ($1130 in this case)
LDX #$1130
LDA #$00
JSL $E04E ; This subroutine reads a string stored where Xreg is pointed to and prints it to the console (COM3 in my case).
brk


Thanks. Oh! I see... it was a matter of rewriting the registers the following subroutine expected, because the previous one could have overwritten them, couldn't it?? Thanks, again.


Top
 Profile  
Reply with quote  
PostPosted: Thu Oct 01, 2020 10:10 pm 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8510
Location: Southern California
tokafondo wrote:
I'm just being sure that I put the Acc and Registers in 16 bit mode, and then only the Acc in 8 bit mode.

There's a problem there. The accumulator is one of the main registers. There is one status bit, M, for the accumulator width, and one bit, X, for the index-register width. Most memory operations that do not involve a register will be done according the M bit, for example INC <addr>. But see below:

Quote:
Thanks. Does that implies that Acc and Registrers should be both in 16 bit mode? Or can I JSL everywhere I'd need, no matter the data width?

M and X have to do with data-handling size, not address size. The "L" in "JSL" means the operand, which is an address, is three bytes. It doesn't care what the data size is.

_________________
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: Thu Oct 01, 2020 10:26 pm 
Offline

Joined: Sat Apr 11, 2020 7:28 pm
Posts: 344
Thanks for your help. I should be reading that "65816 programming" book from WDC instead of jumping into the pool while not being able to swim... 8) 8) 8)

It seems there is something also with SEND_CR ($e066) subroutine, because if I put it like this

Code:
[...]
jsl $00e066
jsl $00e066
LDX #$1130
LDA #$0000
JSL $00E04E ; This subroutine reads a string stored where Xreg is pointed to and prints it to the console (COM3 in my case).
jsl $00e066
jsl $00e066
brk


...to force blank line, it doesn't work at all. But If I remove them, the code works, by outputting the time running in the computer.


Top
 Profile  
Reply with quote  
PostPosted: Thu Oct 01, 2020 11:08 pm 
Offline
User avatar

Joined: Tue Mar 02, 2004 8:55 am
Posts: 996
Location: Berkshire, UK
The Mensch monitor only outputs CR for a new line. Your terminal program needs to be configure for automatic new lines (i.e. it generates the line feed for you).

_________________
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  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 11 posts ] 

All times are UTC


Who is online

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