Starting with my first SBC Project, Plans and Confusions
Re: Starting with my first SBC Project, Plans and Confusions
Proxy, you were asked which bytes you were running. If you showed us the output of your assembler, then we'd all know exactly what code the 6502 is running. But with your own assembler, with your own syntax and your own understanding of the 6502 instruction set, there are too many variables.
Re: Starting with my first SBC Project, Plans and Confusions
cjs wrote:
Right. But something to keep in mind is that the Z80 doesn't have indirection through a pointer in memory, so LD A,(1234h) is unequivocal.
cjs wrote:
Ok, I think that you may be using the wrong terminology here and this may be creating some of the confusion. I think you don't mean the zero page addressing mode, but the indirect addressing mode, right? I.e., you're not differentating between (in traditional syntax) LDA $22 assembling to AD 22 00 (absolute) or A5 22 (zero page), both of which are valid assemblies, both of which have the same effect, and neither of which is indirect, right?
LD A, [0x88] assembles to A5 88 (Zero Page)
LD A, (0x88)assembles to AD 88 00 (Absolute)
cjs wrote:
And I am guessing that when you said "ABS address" for LD A,([nnnn]) you really meant indirect address; in your syntax the 6502 absolute addressing mode, which indicates using the contents of a memory location (with no indirection) would be LD A,(nnnn), if I'm reading it right.
and a regular indirect load works by:
1. loading immedaite value
2. use that as address for the Zero Page to load 2 values from
3. use those values as an Absolute address to load the final value into the A Register
all 3 steps together make up the Indirect load, but if you seperate them out like this you can see that it's just 3 other addressing modes working together.
that was my whole point, sorry if it was confusing.
cjs wrote:
Assuming that's correct, I personally think it would be a good idea always to use 6502-style #-prefix for immediate, no prefix for absolute loads from memory (whether zero page or not), and brackets of some sort for indirect, and change your assembler to do that. While introducing LDA ([$1234]) or whatever probably isn't such a big deal, Making LDA ($1234) ambiguous seems destined to lead to problems and debugging when copying code around. (Remember that, though you chose square brackets for indirection, many 6502 assemblers use parentheses instead.)
but as said before i take my time to convert the code before posting parts of it here.
but also as said i could get rid of the [] for Zero page stuff. so the convertion is a bit more linear.
LDA #0x80 -> LD A, 0x80
LDA 0x8000 -> LD A, (0x8000)
LDA (0x80) -> LD A, ((0x80)) or LD A, ([0x80])
cjs wrote:
Yeah, I think you've found an inconsistency there; if instead of JMP we had a LDPC instruction, it would make sense to write LDPC #$8000.
BigEd wrote:
Proxy, you were asked which bytes you were running. If you showed us the output of your assembler, then we'd all know exactly what code the 6502 is running. But with your own assembler, with your own syntax and your own understanding of the 6502 instruction set, there are too many variables.
also you guys are able to just read 6502 Binary?
also i tried to use a Disassembler so i can easily convert my code easily and accurately, but the only one i was able to find only supports the normal 6502 and not the 65C02....
if any of you could recommend a dissassembler for the 65C02, it would be really amazing.
Re: Starting with my first SBC Project, Plans and Confusions
Here's a reliable one: https://www.white-flame.com/wfdis/
Re: Starting with my first SBC Project, Plans and Confusions
Proxy wrote:
now you confused me.
LD A, [0x88] assembles to A5 88 (Zero Page)
LD A, (0x88)assembles to AD 88 00 (Absolute)
LD A, [0x88] assembles to A5 88 (Zero Page)
LD A, (0x88)assembles to AD 88 00 (Absolute)
Typically zero-page addressing is not specified by the programmer in assembly code: the assembler decides whether to use zero-page or absolute depending on whether the address is in the $0000-$00FF range or not. Many assemblers don't even provide a way of explicitly specifying zero-page addressing. (I've just checked both the original MOS programming guide and the WDC 65816 book, and neither specifies one. Nor is one specified in the Apple EDASM or Merlin documentation.) Ways I've seen of explicitly specifying zero page addressing include:
- Macroassembler AS v1.32 and later: "<" prefix, e.g., LDA <addr.
- Macroassembler AS v1.31 and earlier: ".z" suffix, e.g., LDA addr.z.
- ASxxxx: "*" prefix, e.g. LDA *addr.
Quote:
Yes kinda... i was just splitting up the indirect load into it's components to make it more visible why and how the brackets work in there.
and a regular indirect load works by:
1. loading immedaite value
2. use that as address for the Zero Page to load 2 values from....
and a regular indirect load works by:
1. loading immedaite value
2. use that as address for the Zero Page to load 2 values from....
Quote:
but as said before i take my time to convert the code before posting parts of it here.
Quote:
also you guys are able to just read 6502 Binary?
Curt J. Sampson - github.com/0cjs
Re: Starting with my first SBC Project, Plans and Confusions
Chromatix wrote:
Here's a reliable one: https://www.white-flame.com/wfdis/
also one thing i discovered, i can use my assembler to generate annotated binary files.
for example:
Code: Select all
1:0 | e001 | ; START:
1:0 | e001 | a2 ff ; LD X, 0xFF
3:0 | e003 | 9a ; LD SP, X
4:0 | e004 | a9 00 ; LD A, 0x00
6:0 | e006 | aa ; LD X, A
7:0 | e007 | a8 ; LD Y, A
Code: Select all
Reset_Handler ldx #$ff
txs
lda #$00
tax
tayanyways i'll be sure to use this to convert my code.
cjs wrote:
Well, you can do that if you like, meaning that zero-page indirect will be LD A,([0x88]) and absolute indirect will be LD A,((0x88)), but I've never seen a 6502 assembler that uses brackets of any kind for zero-page addressing.
Typically zero-page addressing is not specified by the programmer in assembly code: the assembler decides whether to use zero-page or absolute depending on whether the address is in the $0000-$00FF range or not. Many assemblers don't even provide a way of explicitly specifying zero-page addressing.
Typically zero-page addressing is not specified by the programmer in assembly code: the assembler decides whether to use zero-page or absolute depending on whether the address is in the $0000-$00FF range or not. Many assemblers don't even provide a way of explicitly specifying zero-page addressing.
cjs wrote:
Only for a zero-page indirect load. That's all you have on the 6502, of course, but the 65C02 also has indexed absolute indirect addressing, e.g., LDA ($1234,X) or LDA ($1234),Y (in standard 6502 syntax).
cjs wrote:
Remember, you also need to convert code going back the other way: any time you use code from somewhere else, you need to change LDA ($20),Y to LDA (($20),Y). Were I trying to do that, I'm sure I'd be making subtle errors all over the place, since both are valid, but have different meanings. (The translation is slightly different if you use square brackets for indirection and parentheses for absolute addressing, but the confusion is still there. I think. I'm now confused even about what's confusing!
)
cjs wrote:
Of course! Assemblers and disassemblers are only for the weak!
(And yes, I guess if we all write only machine-language code in this thread that will solve the problem handily.
)
Re: Starting with my first SBC Project, Plans and Confusions
Quote:
Many assemblers don't even provide a way of explicitly specifying zero-page addressing.
A while ago, I proposed a revised syntax to address precisely this problem, which did indeed use brackets in a broadly similar way to some other assembly syntaxes. I adopted [] for long addressing, () for absolute, and {} for Direct Page. I also suggested a method to verify that the M and X bits were being set consistently with what the assembler expected operand sizes to be. But I see no pressing reason to use this new syntax on the 6502 family itself, only on the '816 - and in any case I got distracted while trying to implement it.
Re: Starting with my first SBC Project, Plans and Confusions
Proxy wrote:
cjs wrote:
Only for a zero-page indirect load. That's all you have on the 6502, of course, but the 65C02 also has indexed absolute indirect addressing, e.g., LDA ($1234,X) or LDA ($1234),Y (in standard 6502 syntax).
For first learning about the details of the new 65C02 features, it's probably easier to read Roger Wagner's "Assembly Lines," part 33 (June 1983 Softalk) than it is the data sheet.
Chromatix wrote:
Quote:
Many assemblers don't even provide a way of explicitly specifying zero-page addressing.
Quote:
A while ago, I proposed a revised syntax to address precisely this problem, which did indeed use brackets in a broadly similar way to some other assembly syntaxes. I adopted [] for long addressing, () for absolute, and {} for Direct Page.
Curt J. Sampson - github.com/0cjs
- BigDumbDinosaur
- Posts: 9428
- Joined: 28 May 2009
- Location: Midwestern USA (JB Pritzker’s dystopia)
- Contact:
Re: Starting with my first SBC Project, Plans and Confusions
cjs wrote:
...but the 65C02 also has indexed absolute indirect addressing, e.g., LDA ($1234,X) or LDA ($1234),Y (in standard 6502 syntax).
Quote:
For first learning about the details of the new 65C02 features, it's probably easier to read Roger Wagner's "Assembly Lines," part 33 (June 1983 Softalk) than it is the data sheet.
Chromatix wrote:
And this promptly became a problem when the 65816 arrived, with its DBR and DPR registers which can make any 8-bit address refer to different locations in Direct Page (replacing Zero Page), Absolute, and Long addressing modes (which take up 8, 16 and 24 bits of operand respectively). You really do need to explicitly specify which addressing mode you mean on the '816, but continuing the traditional 6502 assembly syntax does not make that easy.
Turning to DB (data bank register), its content matters when 16-bit addresses are used in load/store instructions. It's important to understand that the '816 always generates 24-bit addresses, regardless of the addressing mode used. If an absolute addressing mode is specified for any load/store instruction DB will be prepended to the effective address to create the 24-bit address that the '816 will emit. DB will be ignored if the addressing mode is direct page, any of the direct page indirect long modes, or any of the absolute long modes. A load immediate instruction is always from the bank in which the instruction is located.
Proxy wrote:
That's why i'm asking the creator of the CustomASM to maybe add an disassembler. so i can easily convert back and forth.
x86? We ain't got no x86. We don't NEED no stinking x86!
Re: Starting with my first SBC Project, Plans and Confusions
BigDumbDinosaur wrote:
Why make it so complicated? You'd be better served by learning and using standard 6502 assembly language instead of trying to somehow make a 6502 program look like a Z80 program. It will also make it a lot easier for most of us to help you as you write software and run into trouble.
like why is exclusive OR called "EOR" instead of "XOR" like literally any person calls it?
and don't come with the "but the first letter of 'Exclusive' is an 'E'" excuse. because then explain "Overflow" being shortent to a "V" instead of an "O" like the first letter is.
or why is Shifting to left "arithmetic" while shifting right is "logical"? it could just be left out without impacting anything.
why not just call them "Shift left" and "Shirt right" to better fit the "Rorate left" and "Rotate right" instruction names for consistency?
which also means that both instructions would then have consistent sounding instruction mnemonics like "ROL" and "ROR", those being "SFL" and "SFR".
another inconsistency is... some of the branch instructions.
half of them use the "branch on x set/clear" while the other half just uses a completely different way of naming them.
why not make them all have a consistent instruction mnemonic?
"Branch on Carry Clear" (BCC)
"Branch on Carry Set" (BCS)
"Branch on Overflow Clear" (BVC)
"Branch on Overflow Set" (BVS)
so these would need to change:
"Branch on Not Equal" (BNE) -> "Branch Zero Clear" (BZC)
"Branch on Equal" (BEQ) -> "Branch Zero Set" (BZS)
"Branch on Plus" (BRP) -> "Branch Negative Clear" (BNC)
"Branch on Minus" (BMI) -> "Branch Negative Set" (BNS)
and lastly the "Test and Reset memory bit" (TRB) and "Reset Memory Bit" (RMB) instructions are the only instructions that uses the word "Reset" instead of "Clear" like the rest of the Instructions do.
so technically they should be called "Test and Clear memory bit" (TCB) and "Clear Memory Bit" (CMB).
and then there also was the minor inconsistency where any Jump and Branch should technically use an immediate value. for example JMP #0x8000 instead of JMP 0x8000
but that kinda gets in the way of labels so i can understand that one i guess.
if those would've been different i would've used the 65c02 syntax from the start. but sadly i'm around 45 years too late to change these names or suggest changing them.
Re: Starting with my first SBC Project, Plans and Confusions
I see your point, but, much like English spelling, this is where we are. It's easy enough to get used to.
For my part, I find quite a barrier swapping between those machines where you say
op src dst
and those where you say
op dst src
But again, just like bilingualism, or driving on the wrong side, it's possible to switch.
For my part, I find quite a barrier swapping between those machines where you say
op src dst
and those where you say
op dst src
But again, just like bilingualism, or driving on the wrong side, it's possible to switch.
- GARTHWILSON
- Forum Moderator
- Posts: 8775
- Joined: 30 Aug 2002
- Location: Southern California
- Contact:
Re: Starting with my first SBC Project, Plans and Confusions
Many assemblers let you make aliases, and may even include some of their own, like BLT for BMI (although BMI is still appropriate for when you load a value or do a bit operation on one and it's not really a matter of comparing or even subtracting). Then you can use either mnemonic, depending on what you're doing.
JMP-immediate would not make sense though, because "immediate" means the operand is the data, not an address. JMP immediate might be kind of like STA immediate which interestingly might sometimes be useful in self-modifying code, making the variable space be the operand of the STA (or STX or STY) instruction, but is otherwise pretty pointless.
JMP-immediate would not make sense though, because "immediate" means the operand is the data, not an address. JMP immediate might be kind of like STA immediate which interestingly might sometimes be useful in self-modifying code, making the variable space be the operand of the STA (or STX or STY) instruction, but is otherwise pretty pointless.
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?
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?
Re: Starting with my first SBC Project, Plans and Confusions
GARTHWILSON wrote:
Many assemblers let you make aliases, and may even include some of their own, like BLT for BMI (although BMI is still appropriate for when you load a value or do a bit operation on one and it's not really a matter of comparing or even subtracting). Then you can use either mnemonic, depending on what you're doing.
JMP-immediate would not make sense though, because "immediate" means the operand is the data, not an address. JMP immediate might be kind of like STA immediate which interestingly might sometimes be useful in self-modifying code, making the variable space be the operand of the STA (or STX or STY) instruction, but is otherwise pretty pointless.
JMP-immediate would not make sense though, because "immediate" means the operand is the data, not an address. JMP immediate might be kind of like STA immediate which interestingly might sometimes be useful in self-modifying code, making the variable space be the operand of the STA (or STX or STY) instruction, but is otherwise pretty pointless.
like CJS said you could imagine a Jump as a "Load PC" instruction, which makes it easier to understand.
LDA #0x80 would load the value "0x80" into the A Register.
and
LDA 0x8000 would use 0x8000 as an address to load a value that then gets loaded into the A Register
so following the same logic
LDPC #0x8000 or JMP #0x8000 would load the immediate value "0x8000" into the PC.
while
LDPC 0x8000 or JMP 0x8000 would use the immediate value "0x8000" as an address to load 2 bytes from which then get loaded into the PC.
now it would be consistent with the other instructions. but i guess jumps are just "special" load instructions that require different ways of refering to thier data compared to any other instruction... it's weird.
.
anyways i think it kinda got out of hand with confusing instruction mnemonics, non-sensical inconsistencies, etc.
(though one last thing, the Dissassembler i was shown before is kinda broken...? sometimes it just randomly stops disassembing, and for some reason it doesn't regonize "0x29" as an Instruction, but it should be an AND immediate)
so, i still need help with the ATF1504. as said i don't have a progammer for it and i don't really know how and which to choose.
plus i'm a bit confused by some of the pins as mentioned last time (around a billion posts ago)
this is around all i have currently for the breakout board.
- GARTHWILSON
- Forum Moderator
- Posts: 8775
- Joined: 30 Aug 2002
- Location: Southern California
- Contact:
Re: Starting with my first SBC Project, Plans and Confusions
I suppose that in the Z80's overloaded "load" lingo, it makes sense. However, none of the processors or languages I've used think of jumps as "loading" anything, at least at the programmer's level. It has always been "jump," "branch," "go to," or higher-level things where a BEGIN, DO, IF, ELSE, etc. took care of the jumping internally.
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?
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?
- BigDumbDinosaur
- Posts: 9428
- Joined: 28 May 2009
- Location: Midwestern USA (JB Pritzker’s dystopia)
- Contact:
Re: Starting with my first SBC Project, Plans and Confusions
Proxy wrote:
like why is exclusive OR called "EOR" instead of "XOR" like literally any person calls it?
and don't come with the "but the first letter of 'Exclusive' is an 'E'" excuse. because then explain "Overflow" being shortent to a "V" instead of an "O" like the first letter is...
and don't come with the "but the first letter of 'Exclusive' is an 'E'" excuse. because then explain "Overflow" being shortent to a "V" instead of an "O" like the first letter is...
You may be interested to know that at one time there was a proposal for an assembly language standard before the IEEE in which the 6800/6500 dialect would have been the prototype. The reason that dialect was considered was due to the uniform use of three-character mnemonics (very easy to encode in an assembler look-up table) and a generally unambiguous addressing mode notation, some of which harks back to the IBM mainframe assembly language of the 1960s. Unfortunately, competitors Intel and Zilog bickered over it and the proposal died.
BTW, at one time, I studied Zilog's horrid assembly language due my employer producing a product whose prototype powered by a Z80. To this day I still can't make heads or tails out of Z80 code. Mandarin Chinese would be less a challenge to understand.
x86? We ain't got no x86. We don't NEED no stinking x86!
- BigDumbDinosaur
- Posts: 9428
- Joined: 28 May 2009
- Location: Midwestern USA (JB Pritzker’s dystopia)
- Contact:
Re: Starting with my first SBC Project, Plans and Confusions
GARTHWILSON wrote:
However, none of the processors or languages I've used think of jumps as "loading" anything, at least at the programmer's level.
x86? We ain't got no x86. We don't NEED no stinking x86!