Page 1 of 1

6809 opcode missmatch...

Posted: Fri Sep 20, 2013 9:53 pm
by jedie
This opcode line:

Code: Select all

 | 60    0096 | NEG         | INDEXED      |   6   |   2   | uaaaa |
says address mode "indexed"... Thinks that's right.
But in http://www.maddes.net/m6809pm/appendix_a.htm#appA stands only Inherent, Extended, Direct

Maybe the error is in the origin Reference?

Re: 6809 opcode missmatch...

Posted: Fri Sep 20, 2013 10:05 pm
by sixxie
Yes, error in the doc. NEG has an indexed form.

Re: 6809 opcode missmatch...

Posted: Fri Sep 20, 2013 11:41 pm
by Alastair
If you don't have a copy of the "MC6809 Microprocessor Instruction Set Summary" card (where it's shown as "60 NEG INDEXED 6 2") you can download a copy from the forum.

Re: 6809 opcode missmatch...

Posted: Sun Sep 22, 2013 10:18 am
by jedie
Alastair wrote:If you don't have a copy of the "MC6809 Microprocessor Instruction Set Summary" card (where it's shown as "60 NEG INDEXED 6 2") you can download a copy from the forum.
Thanks for the link. This PDF is new to me.

The wrong information:
jedie wrote:But in http://www.maddes.net/m6809pm/appendix_a.htm#appA stands only Inherent, Extended, Direct
is from
MC6809-MC6809E 8-Bit Microprocessor Programming Manual [M6809PM/AD]
© Motorola Inc., 1981
The origin PDF can be downloaded here: http://bitsavers.trailing-edge.com/pdf/motorola/
direct link: http://bitsavers.trailing-edge.com/pdf/ ... _May83.pdf

The wrong information is on PDF page 97

Re: 6809 opcode missmatch...

Posted: Wed Oct 16, 2013 7:45 am
by jedie
I have made a CSV exporter CPU6809csv_export.py for the DragonPy MC6809_data_raw.py

Now i put the CSV data into a public spreadsheet: https://docs.google.com/spreadsheet/ccc ... sp=sharing

The last thing i added was the columns mem_access, mem_read, mem_write:

mem_access: byte/word
mem_read: Does the op need the memory content?
mem_write: Does the op write back data to memory?

Can someone take a look and report errors?

Re: 6809 opcode missmatch...

Posted: Thu Oct 17, 2013 11:02 pm
by jedie
jedie wrote:Now i put the CSV data into a public spreadsheet: https://docs.google.com/spreadsheet/ccc ... sp=sharing

The last thing i added was the columns mem_access, mem_read, mem_write:

mem_access: byte/word
mem_read: Does the op need the memory content?
mem_write: Does the op write back data to memory?
Seems that i need more info from every op code:
mem read yes/no and if yes: byte/word? Same for mem write...
address mode (exist) and address mode byte/word...

Re: 6809 opcode missmatch...

Posted: Sat Oct 19, 2013 10:37 am
by jedie
I started with a new script here: https://github.com/jedie/DragonPy/blob/ ... 9_data2.py

And add a "NEW" sheet here: https://docs.google.com/spreadsheet/ccc ... URnUTNtSFE

The goal is to have something like this:

Code: Select all

{'ABX': {'ABX': {'desc': 'X = B+X (Unsigned)',
              'operand': '',
              'ops': {0x3a: 'INHERENT'},
              'read_from_memory': '-',
              'write_to_memory': '-'}},
'ADC': {'ADCA': {'desc': 'A = A+M+C',
               'operand': 'A',
               'ops': {0x89: 'IMMEDIATE',
                      0x99: 'DIRECT',
                      0xa9: 'INDEXED',
                      0xb9: 'EXTENDED'},
               'read_from_memory': 'BYTE',
               'write_to_memory': '-'},
       'ADCB': {'desc': 'B = B+M+C',
               'operand': 'B',
               'ops': {0xc9: 'IMMEDIATE',
                      0xd9: 'DIRECT',
                      0xe9: 'INDEXED',
                      0xf9: 'EXTENDED'},
               'read_from_memory': 'BYTE',
               'write_to_memory': '-'}},
'ADD': {'ADDA': {'desc': 'A = A+M',
               'operand': 'A',
               'ops': {0x8b: 'IMMEDIATE',
                      0x9b: 'DIRECT',
                      0xab: 'INDEXED',
                      0xbb: 'EXTENDED'},
               'read_from_memory': 'BYTE',
               'write_to_memory': '-'},
       'ADDB': {'desc': 'B = B+M',
               'operand': 'B',
               'ops': {0xcb: 'IMMEDIATE',
                      0xdb: 'DIRECT',
                      0xeb: 'INDEXED',
                      0xfb: 'EXTENDED'},
               'read_from_memory': 'BYTE',
               'write_to_memory': '-'},
       'ADDD': {'desc': 'D = D+M:M+1',
               'operand': 'D',
               'ops': {0xc3: 'IMMEDIATE_WORD',
                      0xd3: 'DIRECT',
                      0xe3: 'INDEXED',
                      0xf3: 'EXTENDED'},
               'read_from_memory': 'WORD',
               'write_to_memory': '-'}},
...
full list here: https://gist.github.com/jedie/7054130


The Problem is, how can i get the information if the op code "read from memory" and "write to memory" ???

The current solution is simple: Look at the Description :roll:
here: https://github.com/jedie/DragonPy/blob/ ... #L385-L490

and the code:

Code: Select all

    read_from_memory = "-"
    if "=" in desc:
        right = desc.split("=")[1]
        if "M:M" in right:
            read_from_memory = "WORD"
        elif "M" in right:
            read_from_memory = "BYTE"

    write_to_memory = "-"
    if desc.startswith("M:M"):
        write_to_memory = "WORD"
    elif desc.startswith("M ="):
        write_to_memory = "BYTE"
I think not all information is in the description, isn't it???

Re: 6809 opcode missmatch...

Posted: Sun Oct 20, 2013 1:26 pm
by jedie
I didn't found a better reference. So i merge the information i have, with this script: https://github.com/jedie/DragonPy/blob/ ... 9_data2.py

The result is this: https://github.com/jedie/DragonPy/blob/ ... ta_raw2.py

It looks noe like this:

Code: Select all

OP_DATA = {ABX: {'HNZVC': '-----',
     'condition code': 'Not affected.',
     'description': 'Add the 8-bit unsigned value in accumulator B into index register X.',
     'instr_desc': 'Add B accumulator to X (unsigned)',
     'mnemonic': {ABX: {'desc': 'X = B+X (Unsigned)',
                      'operand': None,
                      'ops': {0x3a: {'addr_mode': INHERENT,
                                   'bytes': 1,
                                   'cycles': 3}},
                      'read_from_memory': None,
                      'write_to_memory': None}},
     'operation': "IX' = IX + ACCB",
     'source form': ABX},
ADC: {'HNZVC': 'aaaaa',
     'condition code': 'H - Set if a half-carry is generated; cleared otherwise.\nN - Set if the result is negative; cleared otherwise.\nZ - Set if the result is zero; cleared otherwise.\nV - Set if an overflow is generated; cleared otherwise.\nC - Set if a carry is generated; cleared otherwise.',
     'description': 'Adds the contents of the C (carry) bit and the memory byte into an 8-bit accumulator.',
     'instr_desc': 'Add memory to accumulator with carry',
     'mnemonic': {'ADCA': {'desc': 'A = A+M+C',
                         'operand': REG_A,
                         'ops': {0x89: {'addr_mode': IMMEDIATE,
                                      'bytes': 2,
                                      'cycles': 2},
                                0x99: {'addr_mode': DIRECT,
                                      'bytes': 2,
                                      'cycles': 4},
                                0xa9: {'addr_mode': INDEXED,
                                      'bytes': 2,
                                      'cycles': 4},
                                0xb9: {'addr_mode': EXTENDED,
                                      'bytes': 3,
                                      'cycles': 5}},
                         'read_from_memory': BYTE,
                         'write_to_memory': None},
                 'ADCB': {'desc': 'B = B+M+C',
                         'operand': REG_B,
                         'ops': {0xc9: {'addr_mode': IMMEDIATE,
                                      'bytes': 2,
                                      'cycles': 2},
                                0xd9: {'addr_mode': DIRECT,
                                      'bytes': 2,
                                      'cycles': 4},
                                0xe9: {'addr_mode': INDEXED,
                                      'bytes': 2,
                                      'cycles': 4},
                                0xf9: {'addr_mode': EXTENDED,
                                      'bytes': 3,
                                      'cycles': 5}},
                         'read_from_memory': BYTE,
                         'write_to_memory': None}},
     'operation': "R' = R + M + C",
     'source form': 'ADCA P; ADCB P'},
ADD: {'HNZVC': 'aaaaa',
...

Re: 6809 opcode missmatch...

Posted: Sun Oct 20, 2013 11:56 pm
by JeeK
jedie wrote:I didn't found a better reference. So i merge the information i have, with this script: https://github.com/jedie/DragonPy/blob/ ... 9_data2.py

The result is this: https://github.com/jedie/DragonPy/blob/ ... ta_raw2.py
[..]
As far as I understand LEA, if a memory access happen depends on the addressing mode.
It depends on how the description or information 'read_from_memory' is meant or used for ...

Code: Select all

LEA: {'HNZVC': '-----',
[..]
     'instr_desc': 'Load effective address into stack pointer',
     'mnemonic': {'LEAS': {'desc': 'S = EA',
                         'operand': REG_S,
                         'ops': {0x32: {'addr_mode': INDEXED,
                                      'bytes': 2,
                                      'cycles': 4}},
                         'read_from_memory': None,
                         'write_to_memory': None},
                 'LEAU': {'desc': 'U = EA',
                         'operand': REG_U,
                         'ops': {0x33: {'addr_mode': INDEXED,
                                      'bytes': 2,
                                      'cycles': 4}},
                         'read_from_memory': None,
                         'write_to_memory': None},
                 'LEAX': {'desc': 'X = EA',
                         'operand': REG_X,
                         'ops': {0x30: {'addr_mode': INDEXED,
                                      'bytes': 2,
                                      'cycles': 4}},
                         'read_from_memory': None,
                         'write_to_memory': None},
                 'LEAY': {'desc': 'Y = EA',
                         'operand': REG_Y,
                         'ops': {0x31: {'addr_mode': INDEXED,
                                      'bytes': 2,
                                      'cycles': 4}},
                         'read_from_memory': None,
                         'write_to_memory': None}},
     'operation': "R' = EA",
     'source form': 'LEAX, LEAY, LEAS, LEAU'},
...
Just in case of a strict definition any indirect addressing modes implies actual a read:

[disp,R]
[,--R]
[,R++]
[A,R]
[B,R]
[D,R]
[disp,PC]
[address]

They all read a word because each has to fetch the effective address from memory ...
In not LEA-cases, multiple reads or read followed by writes may occur.
To take this thought further, JSR produces reads for indexed indirect addressing modes too, beside the fact that the saving of the PC to the stack could be regarded as writes too. So,

Code: Select all

                     'read_from_memory': None,
                      'write_to_memory': None}},
might no hold in this or similar cases ...

Re: 6809 opcode missmatch...

Posted: Mon Oct 21, 2013 9:34 am
by jedie
Good point! Thanks.

In my usage the read_from_memory "excluded" the address part. So if the address mode will fetch the memory to get the effective address, but the content of the memory is not needed in the instruction them self, the read_from_memory must be set to False.