Dropcheck Posted November 3, 2019 Share Posted November 3, 2019 I have a .bin file I am trying to deconstruct into somewhat understandable and readable assembly language. It's code for the 6500/1 series of cpus. These cpus combine the 6502 with 2K of ROM, 64byte of RAM and 32 bi-directional TTL compatible I/0 lines(4 ports) among other goodies. All addressing is internal. The four 8-bit I/O ports are for want of a better designation PORTA, PORTB, PORTC and PORTD. There are also four 8-bit registers associated with the ports located on page zero(80,81,82,83). My question centers around a series of instructions that are confusing to me. lda #$FF ;Load accumulator with hex value FF sta PORTA ;Store that value in memory location 80(PortA) ldx #$F7 ;Load Index X with hex value F7 stx PORTA ;Store Index X value in memory location 80(PortA) sta PORTA ;Store accumulator value in memory location 80(PortA) I don't get the last two instructions. Why would a programmer load a zero page memory location at 80 with one hex number and then turn around without seeming to use it, clobber the same memory location with a completely different hex number? Quote Link to comment Share on other sites More sharing options...
R0ger Posted November 3, 2019 Share Posted November 3, 2019 Well you said it yourself. If those memory locations are mapped to I/O ports, writing to them means writing to I/O ports. I mean you say 'associated with', so it's not clear, but the code looks just like writing to external chip, let's say POKEY or ANTIC, with memory-mapped registers. Quote Link to comment Share on other sites More sharing options...
Dropcheck Posted November 3, 2019 Author Share Posted November 3, 2019 So essentially the code is simply putting the hex number on the selected port and whatever is connected to that port responds to that number according to its dictates? It's not loading a lo-byte then the high-byte memory address onto the PORTA register? Quote Link to comment Share on other sites More sharing options...
Rybags Posted November 3, 2019 Share Posted November 3, 2019 Have you disassembled the code properly? In the PIA sense, PORTA also serves as it's own data direction register which looks somewhat like what's going on there. Generally you write to PACTL to hit the bitsetting to put PORTA into DDR mode. Then write PORTA with 0 representing what bits will be inputs, and 1 to select outputs. Then write PACTL again to put PORTA back into data mode. Then subsequent reads get your inputs, writes perform outputs. Quote Link to comment Share on other sites More sharing options...
Rybags Posted November 3, 2019 Share Posted November 3, 2019 Thinking more... maybe it does operate differently with sequential writes doing a low then high byte. Or first byte selecting which bits for input/output then the second one writing the actual data. Quote Link to comment Share on other sites More sharing options...
Dropcheck Posted November 3, 2019 Author Share Posted November 3, 2019 (edited) Using a .bin dump of internal code from the 40pin CPU in the Supra Microstuffer printer buffer device, I used the old program Dis6502 to come up with the disassembly. First I entered all the known equ for the 6500/1 chips, then deleted all the other default equ. I then loaded up the raw .bin file and set the code start at $800. I've been slowly going through the resulting disassembly, trying to comment and more importantly understand what the code is doing. Since these cpus are no longer made and they were masked at the factory I've been trying to come up with an alternative chip/software combination. The code in question comes rather early in the setup portion. SupraMicroStuffer.zip Edited November 3, 2019 by Dropcheck further info Quote Link to comment Share on other sites More sharing options...
R0ger Posted November 3, 2019 Share Posted November 3, 2019 34 minutes ago, Dropcheck said: So essentially the code is simply putting the hex number on the selected port and whatever is connected to that port responds to that number according to its dictates? It's not loading a lo-byte then the high-byte memory address onto the PORTA register? The code is simple and clear. It writes 3 numbers to that address, and you mention, there is hardware register associated with it, so I assume it writes to that register. Now how the hardware connected to this register interprets those 3 numbers, is outside scope of the code. Quote Link to comment Share on other sites More sharing options...
Dropcheck Posted November 3, 2019 Author Share Posted November 3, 2019 2 minutes ago, R0ger said: The code is simple and clear. It writes 3 numbers to that address, and you mention, there is hardware register associated with it, so I assume it writes to that register. Now how the hardware connected to this register interprets those 3 numbers, is outside scope of the code. Thank you. ? Quote Link to comment Share on other sites More sharing options...
Rybags Posted November 3, 2019 Share Posted November 3, 2019 Should have realized this immediately. It might seem wrong but it's quickly clearing then resetting a bit, so it's probably a clock or strobe function and perfectly OK. Do you have accompanying writes to another port that occur just before? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.