Reading and writing bytes. Addresses, data, LDSW and UDSW...

For hardware talk only (please avoid ROM dumper stuff)
doragasu
Very interested
Posts: 125
Joined: Tue Oct 09, 2012 8:15 am

Reading and writing bytes. Addresses, data, LDSW and UDSW...

Post by doragasu » Tue Mar 22, 2016 7:15 pm

AFAIK, the 68k at the hardware level, cannot read a single byte: if you want to read a byte, it reads a full 16-bit word, but keeps only the relevant 8 bits (the upper or lower byte). But when writing to the cart, it can write bytes: we have LDSW line to write the lower part (at an odd address) and UDSW line to write the upper part (at an even address). I know that you can read and write bytes the following way (because my WiFi cart works like this):

Code: Select all

TYPE | ADDRESS |  DATA  | [LU]DSW
=====|=========|========|=========
 WR  | bN...N1 | D[0-7] |   LDSW
 RD  | bN...N1 | D[0-7] |   N/A
This works using odd addresses. I'm wondering how should I do this if I want to read and write to an even address... would it be like this?

Code: Select all

TYPE | ADDRESS |  DATA   | [LU]DSW
=====|=========|=========|=========
 WR  | bN...N0 | D[0-7]  |   UDSW
 RD  | bN...N0 | D[8-15] |   N/A
Or maybe like this?

Code: Select all

TYPE | ADDRESS |  DATA   | [LU]DSW
=====|=========|=========|=========
 WR  | bN...N0 | D[8-15] |   UDSW
 RD  | bN...N0 | D[8-15] |   N/A
Or maybe none of these?

User avatar
Sik
Very interested
Posts: 688
Joined: Thu Apr 10, 2008 3:03 pm
Contact:

Re: Reading and writing bytes. Addresses, data, LDSW and UDSW...

Post by Sik » Tue Mar 22, 2016 9:19 pm

Use either of the two signals as if it was an extra address line, then when reading use the same value on both bytes. I don't recall how the 68000 behaves when writing (did it write the same byte twice too? if so you can get away with just an 8-bit bus altogether). Note that this would force you to use only byte accesses though (much like with Z80 RAM), for allowing word accesses too you'll need something more complex.
Sik is pronounced as "seek", not as "sick".

User avatar
HardWareMan
Very interested
Posts: 704
Joined: Sat Dec 15, 2007 7:49 am
Location: Kazakhstan, Pavlodar

Re: Reading and writing bytes. Addresses, data, LDSW and UDSW...

Post by HardWareMan » Fri Mar 25, 2016 12:56 am

Is it real so hard to look into M68K UM?
Image
LDS - Lower Data Strobe: CPU use D0-D7
UDS - Upper Data Strobe: CPU use D8-D15

LWR = LDS | R/W
UWR = UDS | R/W

Any questionas?

doragasu
Very interested
Posts: 125
Joined: Tue Oct 09, 2012 8:15 am

Re: Reading and writing bytes. Addresses, data, LDSW and UDSW...

Post by doragasu » Fri Mar 25, 2016 3:19 pm

HardWareMan wrote:Is it real so hard to look into M68K UM?
Could you please point me to a manual? Searching the net, I can easily find the m68k programmer manual, but it does not deal with hardware, just programming details.

Also there is something that does not match my observations... In the diagram, #LDS is active (low) for odd addresses (A0 = 1) and #UDS is active for even addresses (A0 = 0). But as I wrote here, I have observed (using a logic analyzer) just the opposite: #LDSW is lowered for even addresses, and #UDSW is lowered for odd addresses.
Last edited by doragasu on Fri Mar 25, 2016 8:50 pm, edited 1 time in total.

User avatar
Sik
Very interested
Posts: 688
Joined: Thu Apr 10, 2008 3:03 pm
Contact:

Re: Reading and writing bytes. Addresses, data, LDSW and UDSW...

Post by Sik » Fri Mar 25, 2016 5:22 pm

doragasu wrote:#LDSW is lowered for even addresses, and #UDSW is lowered for even addresses.
:?
Sik is pronounced as "seek", not as "sick".

doragasu
Very interested
Posts: 125
Joined: Tue Oct 09, 2012 8:15 am

Re: Reading and writing bytes. Addresses, data, LDSW and UDSW...

Post by doragasu » Fri Mar 25, 2016 8:50 pm

Sik wrote:
doragasu wrote:#LDSW is lowered for even addresses, and #UDSW is lowered for even addresses.
:?
Edited and corrected :wink:

User avatar
HardWareMan
Very interested
Posts: 704
Joined: Sat Dec 15, 2007 7:49 am
Location: Kazakhstan, Pavlodar

Re: Reading and writing bytes. Addresses, data, LDSW and UDSW...

Post by HardWareMan » Sat Mar 26, 2016 5:06 am

doragasu wrote:Could you please point me to a manual? Searching the net, I can easily find the m68k programmer manual, but it does not deal with hardware, just programming details.
Because you must search M68K User Manual, not M68K Programming Manual.
doragasu wrote:Also there is something that does not match my observations... In the diagram, #LDS is active (low) for odd addresses (A0 = 1) and #UDS is active for even addresses (A0 = 0). But as I wrote here, I have observed (using a logic analyzer) just the opposite: #LDSW is lowered for even addresses, and #UDSW is lowered for odd addresses.
M68K is big endian. And where you find A0?

User avatar
Sik
Very interested
Posts: 688
Joined: Thu Apr 10, 2008 3:03 pm
Contact:

Re: Reading and writing bytes. Addresses, data, LDSW and UDSW...

Post by Sik » Sat Mar 26, 2016 7:28 am

Internal signal (the LSB of whatever address it's trying to access, as it'd appear in the registers).
Sik is pronounced as "seek", not as "sick".

Eke
Very interested
Posts: 821
Joined: Wed Feb 28, 2007 2:57 pm
Contact:

Re: Reading and writing bytes. Addresses, data, LDSW and UDSW...

Post by Eke » Sat Mar 26, 2016 1:47 pm

doragasu wrote: as I wrote here[/url], I have observed (using a logic analyzer) just the opposite: #LDSW is lowered for even addresses, and #UDSW is lowered for odd addresses.
Seems like you are confused, from what you wrote in the post you linked, you actually observed the opposite i.e UDSW being lowered for even addresses, which is indeed correct behavior
doragasu wrote: I was wrongly assuming that when writing to even addresses, #LDSW was active, but it is #UDSW line the one that is lowered! I
Also note that when doing a word write, both signals are asserted, although technically the address is even (A0=0 internally).

Actually, those signals are just strobes that indicate which part of the data bus (low or high) hold valid data, as documented below from the 68k User Manual.
68k_strobe.jpg
68k_strobe.jpg (47.11 KiB) Viewed 3000 times
68k being a BIG Endian CPU, high byte (D8-D15) is stored at even address (ADDR) and low byte (D0-D7) is stored at odd address (ADDR + 1) where ADDR is address on external bus (VA1-VA23).

And to be nitpicking, there aren't any signals named #LDSW or #UDSW, there are #UDS, #LDS and #RW controlled by 68k CPU then #LWR and #UWR which are generated by VDP using 68k signals.

doragasu
Very interested
Posts: 125
Joined: Tue Oct 09, 2012 8:15 am

Re: Reading and writing bytes. Addresses, data, LDSW and UDSW...

Post by doragasu » Sat Mar 26, 2016 2:53 pm

HardWareMan wrote:
doragasu wrote:Could you please point me to a manual? Searching the net, I can easily find the m68k programmer manual, but it does not deal with hardware, just programming details.
Because you must search M68K User Manual, not M68K Programming Manual.
Image

No m68k manuale here (neither on the links below).
doragasu wrote:Also there is something that does not match my observations... In the diagram, #LDS is active (low) for odd addresses (A0 = 1) and #UDS is active for even addresses (A0 = 0). But as I wrote here, I have observed (using a logic analyzer) just the opposite: #LDSW is lowered for even addresses, and #UDSW is lowered for odd addresses.
M68K is big endian. And where you find A0?[/quote]

As Sik wrote, A0 is internal (I suppose that's the reason it has an asterisk on the diagram you posted). It's the bit 0 of the address you write on your code.

doragasu
Very interested
Posts: 125
Joined: Tue Oct 09, 2012 8:15 am

Re: Reading and writing bytes. Addresses, data, LDSW and UDSW...

Post by doragasu » Sat Mar 26, 2016 3:04 pm

Eke wrote:Seems like you are confused, from what you wrote in the post you linked, you actually observed the opposite i.e UDSW being lowered for even addresses, which is indeed correct behavior
You are right, I was confused, and what I observed matches the diagram HardwareMan posted. I'm feeling a bit stupid, as I double checked the thing before posting (looks like both times I checked it wrong). Also the table you posted sums it all.

Thanks all for the info, and sorry for being so dumb.

BTW, did another search using Google instead of DuckDuckGo, and the User Manual appeared on the second entry... DuckDuckGo has still much to improve.

User avatar
Sik
Very interested
Posts: 688
Joined: Thu Apr 10, 2008 3:03 pm
Contact:

Re: Reading and writing bytes. Addresses, data, LDSW and UDSW...

Post by Sik » Sat Mar 26, 2016 4:24 pm

Searching the filenames is easier! =/

M68000PRM.pdf = programmer manual
MC68000UM.pdf = user manual
Sik is pronounced as "seek", not as "sick".

User avatar
HardWareMan
Very interested
Posts: 704
Joined: Sat Dec 15, 2007 7:49 am
Location: Kazakhstan, Pavlodar

Re: Reading and writing bytes. Addresses, data, LDSW and UDSW...

Post by HardWareMan » Sun Mar 27, 2016 5:15 am

Sik wrote:Searching the filenames is easier! =/

M68000PRM.pdf = programmer manual
MC68000UM.pdf = user manual
Sure, but you must to know them first, isn't it?

doragasu
Very interested
Posts: 125
Joined: Tue Oct 09, 2012 8:15 am

Re: Reading and writing bytes. Addresses, data, LDSW and UDSW...

Post by doragasu » Sun Mar 27, 2016 8:50 pm

The easiest way is providing the download URL :wink:

It's curious, I repeated searching "M68K User Manual" using Bing, and the manual does neither appear. It looks like only Google hits it...

User avatar
HardWareMan
Very interested
Posts: 704
Joined: Sat Dec 15, 2007 7:49 am
Location: Kazakhstan, Pavlodar

Re: Reading and writing bytes. Addresses, data, LDSW and UDSW...

Post by HardWareMan » Mon Mar 28, 2016 8:00 am

doragasu wrote:The easiest way is providing the download URL :wink:

It's curious, I repeated searching "M68K User Manual" using Bing, and the manual does neither appear. It looks like only Google hits it...
There are no M68K CPU. There is only 68000 or M68000 CPUs.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest