easier68k.core.opcodes package

This page lists all of the opcodes that have been implemented in Easier68k.

Submodules

easier68k.core.opcodes.add module

class easier68k.core.opcodes.add.Add(params: list, size: easier68k.core.enum.op_size.OpSize = <OpSize.WORD: 2>)[source]

Bases: easier68k.core.opcodes.opcode.Opcode

ADD: add

Operation: Source + Destination → Destination

Syntax: ADD Dn, < ea > OR ADD < ea > ,Dn

Attributes: Size = (Byte, Word, Long)

Description: Adds the source operand to the destination operand using binary addition and stores the result in the destination location. The size of the operation may be specified as byte, word, or long. The mode of the instruction indicates which operand is the source and which is the destination, as well as the operand size.

Condition Codes: X — Set the same as the carry bit. N — Set if the result is negative; cleared otherwise. Z — Set if the result is zero; cleared otherwise. V — Set if an overflow is generated; cleared otherwise. C — Set if a carry is generated; cleared otherwise.

Instruction Fields: Register field—Specifies any of the eight data registers. Opmode field

Byte Word Long Operation

000 001 010 < ea > + Dn → Dn

100 101 110 Dn + < ea > → < ea >

NOTE The Dn mode is used when the destination is a data register; the destination < ea > mode is invalid for a data register. ADDA is used when the destination is an address register. ADDI and ADDQ are used when the source is immediate data. Most assemblers automatically make this distinction.

assemble() → bytearray[source]

Assembles this opcode into hex to be inserted into memory :return: The hex version of this opcode

classmethod command_matches(command: str) → bool[source]

Checks whether a command string is an instance of this command type :param command: The command string to check (e.g. ‘MOVE.B’, ‘LEA’, etc.) :return: Whether the string is an instance of this command type

classmethod disassemble_instruction(data: bytearray) → easier68k.core.opcodes.opcode.Opcode[source]

This has a non-add opcode >>> Add.disassemble_instruction(bytearray.fromhex(‘0280’))

ADD.B D1,D7 >>> op = Add.disassemble_instruction(bytearray.fromhex(‘D307’))

>>> str(op.src)
'EA Mode: EAMode.DRD, Data: 1'
>>> str(op.dest)
'EA Mode: EAMode.DRD, Data: 7'

ADD.B #0, D1 >>> op = Add.disassemble_instruction(bytearray.fromhex(‘D23C00’))

>>> str(op.src)
'EA Mode: EAMode.IMM, Data: 0'
>>> str(op.dest)
'EA Mode: EAMode.DRD, Data: 1'

ADD.W D3, D0 >>> op = Add.disassemble_instruction(bytearray.fromhex(‘D740’))

>>> str(op.src)
'EA Mode: EAMode.DRD, Data: 3'
>>> str(op.dest)
'EA Mode: EAMode.DRD, Data: 0'

ADD.L ($0A0B0C0D).L, D7 >>> op = Add.disassemble_instruction(bytearray.fromhex(‘DEB9000A0B0C’))

>>> str(op.src)
'EA Mode: EAMode.ALA, Data: 658188'
>>> str(op.dest)
'EA Mode: EAMode.DRD, Data: 7'

Parses some raw data into an instance of the opcode class :param data: The data used to convert into an opcode instance :return: The constructed instance or none if there was an error and

the amount of data in words that was used (e.g. extra for immediate data) or 0 for not a match
execute(simulator: easier68k.simulator.m68k.M68K)[source]

Executes this command in a simulator :param simulator: The simulator to execute the command on :return: Nothing

classmethod from_str(command: str, parameters: str)[source]

Parses a ADD command from text.

>>> str(Add.from_str('ADD.B', '-(A0), D1'))
'Add command: Size OpSize.BYTE, src EA Mode: EAMode.ARIPD, Data: 0, dest EA Mode: EAMode.DRD, Data: 1'
>>> str(Add.from_str('ADD.L', 'D3, (A0)'))
'Add command: Size OpSize.LONG, src EA Mode: EAMode.DRD, Data: 3, dest EA Mode: EAMode.ARI, Data: 0'
Parameters:
  • command – The command itself (e.g. ‘MOVE.B’, ‘LEA’, etc.)
  • parameters – The parameters after the command (such as the source and destination of a move)
Returns:

The parsed command

classmethod get_word_length(command: str, parameters: str) → int[source]
>>> Add.get_word_length('ADD', 'D0, D1')
1
>>> Add.get_word_length('ADD.L', '#$90, D3')
3
>>> Add.get_word_length('ADD.W', '#$90, D3')
2
>>> Add.get_word_length('ADD.W', '($AAAA).L, D7')
3
>>> Add.get_word_length('ADD.W', 'D0, ($BBBB).L')
3
>>> Add.get_word_length('ADD.W', '($AAAA).L, ($BBBB).L')
5
>>> Add.get_word_length('ADD.W', '#$AAAA, ($BBBB).L')
4

Gets what the end length of this command will be in memory :param command: The text of the command itself (e.g. “LEA”, “MOVE.B”, etc.) :param parameters: The parameters after the command :return: The length of the bytes in memory in words, as well as a list of warnings or errors encountered

classmethod is_valid(command: str, parameters: str) -> (<class 'bool'>, <class 'list'>)[source]

Tests whether the given command is valid

>>> Add.is_valid('ADD.B', 'D0, D1')[0]
True
>>> Add.is_valid('ADD.W', 'D0')[0]
False
>>> Add.is_valid('ADD.G', 'D0, D1')[0]
False
>>> Add.is_valid('ADD.L', 'D0, A2')[0]
False
>>> Add.is_valid('AD.L', 'D0, D1')[0]
False
>>> Add.is_valid('ADD.', 'D0, D1')[0]
False
Parameters:
  • command – The command itself (e.g. ‘MOVE.B’, ‘LEA’, etc.)
  • parameters – The parameters after the command (such as the source and destination of a move)
Returns:

Whether the given command is valid and a list of issues/warnings encountered

valid_sizes = [<OpSize.BYTE: 1>, <OpSize.WORD: 2>, <OpSize.LONG: 4>]

easier68k.core.opcodes.adda module

class easier68k.core.opcodes.adda.Adda(params: list, size: easier68k.core.enum.op_size.OpSize = <OpSize.WORD: 2>)[source]

Bases: easier68k.core.opcodes.opcode.Opcode

ADDA Add Address ADDA Operation: Source + Destination → Destination Syntax: ADDA < ea > , An Attributes: Size = (Word, Long)

Description: Adds the source operand to the destination address register and stores the result in the address register. The size of the operation may be specified as word or long. The entire destination address register is used regardless of the operation size.

Condition Codes: Not affected

Instruction Fields: Register field—Specifies any of the eight address registers. This is always the destination. Opmode field—Specifies the size of the operation. 011— Word operation; the source operand is sign-extended to a long operand and the operation is performed on the address register using all 32 bits. 111— Long operation.

assemble() → bytearray[source]

Assembles this opcode into hex to be inserted into memory :return: The hex version of this opcode

classmethod command_matches(command: str) → bool[source]

Checks whether a command string is an instance of this command type :param command: The command string to check (e.g. ‘MOVE.B’, ‘LEA’, etc.) :return: Whether the string is an instance of this command type

classmethod disassemble_instruction(data: bytearray) -> (<class 'easier68k.core.opcodes.adda.Adda'>, <class 'int'>)[source]

This has a non-adda opcode >>> Adda.disassemble_instruction(bytearray.fromhex(‘1E00’))

ADDA.W A1,A7 >>> op = Adda.disassemble_instruction(bytearray.fromhex(‘DEC9’))

>>> str(op.src)
'EA Mode: EAMode.ARD, Data: 1'
>>> str(op.dest)
'EA Mode: EAMode.ARD, Data: 7'

ADDA.W #0, A1 >>> op = Adda.disassemble_instruction(bytearray.fromhex(‘D2FC0000’))

>>> str(op.src)
'EA Mode: EAMode.IMM, Data: 0'
>>> str(op.dest)
'EA Mode: EAMode.ARD, Data: 1'

ADDA.W D3, A0 >>> op = Adda.disassemble_instruction(bytearray.fromhex(‘D0C3’))

>>> str(op.src)
'EA Mode: EAMode.DRD, Data: 3'
>>> str(op.dest)
'EA Mode: EAMode.ARD, Data: 0'

ADDA.W ($0A0B).W, A6 >>> op = Adda.disassemble_instruction(bytearray.fromhex(‘DCF80A0B’))

>>> str(op.src)
'EA Mode: EAMode.AWA, Data: 2571'
>>> str(op.dest)
'EA Mode: EAMode.ARD, Data: 6'

Parses some raw data into an instance of the opcode class :param data: The data used to convert into an opcode instance :return: The constructed instance or none if there was an error and

the amount of data in words that was used (e.g. extra for immediate data) or 0 for not a match
execute(simulator: easier68k.simulator.m68k.M68K)[source]

Executes this command in a simulator :param simulator: The simulator to execute the command on :return: Nothing

classmethod from_str(command: str, parameters: str)[source]

Parses a ADDA command from text.

>>> str(Adda.from_str('ADDA.W', 'A5, A3'))
'Adda command: Size OpSize.WORD, src EA Mode: EAMode.ARD, Data: 5, dest EA Mode: EAMode.ARD, Data: 3'
>>> str(Adda.from_str('ADDA.L', '(A0)+, A4'))
'Adda command: Size OpSize.LONG, src EA Mode: EAMode.ARIPI, Data: 0, dest EA Mode: EAMode.ARD, Data: 4'
Parameters:
  • command – The command itself (e.g. ‘MOVE.B’, ‘LEA’, etc.)
  • parameters – The parameters after the command (such as the source and destination of a move)
Returns:

The parsed command

classmethod get_word_length(command: str, parameters: str) → int[source]
>>> Adda.get_word_length('ADDA.W', 'D0, A1')
1
>>> Adda.get_word_length('ADDA.W', '#$90, A0')
2
>>> Adda.get_word_length('ADDA.L', '#$90, A3')
3
>>> Adda.get_word_length('ADDA.W', '#$90, A3')
2
>>> Adda.get_word_length('ADDA.W', '(A0), A1')
1
>>> Adda.get_word_length('ADDA.W', '#$ABCDE, A0')
2
>>> Adda.get_word_length('ADDA.L', '($AAAA).L, A6')
3
>>> Adda.get_word_length('ADDA.W', '($AAAA).W, A5')
2

Gets what the end length of this command will be in memory :param command: The text of the command itself (e.g. “LEA”, “MOVE.B”, etc.) :param parameters: The parameters after the command :return: The length of the bytes in memory in words, as well as a list of warnings or errors encountered

classmethod is_valid(command: str, parameters: str) -> (<class 'bool'>, <class 'list'>)[source]

Tests whether the given command is valid

>>> Adda.is_valid('ADDA', '(A0), A1')[0]
True
>>> Adda.is_valid('ADDA.W', '(A0)+')[0]
False
>>> Adda.is_valid('ADDA.B', '(A0), A1')[0]
False
>>> Adda.is_valid('ADDA.W', 'D0, A2')[0]
True
>>> Adda.is_valid('ADDA.L', '#$0A, A4')[0]
True
>>> Adda.is_valid('ADDA.L', '($AAAA).L, A7')[0]
True
Parameters:
  • command – The command itself (e.g. ‘MOVE.B’, ‘LEA’, etc.)
  • parameters – The parameters after the command (such as the source and destination of a move)
Returns:

Whether the given command is valid and a list of issues/warnings encountered

valid_sizes = [<OpSize.WORD: 2>, <OpSize.LONG: 4>]

easier68k.core.opcodes.cmp module

class easier68k.core.opcodes.cmp.Cmp(params: list, size: easier68k.core.enum.op_size.OpSize = <OpSize.WORD: 2>)[source]

Bases: easier68k.core.opcodes.opcode.Opcode

CMP: Compare Operation: Destination - Source -> cc Assembler Syntax: CMP <ea>, Dn Attributes: Size = (Byte, Word, Long) Description: Subtracts the source operand from the destination data register

and sets the condition codes according to the result; the data register is not changed. The size of the operation can be byte, word, or long.
Condition Codes: X - Not affected
N - Set if the result is negative; cleared otherwise. Z - Set if the result is zero; cleared otherwise. V - Set if an overflow occurs; cleared otherwise. C - Set if a borrow occurs; cleared otherwise.

Instruction Format: 1 0 1 1 Dest Register xxx OpMode xxx EA mode xxx Register xxx Instruction Fields:

Register field - Specifies the destination data register.

Opmode field [Operation: Dn - <ea>]
000 - Byte 001 - Word 010 - Long
Effective Address field - Specifies the source operand.
All addressing modes can be used.

Valid Modes - All (Word and Long size only for An)

NOTE: CMPA is used when the destination is an address register.
CMPI is used when the source is immediate data. CMPM is used for memory-to-memory compares. Most assemblers automatically make the distinction.
assemble() → bytearray[source]

Assembles this opcode into a bytearray to be inserted into memory :return: The bytearray which represents this assembled opcode

classmethod command_matches(command: str) → bool[source]

Checks whether a command string is an instance of this command type

This will only allow for CMP. Not CMPA, CMPI, CMPM. While CMP is not checking for the types that would make it actually one of these different types, those instructions must be implemented separately.

Parameters:command – The command string to check ‘CMP.W’, ‘CMP’
Returns:Whether the string is an instance of CMP
classmethod disassemble_instruction(data: bytes) → easier68k.core.opcodes.opcode.Opcode[source]

Disassembles the instruction into an instance of the CMP class :param data: :return:

execute(simulator: easier68k.simulator.m68k.M68K)[source]

Executes this command in the simulator

Subtracts the source operand from the destination operand and set the condition codes accordingly. The destination must be a data register. The destination is not modified by this instruction.

Parameters:simulator – the simulator that this opcode is being run on
Returns:
classmethod from_str(command: str, parameters: str)[source]

Parses a CMP from text.

Parameters:
  • command – The command itself ‘CMP.L’ ‘CMP’, etc.
  • parameters – The parameters after the command
Returns:

The parsed command

classmethod get_word_length(command: str, parameters: str) → int[source]

Gets the length of this command in memory, including the length of the single opcode and the length of any immediate parameter values

>>> Cmp.get_word_length('CMP', 'D0, D1')
1
>>> Cmp.get_word_length('CMP.W', 'D0, D1')
1
>>> Cmp.get_word_length('CMP.L', 'D0, D1')
1
>>> Cmp.get_word_length('CMP.L', '($AAAA).L, D7')
3
Parameters:
  • command
  • parameters
Returns:

classmethod is_valid(command: str, parameters: str) -> (<class 'bool'>, <class 'list'>)[source]

Tests whether the given command is valid

>>> Cmp.is_valid('CMP', 'D0, D1')[0]
True
>>> Cmp.is_valid('CMP.', '#123, D7')[0]
False
Parameters:
  • command
  • parameters
Returns:

valid_sizes = [<OpSize.BYTE: 1>, <OpSize.WORD: 2>, <OpSize.LONG: 4>]

easier68k.core.opcodes.cmpi module

class easier68k.core.opcodes.cmpi.Cmpi(params: list, size: easier68k.core.enum.op_size.OpSize = <OpSize.WORD: 2>)[source]

Bases: easier68k.core.opcodes.opcode.Opcode

CMPI: Compare Immediate Operation: Destination - Immediate Data -> cc Assembler Syntax: CMPI #<data>, <ea> Attributes: Size = (Byte, Word, Long) Description: Subtracts the immediate data from the destination operand

and sets the condition codes according to the result; the destination location is not changed. The size of the operation may be specified as byte, word, or long. The size of the immediate data matches the operation size.
Condition Codes: X - Not affected
N - Set if the result is negative; cleared otherwise. Z - Set if the result is zero; cleared otherwise. V - Set if an overflow occurs; cleared otherwise. C - Set if a borrow occurs; cleared otherwise.
Instruction Format: 0100111010 Signature xxx EAMode xxx EARegister
16-BIT WORD DATA | 8-BIT BYTE DATA |
32-BIT LONG DATA |
Instruction Fields:
Size field - Specifies the size of the operation.
00 - Byte operation 01 - Word operation 10 - Long operation
Effective Address field - Specifies the address of the next instruction.
Only data addressing modes can be used.

Valid Modes - Dn, (An), (An)+, -(An), (xxx).W, (xxx).L

Immediate field - Data immediately following the instruction.
If size = 00, the data is the low-order byte of the immediate word If size = 01, the data is the entire immediate word. If size = 10, the data is the next two immediate words.
assemble() → bytearray[source]

Assembles this opcode into a bytearray to be inserted into memory :return: The bytearray which represents this assembled opcode

classmethod command_matches(command: str) → bool[source]

Checks whether a command string is an instance of this command type

This will only allow for CMPI. Not CMPA, CMP, CMPM. While CMPI is not checking for the types that would make it actually one of these different types, those instructions must be implemented separately.

Parameters:command – The command string to check ‘CMPI.W’, ‘CMPI’
Returns:Whether the string is an instance of CMPI
classmethod disassemble_instruction(data: bytes) → easier68k.core.opcodes.opcode.Opcode[source]

CMPI.W #123,D7 >>> op = Cmpi.disassemble_instruction(bytearray.fromhex(‘0C47007B’))

>>> str(op.src)
'EA Mode: EAMode.IMM, Data: 123'
>>> str(op.dest)
'EA Mode: EAMode.DRD, Data: 7'

Disassembles the instruction into an instance of the CMP class :param data: :return:

execute(simulator: easier68k.simulator.m68k.M68K)[source]

Executes this command in the simulator

Subtracts the source operand from the destination operand and set the condition codes accordingly. The source must be an immediate number. The destination is not modified by this instruction.

Parameters:simulator – the simulator that this opcode is being run on
Returns:
classmethod from_str(command: str, parameters: str)[source]

Parses a CMPI from text.

>>> str(Cmpi.from_str('CMPI.B', '#1337, D1'))
'CMPI Size OpSize.BYTE, Src EA Mode: EAMode.IMM, Data: 1337, Dest EA Mode: EAMode.DRD, Data: 1'
Parameters:
  • command – The command itself ‘CMPI’ ‘CMPI.B’, etc.
  • parameters – The parameters after the command
Returns:

The parsed command

classmethod get_word_length(command: str, parameters: str) → int[source]

Gets the length of this command in memory, including the length of the single opcode and the length of any immediate parameter values

>>> Cmpi.get_word_length('CMPI', '#123, D3')
2
>>> Cmpi.get_word_length('CMPI.L', '#12345678, D1')
3
>>> Cmpi.get_word_length('CMPI.W', '#$FFFF, (A2)+')
2
>>> Cmpi.get_word_length('CMPI.L', '#12345678, (A7)')
3
>>> Cmpi.get_word_length('CMPI.W', '#$FFFF, ($AAAA).W')
3
>>> Cmpi.get_word_length('CMPI.L', '#12345678, ($AAAA).L')
5
Parameters:
  • command
  • parameters
Returns:

classmethod is_valid(command: str, parameters: str) -> (<class 'bool'>, <class 'list'>)[source]

Tests whether the given command is valid

>>> Cmpi.is_valid('CMPI', '#123, D1')[0]
True
>>> Cmpi.is_valid('CMP.', '#123, D7')[0]
False
Parameters:
  • command
  • parameters
Returns:

valid_sizes = [<OpSize.BYTE: 1>, <OpSize.WORD: 2>, <OpSize.LONG: 4>]

easier68k.core.opcodes.dc module

class easier68k.core.opcodes.dc.DC(values: list, size=<OpSize.WORD: 2>)[source]

Bases: easier68k.core.opcodes.opcode.Opcode

QUOTE_DELIMETER = "'"
assemble() → bytearray[source]

Assembles this opcode into hex to be inserted into memory :return: The hex version of this opcode

classmethod command_matches(command: str) → bool[source]

Checks whether a command string is an instance of this command type :param command: The command string to check (e.g. ‘MOVE.B’, ‘LEA’, etc.) :return: Whether the string is an instance of this command type

classmethod disassemble_instruction(data: bytes) → easier68k.core.opcodes.opcode.Opcode[source]

Disassembles the instuction into an instance of the DC class

execute(simulator: easier68k.simulator.m68k.M68K)[source]

Executes this command in a simulator :param simulator: The simulator to execute the command on :return: Nothing

classmethod from_binary(data: bytearray)[source]
classmethod from_str(command: str, parameters: str)[source]

Parses a command string into an instance of the opcode class

>>> test0 = DC.from_str("DC.B", "$0A, $0B")
>>> test0.size
<OpSize.BYTE: 1>
>>> test0.values
[10, 11]
>>> test1 = DC.from_str("DC.B", "\'Hai!\'")
>>> test1.size
<OpSize.BYTE: 1>
>>> test1.values
[72, 97, 105, 33]
>>> test2 = DC.from_str("DC.L", "\'Hai\'")
>>> test2.size
<OpSize.LONG: 4>
>>> test2.values
[72, 97, 105, 0]
>>> test3 = DC.from_str("DC.L", "\'Hai\', $AB")
>>> test3.size
<OpSize.LONG: 4>
>>> test3.values
[72, 97, 105, 0, 0, 0, 0, 171]
>>> test4 = DC.from_str("DC.W", "\'Hai\', $AB")
>>> test4.size
<OpSize.WORD: 2>
>>> test4.values
[72, 97, 105, 0, 0, 171]
Parameters:
  • command – The command itself (e.g. ‘MOVE.B’, ‘LEA’, etc.)
  • parameters – The parameters after the command (such as the source and destination of a move)
classmethod get_word_length(command: str, parameters: str) → int[source]

Gets the final length of a command in memory in words NOTE: for DC.B, this will round UP to make it a full word, even though it won’t use the full memory

>>> DC.get_word_length('DC.B', '$0A, $0B')
1
>>> DC.get_word_length('DC.W', '$0A, $0B')
2
>>> DC.get_word_length('DC.L', '$0A, $0B')
4
>>> DC.get_word_length('DC.B', '\'Hai!\'')
2
>>> DC.get_word_length('DC.W', '\'Hai!\'')
2
>>> DC.get_word_length('DC.L', '\'Hai!\'')
4
Parameters:
  • command – The command itself (e.g. ‘MOVE.B’, ‘LEA’, etc.)
  • parameters – The parameters after the command (such as the source and destination of a move)
Returns:

The length of the command in memory (in words)

classmethod is_valid(command: str, parameters: str) -> (<class 'bool'>, <class 'list'>)[source]

Tests whether the given command is valid

>>> DC.is_valid('DC.B', '\'Hello, world!\'')[0]
True
>>> DC.is_valid('DC.B', '\'Hello\'\' world!\'')[0]
True
>>> DC.is_valid('DC.W', '\'Hello\', \' world!\'')[0]
True
>>> DC.is_valid('DC.W', '$0A, $0B')[0]
True
>>> DC.is_valid('DC.L', '$0A')[0]
True
>>> DC.is_valid('DC.B', '')[0]
False
>>> DC.is_valid('DC.W', '\'Hey!\', $0A')[0]
True
>>> DC.is_valid('DC.G', '$0A')[0]
False
Parameters:
  • command – The command itself (e.g. ‘MOVE.B’, ‘LEA’, etc.)
  • parameters – The parameters after the command (such as the source and destination of a move)
Returns:

Whether the given command is valid and a list of issues/warnings encountered

valid_sizes = [<OpSize.BYTE: 1>, <OpSize.WORD: 2>, <OpSize.LONG: 4>]

easier68k.core.opcodes.eor module

class easier68k.core.opcodes.eor.Eor(params: list, size: easier68k.core.enum.op_size.OpSize = <OpSize.WORD: 2>)[source]

Bases: easier68k.core.opcodes.opcode.Opcode

EOR: Exclusive-OR Logical

Operation: Source ⊕ Destination → Destination

Syntax: EOR Dn, < ea >

Attributes: Size = (Byte, Word, Long)

Description: Performs an exclusive-OR operation on the destination operand using the source operand and stores the result in the destination location. The size of the operation may be specified to be byte, word, or long. The source operand must be a data register. The destination operand is specified in the effective address field.

Condition Codes: X — Not affected. N — Set if the most significant bit of the result is set; cleared otherwise. Z — Set if the result is zero; cleared otherwise. V — Always cleared. C — Always cleared.

NOTE: Memory-to-data-register operations are not allowed. Most assemblers use EORI when the source is immediate data.

assemble() → bytearray[source]

Assembles this opcode into hex to be inserted into memory :return: The hex version of this opcode

classmethod command_matches(command: str) → bool[source]

Checks whether a command string is an instance of this command type :param command: The command string to check (e.g. ‘MOVE.B’, ‘LEA’, etc.) :return: Whether the string is an instance of this command type

classmethod disassemble_instruction(data: bytearray) → easier68k.core.opcodes.opcode.Opcode[source]

This has a non-EOR opcode >>> Eor.disassemble_instruction(bytearray.fromhex(‘D280’))

EOR.B D0, D1 >>> op = Eor.disassemble_instruction(bytearray.fromhex(‘B101’))

>>> str(op.src)
'EA Mode: EAMode.DRD, Data: 0'
>>> str(op.dest)
'EA Mode: EAMode.DRD, Data: 1'

EOR.W D3, D0 >>> op = Eor.disassemble_instruction(bytearray.fromhex(‘B740’))

>>> str(op.src)
'EA Mode: EAMode.DRD, Data: 3'
>>> str(op.dest)
'EA Mode: EAMode.DRD, Data: 0'

EOR.L D7, $1234 >>> op = Eor.disassemble_instruction(bytearray.fromhex(‘BFB81234’))

>>> str(op.src)
'EA Mode: EAMode.DRD, Data: 7'
>>> str(op.dest)
'EA Mode: EAMode.AWA, Data: 4660'

Parses some raw data into an instance of the opcode class :param data: The data used to convert into an opcode instance :return: The constructed instance or none if there was an error and

the amount of data in words that was used (e.g. extra for immediate data) or 0 for not a match
execute(simulator: easier68k.simulator.m68k.M68K)[source]

Executes this command in a simulator :param simulator: The simulator to execute the command on :return: Nothing

classmethod from_str(command: str, parameters: str)[source]

Parses a MOVE command from text. >>> str(Eor.from_str(‘EOR.B’, ‘D1, -(A0)’)) ‘Eor command: size OpSize.BYTE, src EA Mode: EAMode.DRD, Data: 1, dest EA Mode: EAMode.ARIPD, Data: 0’ >>> str(Eor.from_str(‘EOR.L’, ‘D3, (A2)’)) ‘Eor command: size OpSize.LONG, src EA Mode: EAMode.DRD, Data: 3, dest EA Mode: EAMode.ARI, Data: 2’

Parameters:
  • command – The command itself (e.g. ‘MOVE.B’, ‘LEA’, etc.)
  • parameters – The parameters after the command (such as the source and destination of a move)
Returns:

The parsed command

classmethod get_word_length(command: str, parameters: str) → int[source]
>>> Eor.get_word_length('EOR.B', 'D0, D1')
1
>>> Eor.get_word_length('EOR.W', 'D3, (A4)+')
1
>>> Eor.get_word_length('EOR.L', 'D1, ($1234).W')
2
>>> Eor.get_word_length('EOR.L', 'D0, ($FFFF).L')
3
>>> Eor.get_word_length('EOR.B', 'D0, -(A3)')
1
>>> Eor.get_word_length('EOR.W', 'D7, (A0)')
1

Gets what the end length of this command will be in memory :param command: The text of the command itself (e.g. “LEA”, “MOVE.B”, etc.) :param parameters: The parameters after the command :return: The length of the bytes in memory in words, as well as a list of warnings or errors encountered

classmethod is_valid(command: str, parameters: str) -> (<class 'bool'>, <class 'list'>)[source]

Tests whether the given command is valid

>>> Eor.is_valid('EOR.B', 'D0, D1')[0]
True
>>> Eor.is_valid('EOR.W', 'A3, D7')[0]
False
>>> Eor.is_valid('EOR.L', 'D5, ($1234).W')[0]
True
>>> Eor.is_valid('EOR.W', 'D5, ($0A0B).L')[0]
True
>>> Eor.is_valid('EOR.W', '#$AB, D3')[0]
False
>>> Eor.is_valid('EOR.G', 'D0, D7')[0]
False
Parameters:
  • command – The command itself (e.g. ‘MOVE.B’, ‘LEA’, etc.)
  • parameters – The parameters after the command (such as the source and destination of a move)
Returns:

Whether the given command is valid and a list of issues/warnings encountered

valid_sizes = [<OpSize.BYTE: 1>, <OpSize.WORD: 2>, <OpSize.LONG: 4>]

easier68k.core.opcodes.jsr module

class easier68k.core.opcodes.jsr.Jsr(params: list)[source]

Bases: easier68k.core.opcodes.opcode.Opcode

JSR: Jump to Subroutine Operation: SP - 4 -> SP; PC -> (SP); Destination Address -> PC Assembler Syntax: JSR <ea> Attributes: Unsized Description: Pushes the long-word address of the instruction immediately following the JSR instruction

onto the system stack. Program execution then continues at the address specified in the instruction.

Condition Codes: Not affected Instruction Format: 0100111010 Signature xxx EAMode xxx EARegister Instruction Field:

Effective Address field - Specifies the address of the next instruction.
Only control addressing modes can be used as listed in the following tables.

Valid Modes - (An), (xxx).W, (xxx).L

assemble() → bytearray[source]

Assembles this opcode into hex to be inserted into memory :return: The hex version of this opcode

classmethod command_matches(command: str) → bool[source]

Checks whether a command string is an instance of this command type :param command: The command string to check (e.g. ‘MOVE.B’, ‘LEA’, etc.) :return: Whether the string is an instance of this command type

classmethod disassemble_instruction(data: bytearray) → Optional[easier68k.core.opcodes.opcode.Opcode][source]

This has a non-JSR opcode >>> Jsr.disassemble_instruction(bytearray.fromhex(‘0280’))

JSR (A0) >>> op = Jsr.disassemble_instruction(bytearray.fromhex(‘4E90’))

>>> str(op.dest)
'EA Mode: EAMode.ARI, Data: 0'

JSR (A5) >>> op = Jsr.disassemble_instruction(bytearray.fromhex(‘4E95’))

>>> str(op.dest)
'EA Mode: EAMode.ARI, Data: 5'

JSR $4000 >>> op = Jsr.disassemble_instruction(bytearray.fromhex(‘4EB84000’))

>>> str(op.dest)
'EA Mode: EAMode.AWA, Data: 16384'

JSR $FFFF7000 >>> op = Jsr.disassemble_instruction(bytearray.fromhex(‘4EB87000’))

>>> str(op.dest)
'EA Mode: EAMode.AWA, Data: 28672'

Parses some raw data into an instance of the opcode class :param data: The data used to convert into an opcode instance :return: The constructed instance or none if there was an error and

the amount of data in words that was used (e.g. extra for immediate data) or 0 for not a match
execute(simulator: easier68k.simulator.m68k.M68K)[source]

Executes this command in a simulator :param simulator: The simulator to execute the command on :return: None

classmethod from_str(command: str, parameters: str)[source]

Parses a JSR command from text.

>>> str(Jsr.from_str('JSR', '(A0)'))
'Jsr command: dest EA Mode: EAMode.ARI, Data: 0'
>>> str(Jsr.from_str('JSR', '($4000).W'))
'Jsr command: dest EA Mode: EAMode.AWA, Data: 16384'
Parameters:
  • command – The command itself (e.g. ‘MOVE.B’, ‘LEA’, etc.)
  • parameters – The parameters after the command (such as the source and destination of a move)
Returns:

The parsed command

classmethod get_word_length(command: str, parameters: str) → int[source]
>>> Jsr.get_word_length('JSR', '(A5)')
1
>>> Jsr.get_word_length('JSR', '-(A7)')
1
>>> Jsr.get_word_length('JSR', '($BBBB).W')
2
>>> Jsr.get_word_length('JSR', '($1000).W')
2
>>> Jsr.get_word_length('JSR', '($FFFF).L')
3
>>> Jsr.get_word_length('JSR', '($8000).L')
3

Gets what the end length of this command will be in memory :param command: The text of the command itself (e.g. “LEA”, “MOVE.B”, etc.) :param parameters: The parameters after the command :return: The length of the bytes in memory in words, as well as a list of warnings or errors encountered

classmethod is_valid(command: str, parameters: str) -> (<class 'bool'>, <class 'list'>)[source]

Tests whether the given command is valid

>>> Jsr.is_valid('JSR', '(A0)')[0]
True
>>> Jsr.is_valid('JSR', '(A5)')[0]
True
>>> Jsr.is_valid('JSR', '#5, D1')[0]
False
>>> Jsr.is_valid('JSR.W', '(A1)')[0]
True
>>> Jsr.is_valid('JS', '($1000).W')[0]
False
>>> Jsr.is_valid('JSR.', '(A4)')[0]
False
>>> Jsr.is_valid('JSR', '($7000).W')[0]
True
Parameters:
  • command – The command itself (e.g. ‘MOVE.B’, ‘LEA’, etc.)
  • parameters – The parameters after the command (such as the source and destination of a move)
Returns:

Whether the given command is valid and a list of issues/warnings encountered

easier68k.core.opcodes.lea module

class easier68k.core.opcodes.lea.Lea(params: list)[source]

Bases: easier68k.core.opcodes.opcode.Opcode

LEA: Load Effective Address

Operation: < ea > → An

Syntax: LEA < ea > ,An

Attributes: Size = (Long)

Description: Loads the effective address into the specified address register. All 32 bits of the address register are effected by this instruction.

Condition Codes: Not affected.

assemble() → bytearray[source]

Assembles this opcode into hex to be inserted into memory :return: The hex version of this opcode

classmethod command_matches(command: str) → bool[source]

Checks whether a command string is an instance of this command type :param command: The command string to check (e.g. ‘MOVE.B’, ‘LEA’, etc.) :return: Whether the string is an instance of this command type

classmethod disassemble_instruction(data: bytearray) -> (<class 'easier68k.core.opcodes.lea.Lea'>, <class 'int'>)[source]

Parses some raw data into an instance of the opcode class

Parameters:data – The data used to convert into an opcode instance
Returns:The constructed instance or none if there was an error and the amount of data in words that was used (e.g. extra for immediate data) or 0 for not a match
execute(simulator: easier68k.simulator.m68k.M68K)[source]

Executes this command in a simulator :param simulator: The simulator to execute the command on :return: Nothing

classmethod from_str(command: str, parameters: str)[source]

Parses a LEA command from memory.

>>> str(Lea.from_str('LEA', '(A0), A1'))
'LEA command: src EA Mode: EAMode.ARI, Data: 0, dest EA Mode: EAMode.ARD, Data: 1'
>>> str(Lea.from_str('LEA', '($0A).W, A2'))
'LEA command: src EA Mode: EAMode.AWA, Data: 10, dest EA Mode: EAMode.ARD, Data: 2'
Parameters:
  • command – The command itself (e.g. ‘MOVE.B’, ‘LEA’, etc.)
  • parameters – The parameters after the command (such as the source and destination of a move)
classmethod get_word_length(command: str, parameters: str) → int[source]
>>> Lea.get_word_length('LEA', '(A0), A1')
1
>>> Lea.get_word_length('LEA', '#$90, A0')
2
>>> Lea.get_word_length('LEA', '#$ABCDE, A0')
3
>>> Lea.get_word_length('LEA', '($AAAA).L, A6')
3
>>> Lea.get_word_length('LEA', '($AAAA).W, A5')
2

Gets what the end length of this command will be in memory :param command: The text of the command itself (e.g. “LEA”, “MOVE.B”, etc.) :param parameters: The parameters after the command :return: The length of the bytes in memory in words, as well as a list of warnings or errors encountered

classmethod is_valid(command: str, parameters: str) -> (<class 'bool'>, <class 'list'>)[source]

Tests whether the given command is valid

>>> Lea.is_valid('LEA', '(A0), A1')[0]
True
>>> Lea.is_valid('LEA', 'A0')[0]
False
>>> Lea.is_valid('LEA.B', '(A0), A1')[0]
False
>>> Lea.is_valid('LEA', 'D0, A2')[0]
False
>>> Lea.is_valid('LEA', '#$0A, A4')[0]
True
>>> Lea.is_valid('LEA', '($AAAA).L, A7')[0]
True
Parameters:
  • command – The command itself (e.g. ‘MOVE.B’, ‘LEA’, etc.)
  • parameters – The parameters after the command (such as the source and destination of a move)
Returns:

Whether the given command is valid and a list of issues/warnings encountered

easier68k.core.opcodes.move module

class easier68k.core.opcodes.move.Move(params: list, size: easier68k.core.enum.op_size.OpSize = <OpSize.WORD: 2>)[source]

Bases: easier68k.core.opcodes.opcode.Opcode

MOVE: Move Data from Source to Destination

Operation: Source → Destination

Syntax: MOVE < ea > , < ea >

Attributes: Size = (Byte, Word, Long)

Description: Moves the data at the source to the destination location and sets the condition codes according to the data. The size of the operation may be specified as byte, word, or long.

Condition Codes: X — Not affected. N — Set if the result is negative; cleared otherwise. Z — Set if the result is zero; cleared otherwise. V — Always cleared. C — Always cleared.

Size field: Specifies the size of the operand to be moved. 01 — Byte operation 11 — Word operation 10 — Long operation

Source Effective Address field—Specifies the source operand. All addressing modes can be used as listed in the following tables:

NOTE: Most assemblers use MOVEA when the destination is an address register. MOVEQ can be used to move an immediate 8-bit value to a data register.

assemble() → bytearray[source]

Assembles this opcode into hex to be inserted into memory :return: The hex version of this opcode

classmethod command_matches(command: str) → bool[source]

Checks whether a command string is an instance of this command type :param command: The command string to check (e.g. ‘MOVE.B’, ‘LEA’, etc.) :return: Whether the string is an instance of this command type

classmethod disassemble_instruction(data: bytearray) → easier68k.core.opcodes.opcode.Opcode[source]

This has a non-move opcode >>> Move.disassemble_instruction(bytearray.fromhex(‘5E01’))

MOVE.B D1,D7 >>> op = Move.disassemble_instruction(bytearray.fromhex(‘1E01’))

>>> str(op.src)
'EA Mode: EAMode.DRD, Data: 1'
>>> str(op.dest)
'EA Mode: EAMode.DRD, Data: 7'

MOVE.L (A4),(A7) >>> op = Move.disassemble_instruction(bytearray.fromhex(‘2E94’))

>>> str(op.src)
'EA Mode: EAMode.ARI, Data: 4'
>>> str(op.dest)
'EA Mode: EAMode.ARI, Data: 7'

MOVE.W #$DEAF,(A2)+ >>> op = Move.disassemble_instruction(bytearray.fromhex(‘34FCDEAF’))

>>> str(op.src)
'EA Mode: EAMode.IMM, Data: 57007'
>>> str(op.dest)
'EA Mode: EAMode.ARIPI, Data: 2'

MOVE.L ($1000).W,($200000).L >>> op = Move.disassemble_instruction(bytearray.fromhex(‘23F8100000200000’))

>>> str(op.src)
'EA Mode: EAMode.AWA, Data: 4096'
>>> str(op.dest)
'EA Mode: EAMode.ALA, Data: 2097152'

Parses some raw data into an instance of the opcode class :param data: The data used to convert into an opcode instance :return: The constructed instance or none if there was an error and

the amount of data in words that was used (e.g. extra for immediate data) or 0 for not a match
execute(simulator: easier68k.simulator.m68k.M68K)[source]

Executes this command in a simulator :param simulator: The simulator to execute the command on :return: Nothing

classmethod from_str(command: str, parameters: str)[source]

Parses a MOVE command from text.

>>> str(Move.from_str('MOVE.B', '-(A0), D1'))
'Move command: Size OpSize.BYTE, src EA Mode: EAMode.ARIPD, Data: 0, dest EA Mode: EAMode.DRD, Data: 1'
>>> str(Move.from_str('MOVE.L', 'D3, (A0)'))
'Move command: Size OpSize.LONG, src EA Mode: EAMode.DRD, Data: 3, dest EA Mode: EAMode.ARI, Data: 0'
Parameters:
  • command – The command itself (e.g. ‘MOVE.B’, ‘LEA’, etc.)
  • parameters – The parameters after the command (such as the source and destination of a move)
Returns:

The parsed command

classmethod get_word_length(command: str, parameters: str) → int[source]
>>> Move.get_word_length('MOVE', 'D0, D1')
1
>>> Move.get_word_length('MOVE.L', '#$90, D3')
3
>>> Move.get_word_length('MOVE.W', '#$90, D3')
2
>>> Move.get_word_length('MOVE.W', '($AAAA).L, D7')
3
>>> Move.get_word_length('MOVE.W', 'D0, ($BBBB).L')
3
>>> Move.get_word_length('MOVE.W', '($AAAA).L, ($BBBB).L')
5
>>> Move.get_word_length('MOVE.W', '#$AAAA, ($BBBB).L')
4

Gets what the end length of this command will be in memory :param command: The text of the command itself (e.g. “LEA”, “MOVE.B”, etc.) :param parameters: The parameters after the command :return: The length of the bytes in memory in words, as well as a list of warnings or errors encountered

classmethod is_valid(command: str, parameters: str) -> (<class 'bool'>, <class 'list'>)[source]

Tests whether the given command is valid

>>> Move.is_valid('MOVE.B', 'D0, D1')[0]
True
>>> Move.is_valid('MOVE.W', 'D0')[0]
False
>>> Move.is_valid('MOVE.G', 'D0, D1')[0]
False
>>> Move.is_valid('MOVE.L', 'D0, A2')[0]
False
>>> Move.is_valid('MOV.L', 'D0, D1')[0]
False
>>> Move.is_valid('MOVE.', 'D0, D1')[0]
False
Parameters:
  • command – The command itself (e.g. ‘MOVE.B’, ‘LEA’, etc.)
  • parameters – The parameters after the command (such as the source and destination of a move)
Returns:

Whether the given command is valid and a list of issues/warnings encountered

valid_sizes = [<OpSize.BYTE: 1>, <OpSize.WORD: 2>, <OpSize.LONG: 4>]

easier68k.core.opcodes.movea module

class easier68k.core.opcodes.movea.Movea(params: list, size: easier68k.core.enum.op_size.OpSize = <OpSize.WORD: 2>)[source]

Bases: easier68k.core.opcodes.opcode.Opcode

MOVEA: Move Address Operation: Source -> Destination Assembler Syntax: MOVEA <ea>, An Attributes: Size = (Word, Long) Description: Moves the contents of the source to the destination address register.

The size of the operation is specified as word or long. Word-size source operands are sign-extended to 32-bit quantities.

Condition Codes: Not affected Instruction Format: 00 Signature xx Size xxx DestRegister 001 Const xxx EAMode xxx EARegister Instruction Fields:

Size field - Specifies the size of the operation.
11 - Word operation 10 - Long operation

Destination Register field- specifies the destination address register.

Effective Address field - Specifies the location of the source operand.
All addressing modes can be used.

Valid Modes - All

assemble() → bytearray[source]

Assembles this opcode into hex to be inserted into memory :return: The hex version of this opcode

classmethod command_matches(command: str) → bool[source]

Checks whether a command string is an instance of this command type :param command: The command string to check (e.g. ‘MOVE.B’, ‘LEA’, etc.) :return: Whether the string is an instance of this command type

classmethod disassemble_instruction(data: bytearray) → easier68k.core.opcodes.opcode.Opcode[source]

This has a non-movea opcode >>> Movea.disassemble_instruction(bytearray.fromhex(‘1E00’))

MOVEA.W A1,A7 >>> op = Movea.disassemble_instruction(bytearray.fromhex(‘3E49’))

>>> str(op.src)
'EA Mode: EAMode.ARD, Data: 1'
>>> str(op.dest)
'EA Mode: EAMode.ARD, Data: 7'

MOVEA.W #0, A1 >>> op = Movea.disassemble_instruction(bytearray.fromhex(‘327C0000’))

>>> str(op.src)
'EA Mode: EAMode.IMM, Data: 0'
>>> str(op.dest)
'EA Mode: EAMode.ARD, Data: 1'

MOVEA.W D3, A0 >>> op = Movea.disassemble_instruction(bytearray.fromhex(‘3043’))

>>> str(op.src)
'EA Mode: EAMode.DRD, Data: 3'
>>> str(op.dest)
'EA Mode: EAMode.ARD, Data: 0'

MOVEA.W ($0A0B).W, A6 >>> op = Movea.disassemble_instruction(bytearray.fromhex(‘3C780A0B’))

>>> str(op.src)
'EA Mode: EAMode.AWA, Data: 2571'
>>> str(op.dest)
'EA Mode: EAMode.ARD, Data: 6'

Parses some raw data into an instance of the opcode class :param data: The data used to convert into an opcode instance :return: The constructed instance or none if there was an error and

the amount of data in words that was used (e.g. extra for immediate data) or 0 for not a match
execute(simulator: easier68k.simulator.m68k.M68K)[source]

Executes this command in a simulator :param simulator: The simulator to execute the command on :return: None

classmethod from_str(command: str, parameters: str)[source]

Parses a MOVEA command from text.

>>> str(Movea.from_str('MOVEA.W', 'A5, A3'))
'Movea command: Size OpSize.WORD, src EA Mode: EAMode.ARD, Data: 5, dest EA Mode: EAMode.ARD, Data: 3'
>>> str(Movea.from_str('MOVEA.L', '(A0)+, A4'))
'Movea command: Size OpSize.LONG, src EA Mode: EAMode.ARIPI, Data: 0, dest EA Mode: EAMode.ARD, Data: 4'
Parameters:
  • command – The command itself (e.g. ‘MOVE.B’, ‘LEA’, etc.)
  • parameters – The parameters after the command (such as the source and destination of a move)
Returns:

The parsed command

classmethod get_word_length(command: str, parameters: str) → int[source]
>>> Movea.get_word_length('MOVEA.W', 'D0, A1')
1
>>> Movea.get_word_length('MOVEA.W', '#$90, A0')
2
>>> Movea.get_word_length('MOVEA.L', '#$90, A3')
3
>>> Movea.get_word_length('MOVEA.W', '#$90, A3')
2
>>> Movea.get_word_length('MOVEA.W', '(A0), A1')
1
>>> Movea.get_word_length('MOVEA.W', '#$ABCDE, A0')
2
>>> Movea.get_word_length('MOVEA.L', '($AAAA).L, A6')
3
>>> Movea.get_word_length('MOVEA.W', '($AAAA).W, A5')
2

Gets what the end length of this command will be in memory :param command: The text of the command itself (e.g. “LEA”, “MOVE.B”, etc.) :param parameters: The parameters after the command :return: The length of the bytes in memory in words,

as well as a list of warnings or errors encountered
classmethod is_valid(command: str, parameters: str) -> (<class 'bool'>, <class 'list'>)[source]

Tests whether the given command is valid

>>> Movea.is_valid('MOVEA', '(A0), A1')[0]
True
>>> Movea.is_valid('MOVEA.W', '(A0)+')[0]
False
>>> Movea.is_valid('MOVE.B', '(A0), A1')[0]
False
>>> Movea.is_valid('MOVEA.W', 'D0, A2')[0]
True
>>> Movea.is_valid('MOVEA.L', '#$0A, A4')[0]
True
>>> Movea.is_valid('MOVEA.L', '($AAAA).L, A7')[0]
True
Parameters:
  • command – The command itself (e.g. ‘MOVE.B’, ‘LEA’, etc.)
  • parameters – The parameters after the command (such as the source and destination of a move)
Returns:

Whether the given command is valid and a list of issues/warnings encountered

valid_sizes = [<OpSize.WORD: 2>, <OpSize.LONG: 4>]

easier68k.core.opcodes.neg module

class easier68k.core.opcodes.neg.Neg(params: list, size: easier68k.core.enum.op_size.OpSize = <OpSize.WORD: 2>)[source]

Bases: easier68k.core.opcodes.opcode.Opcode

NEG: Negate Operation: 0 - Destination -> Destination Assembler Syntax: NEG <ea> Attributes: Size = (Byte, Word, Long) Description: Subtracts the destination operand from zero

and stores the result in the destination location. The size of the operation is specified as byte, word, or long.
Condition Codes: X - Set the same as the carry bit.
N - Set if the result is negative; cleared otherwise. Z - Set if the result is zero; cleared otherwise. V - Set if an overflow occurs; cleared otherwise. C - Cleared if the result is zero; set otherwise.

Instruction Format: 01000100 Signature xx Size xxx EAMode xxx EARegister Instruction Fields:

Size field - Specifies the size of the operation.
00 - Byte operation. 01 - Word operation. 10 - Long operation.
Effective Address field - Specifies the address of the next instruction.
Only data alterable addressing modes can be used.

Valid Modes - Dn, (An), (An)+, -(An), (xxx).W, (xxx).L

assemble() → bytearray[source]

Assembles this opcode into hex to be inserted into memory :return: The hex version of this opcode

classmethod command_matches(command: str) → bool[source]

Checks whether a command string is an instance of this command type :param command: The command string to check (e.g. ‘MOVE.B’, ‘LEA’, etc.) :return: Whether the string is an instance of this command type

classmethod disassemble_instruction(data: bytearray) → easier68k.core.opcodes.opcode.Opcode[source]

This has a non-subq opcode >>> Neg.disassemble_instruction(bytearray.fromhex(‘0280’))

NEG.B D7 >>> op = Neg.disassemble_instruction(bytearray.fromhex(‘4407’))

>>> str(op.dest)
'EA Mode: EAMode.DRD, Data: 7'

NEG.W (A5) >>> op = Neg.disassemble_instruction(bytearray.fromhex(‘4455’))

>>> str(op.dest)
'EA Mode: EAMode.ARI, Data: 5'

NEG.L (A0)+ >>> op = Neg.disassemble_instruction(bytearray.fromhex(‘4498’))

>>> str(op.dest)
'EA Mode: EAMode.ARIPI, Data: 0'

NEG.W $4000 >>> op = Neg.disassemble_instruction(bytearray.fromhex(‘44784000’))

>>> str(op.dest)
'EA Mode: EAMode.AWA, Data: 16384'

Parses some raw data into an instance of the opcode class :param data: The data used to convert into an opcode instance :return: The constructed instance or none if there was an error and

the amount of data in words that was used (e.g. extra for immediate data) or 0 for not a match
execute(simulator: easier68k.simulator.m68k.M68K)[source]

Executes this command in a simulator :param simulator: The simulator to execute the command on :return: Nothing

classmethod from_str(command: str, parameters: str)[source]

Parses a NEG command from text.

>>> str(Neg.from_str('NEG.B', 'D1'))
'Neg command: Size OpSize.BYTE, dest EA Mode: EAMode.DRD, Data: 1'
>>> str(Neg.from_str('NEG.L', '(A0)'))
'Neg command: Size OpSize.LONG, dest EA Mode: EAMode.ARI, Data: 0'
Parameters:
  • command – The command itself (e.g. ‘MOVE.B’, ‘LEA’, etc.)
  • parameters – The parameters after the command (such as the source and destination of a move)
Returns:

The parsed command

classmethod get_word_length(command: str, parameters: str) → int[source]
>>> Neg.get_word_length('NEG.B', 'D3')
1
>>> Neg.get_word_length('NEG.W', '-(A5)')
1
>>> Neg.get_word_length('NEG.B', '($BBBB).W')
2
>>> Neg.get_word_length('NEG.W', '(A0)+')
1
>>> Neg.get_word_length('NEG.W', '($BBBB).W')
2
>>> Neg.get_word_length('NEG.L', '($BBBB).L')
3

Gets what the end length of this command will be in memory :param command: The text of the command itself (e.g. “LEA”, “MOVE.B”, etc.) :param parameters: The parameters after the command :return: The length of the bytes in memory in words, as well as a list of warnings or errors encountered

classmethod is_valid(command: str, parameters: str) -> (<class 'bool'>, <class 'list'>)[source]

Tests whether the given command is valid

>>> Neg.is_valid('NEG.B', 'D1')[0]
True
>>> Neg.is_valid('NEG.W', '(A5)')[0]
True
>>> Neg.is_valid('NEG.B', '#5, D1')[0]
False
>>> Neg.is_valid('NEG.L', 'D2')[0]
True
>>> Neg.is_valid('NE.L', 'D1')[0]
False
>>> Neg.is_valid('NEG.', 'D1')[0]
False
>>> Neg.is_valid('NEG.W', '($7000).W')[0]
True
Parameters:
  • command – The command itself (e.g. ‘MOVE.B’, ‘LEA’, etc.)
  • parameters – The parameters after the command (such as the source and destination of a move)
Returns:

Whether the given command is valid and a list of issues/warnings encountered

valid_sizes = [<OpSize.BYTE: 1>, <OpSize.WORD: 2>, <OpSize.LONG: 4>]

easier68k.core.opcodes.opcode module

class easier68k.core.opcodes.opcode.Opcode[source]

Bases: object

Abstract The base class for all Opcodes. Each opcode is responsible for a few actions like assembling instructions into hex, executing itself in the simulator, checking if a string matches the syntax of the opcode, getting the length of this command in memory, validating if the parameters for a command are valid, and disassembling the instruction from bytes.

assemble() → bytes[source]

Assembles this opcode into hex to be inserted into memory :return: The hex version of this opcode

classmethod command_matches(command: str) → bool[source]

Checks whether a command string is an instance of this command type :param command: The command string to check (e.g. ‘MOVE.B’, ‘LEA’, etc.) :return: Whether the string is an instance of this command type

classmethod disassemble_instruction(data: bytes)[source]

Parses some raw data into an instance of the opcode class

Parameters:data – The data used to convert into an opcode instance
Returns:The constructed instance or none if there was an error and the amount of data in words that was used (e.g. extra for immediate data) or 0 for not a match
execute(simulator: easier68k.simulator.m68k.M68K)[source]

Executes this command in a simulator :param simulator: The simulator to execute the command on :return: Nothing

classmethod from_str(command: str, parameters: str)[source]

Parses a command from text

Parameters:
  • command – The command itself (e.g. ‘MOVE.B’, ‘LEA’, etc.)
  • parameters – The parameters after the command (such as the source and destination of a move)
Returns:

The parsed command

classmethod get_word_length(command: str, parameters: str) → int[source]

Gets what the end length of this command will be in memory :param command: The text of the command itself (e.g. “LEA”, “MOVE.B”, etc.) :param parameters: The parameters after the command :return: The length of the bytes in memory in words

classmethod is_valid(command: str, parameters: str) -> (<class 'bool'>, <class 'list'>)[source]

Tests whether the given command is valid

Parameters:
  • command – The command itself (e.g. ‘MOVE.B’, ‘LEA’, etc.)
  • parameters – The parameters after the command (such as the source and destination of a move)
Returns:

Whether the given command is valid and a list of issues/warnings encountered

easier68k.core.opcodes.opcode_or module

class easier68k.core.opcodes.opcode_or.Or(params: list, size: easier68k.core.enum.op_size.OpSize = <OpSize.WORD: 2>)[source]

Bases: easier68k.core.opcodes.opcode.Opcode

OR: Inclusive-OR Logical

Operation: Source V Destination → Destination

Syntax: Type 1: OR < ea > ,Dn Type 2: OR Dn, < ea >

Attributes: Size = (Byte, Word, Long)

Description: Performs an inclusive-OR operation on the source operand and the destination operand and stores the result in the destination location. The size of the operation is specified as byte, word, or long. The contents of an address register may not be used as an operand.

Condition Codes: X — Not affected. N — Set if the most significant bit of the result is set; cleared otherwise. Z — Set if the result is zero; cleared otherwise. V — Always cleared. C — Always cleared.

Opmode field:
Byte Word Long
Type 1:
000 001 010
Type 2:
100 101 110

Operation: Type 1: < ea > V Dn → Dn Type 2: Dn V < ea > → < ea >

NOTE: If the destination is a data register, it must be specified using the destination Dn mode, not the destination < ea > mode. Most assemblers use ORI when the source is immediate data.

assemble() → bytearray[source]

Assembles this opcode into hex to be inserted into memory :return: The hex version of this opcode

classmethod command_matches(command: str) → bool[source]

Checks whether a command string is an instance of this command type :param command: The command string to check (e.g. ‘MOVE.B’, ‘LEA’, etc.) :return: Whether the string is an instance of this command type

classmethod disassemble_instruction(data: bytearray) → easier68k.core.opcodes.opcode.Opcode[source]

This has a non-OR opcode >>> Or.disassemble_instruction(bytearray.fromhex(‘D280’))

OR.B #0, D1 >>> op = Or.disassemble_instruction(bytearray.fromhex(‘823C00’))

>>> str(op.src)
'EA Mode: EAMode.IMM, Data: 0'
>>> str(op.dest)
'EA Mode: EAMode.DRD, Data: 1'

OR.W D3, D0 >>> op = Or.disassemble_instruction(bytearray.fromhex(‘8740’))

>>> str(op.src)
'EA Mode: EAMode.DRD, Data: 3'
>>> str(op.dest)
'EA Mode: EAMode.DRD, Data: 0'

OR.L ($0A0B0C0D).L, D7 >>> op = Or.disassemble_instruction(bytearray.fromhex(‘8EB9000A0B0C’))

>>> str(op.src)
'EA Mode: EAMode.ALA, Data: 658188'
>>> str(op.dest)
'EA Mode: EAMode.DRD, Data: 7'

Parses some raw data into an instance of the opcode class :param data: The data used to convert into an opcode instance :return: The constructed instance or none if there was an error and

the amount of data in words that was used (e.g. extra for immediate data) or 0 for not a match
execute(simulator: easier68k.simulator.m68k.M68K)[source]

Executes this command in a simulator :param simulator: The simulator to execute the command on :return: Nothing

classmethod from_str(command: str, parameters: str)[source]

Parses a MOVE command from text. >>> str(Or.from_str(‘OR.B’, ‘-(A0), D1’)) ‘Or command: size OpSize.BYTE, src EA Mode: EAMode.ARIPD, Data: 0, dest EA Mode: EAMode.DRD, Data: 1’ >>> str(Or.from_str(‘OR.L’, ‘D3, (A0)’)) ‘Or command: size OpSize.LONG, src EA Mode: EAMode.DRD, Data: 3, dest EA Mode: EAMode.ARI, Data: 0’

Parameters:
  • command – The command itself (e.g. ‘MOVE.B’, ‘LEA’, etc.)
  • parameters – The parameters after the command (such as the source and destination of a move)
Returns:

The parsed command

classmethod get_word_length(command: str, parameters: str) → int[source]
>>> Or.get_word_length('OR.W', '(A0), D1')
1
>>> Or.get_word_length('OR.W', '#$0, D3')
2
>>> Or.get_word_length('OR.L', '#$ABCDE, D0')
3
>>> Or.get_word_length('OR.L', '#$A, D3')
3
>>> Or.get_word_length('OR.L', '($AAAA).L, D6')
3
>>> Or.get_word_length('OR.W', '($AAAA).W, D5')
2

Gets what the end length of this command will be in memory :param command: The text of the command itself (e.g. “LEA”, “MOVE.B”, etc.) :param parameters: The parameters after the command :return: The length of the bytes in memory in words, as well as a list of warnings or errors encountered

classmethod is_valid(command: str, parameters: str) -> (<class 'bool'>, <class 'list'>)[source]

Tests whether the given command is valid

>>> Or.is_valid('OR.B', 'D0, D1')[0]
True
>>> Or.is_valid('OR.W', 'A3, D7')[0]
False
>>> Or.is_valid('OR.L', '#$ABCD, D3')[0]
True
>>> Or.is_valid('OR.W', '($0A0B).L, D5')[0]
True
>>> Or.is_valid('ORR.W', '#AB, D3')[0]
False
>>> Or.is_valid('OR.G', 'D0, D7')[0]
False
Parameters:
  • command – The command itself (e.g. ‘MOVE.B’, ‘LEA’, etc.)
  • parameters – The parameters after the command (such as the source and destination of a move)
Returns:

Whether the given command is valid and a list of issues/warnings encountered

valid_sizes = [<OpSize.BYTE: 1>, <OpSize.WORD: 2>, <OpSize.LONG: 4>]

easier68k.core.opcodes.ori module

class easier68k.core.opcodes.ori.Ori(params: list, size: easier68k.core.enum.op_size.OpSize = <OpSize.WORD: 2>)[source]

Bases: easier68k.core.opcodes.opcode.Opcode

ORI: Inclusive-OR

Operation: Immediate Data V Destination → Destination

Syntax: ORI # < data > , < ea >

Attributes: Size = (Byte, Word, Long)

Description: Performs an inclusive-OR operation on the immediate data and the destination operand and stores the result in the destination location. The size of the operation is specified as byte, word, or long. The size of the immediate data matches the operation size.

Condition Codes: X — Not affected. N — Set if the most significant bit of the result is set; cleared otherwise. Z — Set if the result is zero; cleared otherwise. V — Always cleared. C — Always cleared.

Size field—Specifies the size of the operation. 00— Byte operation 01— Word operation 10— Long operation

Immediate field: —Data immediately following the instruction. If size = 00, the data is the low-order byte of the immediate word. If size = 01, the data is the entire immediate word. If size = 10, the data is the next two immediate words.

assemble() → bytearray[source]

Assembles this opcode into hex to be inserted into memory :return: The hex version of this opcode

classmethod command_matches(command: str) → bool[source]

Checks whether a command string is an instance of this command type :param command: The command string to check (e.g. ‘MOVE.B’, ‘LEA’, etc.) :return: Whether the string is an instance of this command type

classmethod disassemble_instruction(data: bytearray) → easier68k.core.opcodes.opcode.Opcode[source]

This has a non-ORI opcode >>> Ori.disassemble_instruction(bytearray.fromhex(‘D280’))

ORI.B #0, D1 >>> op = Ori.disassemble_instruction(bytearray.fromhex(‘00010000’))

>>> str(op.src)
'EA Mode: EAMode.IMM, Data: 0'
>>> str(op.dest)
'EA Mode: EAMode.DRD, Data: 1'

ORI.W #$A000, D0 >>> op = Ori.disassemble_instruction(bytearray.fromhex(‘0040A000’))

>>> str(op.src)
'EA Mode: EAMode.IMM, Data: 40960'
>>> str(op.dest)
'EA Mode: EAMode.DRD, Data: 0'

ORI.L #$FFFF0000, D7 >>> op = Ori.disassemble_instruction(bytearray.fromhex(‘0087FFFF0000’))

>>> str(op.src)
'EA Mode: EAMode.IMM, Data: 4294901760'
>>> str(op.dest)
'EA Mode: EAMode.DRD, Data: 7'

ORI.W #$FFFF, ($1234).W >>> op = Ori.disassemble_instruction(bytearray.fromhex(‘0078FFFF1234’))

>>> str(op.src)
'EA Mode: EAMode.IMM, Data: 65535'
>>> str(op.dest)
'EA Mode: EAMode.AWA, Data: 4660'

Parses some raw data into an instance of the opcode class :param data: The data used to convert into an opcode instance :return: The constructed instance or none if there was an error and

the amount of data in words that was used (e.g. extra for immediate data) or 0 for not a match
execute(simulator: easier68k.simulator.m68k.M68K)[source]

Executes this command in a simulator :param simulator: The simulator to execute the command on :return: Nothing

classmethod from_str(command: str, parameters: str)[source]

Parses a ORI command from text. >>> str(Ori.from_str(‘ORI.B’, ‘#$2, D1’)) ‘Ori command: size OpSize.BYTE, src EA Mode: EAMode.IMM, Data: 2, dest EA Mode: EAMode.DRD, Data: 1’ >>> str(Ori.from_str(‘ORI.L’, ‘#$FFFF8000, (A0)’)) ‘Ori command: size OpSize.LONG, src EA Mode: EAMode.IMM, Data: 4294934528, dest EA Mode: EAMode.ARI, Data: 0’

Parameters:
  • command – The command itself (e.g. ‘MOVE.B’, ‘LEA’, etc.)
  • parameters – The parameters after the command (such as the source and destination of a move)
Returns:

The parsed command

classmethod get_word_length(command: str, parameters: str) → int[source]
>>> Ori.get_word_length('ORI.B', '#$08, D1')
2
>>> Ori.get_word_length('ORI.B', '#$F1, D3')
2
>>> Ori.get_word_length('ORI.W', '#$ABCDE, D0')
2
>>> Ori.get_word_length('ORI.W', '#$000A, ($7000).W')
3
>>> Ori.get_word_length('ORI.L', '#$FFFF7000, ($1234).W')
4
>>> Ori.get_word_length('ORI.L', '#$FFFFFFFF, ($FFFF).L')
5

Gets what the end length of this command will be in memory :param command: The text of the command itself (e.g. “LEA”, “MOVE.B”, etc.) :param parameters: The parameters after the command :return: The length of the bytes in memory in words, as well as a list of warnings or errors encountered

classmethod is_valid(command: str, parameters: str) -> (<class 'bool'>, <class 'list'>)[source]

Tests whether the given command is valid

>>> Ori.is_valid('ORI.B', '#$1, D1')[0]
True
>>> Ori.is_valid('ORI.W', 'A3, D7')[0]
False
>>> Ori.is_valid('ORI.L', '#$ABCD, D3')[0]
True
>>> Ori.is_valid('ORI.L', '#$A0008000, D5')[0]
True
>>> Ori.is_valid('ORR.W', '#AB, D3')[0]
False
>>> Ori.is_valid('OR.G', 'D0, D7')[0]
False
Parameters:
  • command – The command itself (e.g. ‘MOVE.B’, ‘LEA’, etc.)
  • parameters – The parameters after the command (such as the source and destination of a move)
Returns:

Whether the given command is valid and a list of issues/warnings encountered

valid_sizes = [<OpSize.BYTE: 1>, <OpSize.WORD: 2>, <OpSize.LONG: 4>]

easier68k.core.opcodes.rts module

class easier68k.core.opcodes.rts.Rts[source]

Bases: easier68k.core.opcodes.opcode.Opcode

RTS: Return from Subroutine Operation: (SP) -> PC; SP + 4 -> SP Assembler Syntax: RTS Attributes: Unsized Description: Pulls the program counter value from the stack.

The previous program counter value is lost.

Condition Codes: Not affected Instruction Format: 0100111001110101

assemble() → bytearray[source]

Assembles this opcode into hex to be inserted into memory :return: The hex version of this opcode

classmethod command_matches(command: str) → bool[source]

Checks whether a command string is an instance of this command type :param command: The command string to check (e.g. ‘MOVE.B’, ‘LEA’, etc.) :return: Whether the string is an instance of this command type

classmethod disassemble_instruction(data: bytearray) → Optional[easier68k.core.opcodes.opcode.Opcode][source]

This has a non-RTS opcode >>> Rts.disassemble_instruction(bytearray.fromhex(‘0280’))

RTS >>> op = Rts.disassemble_instruction(bytearray.fromhex(‘4E75’))

>>> str(op)
'Rts command'

Parses some raw data into an instance of the opcode class :param data: The data used to convert into an opcode instance :return: The constructed instance or none if there was an error and

the amount of data in words that was used (e.g. extra for immediate data) or 0 for not a match
execute(simulator: easier68k.simulator.m68k.M68K)[source]

Executes this command in a simulator :param simulator: The simulator to execute the command on :return: Nothing

classmethod from_str(command: str, parameters: str)[source]

Parses a RTS command from text.

>>> str(Rts.from_str('RTS', ''))
'Rts command'
Parameters:
  • command – The command itself (e.g. ‘MOVE.B’, ‘LEA’, etc.)
  • parameters – The parameters after the command (such as the source and destination of a move)
Returns:

The parsed command

classmethod get_word_length(command: str, parameters: str) → int[source]
>>> Rts.get_word_length('RTS', '')
1
>>> Rts.get_word_length('RTS', '    ')
1

Gets what the end length of this command will be in memory :param command: The text of the command itself (e.g. “LEA”, “MOVE.B”, etc.) :param parameters: The parameters after the command :return: The length of the bytes in memory in words

classmethod is_valid(command: str, parameters: str) -> (<class 'bool'>, <class 'list'>)[source]

Tests whether the given command is valid

>>> Rts.is_valid('RTS', '')[0]
True
>>> Rts.is_valid('RTS', '(A5)')[0]
False
>>> Rts.is_valid('RTS', '#5, D1')[0]
False
>>> Rts.is_valid('RTS.W', '(A1)')[0]
False
>>> Rts.is_valid('RT', '($1000).W')[0]
False
>>> Rts.is_valid('RTS.', '(A4)')[0]
False
>>> Rts.is_valid('RTS', '($7000).W')[0]
False
Parameters:
  • command – The command itself (e.g. ‘MOVE.B’, ‘LEA’, etc.)
  • parameters – The parameters after the command (such as the source and destination of a move)
Returns:

Whether the given command is valid and a list of issues/warnings encountered

easier68k.core.opcodes.simhalt module

class easier68k.core.opcodes.simhalt.Simhalt[source]

Bases: easier68k.core.opcodes.opcode.Opcode

assemble() → bytearray[source]

Assembles this opcode into hex to be inserted into memory :return: The hex version of this opcode

classmethod command_matches(command: str) → bool[source]

Checks whether a command string is an instance of this command type :param command: The command string to check (e.g. ‘MOVE.B’, ‘LEA’, etc.) :return: Whether the string is an instance of this command type

classmethod disassemble_instruction(data: bytearray) → easier68k.core.opcodes.opcode.Opcode[source]

Parses some raw data into an instance of the opcode class

Parameters:data – The data used to convert into an opcode instance
Returns:The constructed instance or none if there was an error and the amount of data in words that was used (e.g. extra for immediate data) or 0 for not a match
execute(simulator: easier68k.simulator.m68k.M68K)[source]

Executes this command in a simulator :param simulator: The simulator to execute the command on :return: Nothing

classmethod from_str(command: str, parameters: str)[source]

Parses a SIMHALT command from memory.

>>> str(Simhalt.from_str('SIMHALT', ''))
'SIMHALT command'
Parameters:
  • command – The command itself (e.g. ‘MOVE.B’, ‘LEA’, etc.)
  • parameters – The parameters after the command (such as the source and destination of a move)
classmethod get_word_length(command: str, parameters: str) → int[source]
>>> Simhalt.get_word_length('SIMHALT', '')
2

Gets what the end length of this command will be in memory :param command: The text of the command itself (e.g. “LEA”, “MOVE.B”, etc.) :param parameters: The parameters after the command :return: The length of the bytes in memory in words

classmethod is_valid(command: str, parameters: str) -> (<class 'bool'>, <class 'list'>)[source]

Tests whether the given command is valid

>>> Simhalt.is_valid('SIMHALT', '')[0]
True
>>> Simhalt.is_valid('SIMHALT.B', '')[0]
False
>>> Simhalt.is_valid('MOVE', '')[0]
False
>>> Simhalt.is_valid('SIMHALT', ' ')[0]
True
>>> Simhalt.is_valid('SIMHALT', 'D0')[0]
False
Parameters:
  • command – The command itself (e.g. ‘MOVE.B’, ‘LEA’, etc.)
  • parameters – The parameters after the command (such as the source and destination of a move)
Returns:

Whether the given command is valid and a list of issues/warnings encountered

easier68k.core.opcodes.sub module

class easier68k.core.opcodes.sub.Sub(params: list, size: easier68k.core.enum.op_size.OpSize = <OpSize.WORD: 2>)[source]

Bases: easier68k.core.opcodes.opcode.Opcode

SUB: Subtract

Operation: Destination – Source → Destination

Syntax:
SUB < ea > ,Dn SUB Dn, < ea >

Attributes: Size = (Byte, Word, Long)

Description: Subtracts the source operand from the destination operand and stores the result in the destination. The size of the operation is specified as byte, word, or long. The mode of the instruction indicates which operand is the source, which is the destination, and which is the operand size.

Condition Codes: X — Set to the value of the carry bit. N — Set if the result is negative; cleared otherwise. Z — Set if the result is zero; cleared otherwise. V — Set if an overflow is generated; cleared otherwise. C — Set if a borrow is generated; cleared otherwise.

Opmode field
Byte Word Long Operation
Type 1:
000 001 010 Dn – < ea > → Dn
Type 2:
100 101 110 < ea > – Dn → < ea >

NOTE: If the destination is a data register, it must be specified as a destination Dn address, not as a destination < ea > address. Most assemblers use SUBA when the destination is an address register and SUBI or SUBQ when the source is immediate data.

assemble() → bytearray[source]

Assembles this opcode into hex to be inserted into memory :return: The hex version of this opcode

classmethod command_matches(command: str) → bool[source]

Checks whether a command string is an instance of this command type :param command: The command string to check (e.g. ‘MOVE.B’, ‘LEA’, etc.) :return: Whether the string is an instance of this command type

classmethod disassemble_instruction(data: bytearray) → easier68k.core.opcodes.opcode.Opcode[source]

This has a non-sub opcode >>> Sub.disassemble_instruction(bytearray.fromhex(‘0280’))

SUB.B D1,D7 >>> op = Sub.disassemble_instruction(bytearray.fromhex(‘9E01’))

>>> str(op.src)
'EA Mode: EAMode.DRD, Data: 1'
>>> str(op.dest)
'EA Mode: EAMode.DRD, Data: 7'

SUB.W $4000, D1 >>> op = Sub.disassemble_instruction(bytearray.fromhex(‘92784000’))

>>> str(op.src)
'EA Mode: EAMode.AWA, Data: 16384'
>>> str(op.dest)
'EA Mode: EAMode.DRD, Data: 1'

SUB.W D3, D0 >>> op = Sub.disassemble_instruction(bytearray.fromhex(‘9043’))

>>> str(op.src)
'EA Mode: EAMode.DRD, Data: 3'
>>> str(op.dest)
'EA Mode: EAMode.DRD, Data: 0'

SUB.W #$0A0B, D7 >>> op = Sub.disassemble_instruction(bytearray.fromhex(‘9E780A0B’))

>>> str(op.src)
'EA Mode: EAMode.AWA, Data: 2571'
>>> str(op.dest)
'EA Mode: EAMode.DRD, Data: 7'

Parses some raw data into an instance of the opcode class :param data: The data used to convert into an opcode instance :return: The constructed instance or none if there was an error and

the amount of data in words that was used (e.g. extra for immediate data) or 0 for not a match
execute(simulator: easier68k.simulator.m68k.M68K)[source]

Executes this command in a simulator :param simulator: The simulator to execute the command on :return: Nothing

classmethod from_str(command: str, parameters: str)[source]

Parses a SUB command from text.

>>> str(Sub.from_str('SUB.B', '-(A0), D1'))
'Sub command: Size OpSize.BYTE, src EA Mode: EAMode.ARIPD, Data: 0, dest EA Mode: EAMode.DRD, Data: 1'
>>> str(Sub.from_str('SUB.L', 'D3, (A0)'))
'Sub command: Size OpSize.LONG, src EA Mode: EAMode.DRD, Data: 3, dest EA Mode: EAMode.ARI, Data: 0'
Parameters:
  • command – The command itself (e.g. ‘MOVE.B’, ‘LEA’, etc.)
  • parameters – The parameters after the command (such as the source and destination of a move)
Returns:

The parsed command

classmethod get_word_length(command: str, parameters: str) → int[source]
>>> Sub.get_word_length('SUB', 'D0, D1')
1
>>> Sub.get_word_length('SUB.L', '#$90, D3')
3
>>> Sub.get_word_length('SUB.W', '#$90, D3')
2
>>> Sub.get_word_length('SUB.W', '($AAAA).L, D7')
3
>>> Sub.get_word_length('SUB.W', 'D0, ($BBBB).L')
3
>>> Sub.get_word_length('SUB.W', '($AAAA).L, ($BBBB).L')
5
>>> Sub.get_word_length('SUB.W', '#$AAAA, ($BBBB).L')
4

Gets what the end length of this command will be in memory :param command: The text of the command itself (e.g. “LEA”, “MOVE.B”, etc.) :param parameters: The parameters after the command :return: The length of the bytes in memory in words, as well as a list of warnings or errors encountered

classmethod is_valid(command: str, parameters: str) -> (<class 'bool'>, <class 'list'>)[source]

Tests whether the given command is valid

>>> Sub.is_valid('SUB.B', 'D0, D1')[0]
True
>>> Sub.is_valid('SUB.W', 'D0')[0]
False
>>> Sub.is_valid('SUB.G', 'D0, D1')[0]
False
>>> Sub.is_valid('SUB.L', 'D0, A2')[0]
False
>>> Sub.is_valid('SU.L', 'D0, D1')[0]
False
>>> Sub.is_valid('SUB.', 'D0, D1')[0]
False
Parameters:
  • command – The command itself (e.g. ‘MOVE.B’, ‘LEA’, etc.)
  • parameters – The parameters after the command (such as the source and destination of a move)
Returns:

Whether the given command is valid and a list of issues/warnings encountered

valid_sizes = [<OpSize.BYTE: 1>, <OpSize.WORD: 2>, <OpSize.LONG: 4>]

easier68k.core.opcodes.subq module

class easier68k.core.opcodes.subq.Subq(params: list, size: easier68k.core.enum.op_size.OpSize = <OpSize.WORD: 2>)[source]

Bases: easier68k.core.opcodes.opcode.Opcode

SUBQ: Subtract Quick

Operation: Destination – Immediate Data → Destination

Syntax: SUBQ # < data > , < ea >

Attributes: Size = (Byte, Word, Long)

Description: Subtracts the immediate data (1 – 8) from the destination operand. The size of the operation is specified as byte, word, or long. Only word and long operations can be used with address registers, and the condition codes are not affected. When subtracting from address registers, the entire destination address register is used, despite the operation size.

Condition Codes: X — Set to the value of the carry bit. N — Set if the result is negative; cleared otherwise. Z — Set if the result is zero; cleared otherwise. V — Set if an overflow occurs; cleared otherwise. C — Set if a borrow occurs; cleared otherwise.

Data field—Three bits of immediate data; 1 – 7 represent immediate values of 1 – 7, and zero represents eight.

Size field—Specifies the size of the operation.
00 — Byte operation 01 — Word operation 10 — Long operation
assemble() → bytearray[source]

Assembles this opcode into hex to be inserted into memory :return: The hex version of this opcode

classmethod command_matches(command: str) → bool[source]

Checks whether a command string is an instance of this command type :param command: The command string to check (e.g. ‘MOVE.B’, ‘LEA’, etc.) :return: Whether the string is an instance of this command type

classmethod disassemble_instruction(data: bytearray) → easier68k.core.opcodes.opcode.Opcode[source]

This has a non-subq opcode >>> Subq.disassemble_instruction(bytearray.fromhex(‘0280’))

SUBQ.B #2,D7 >>> op = Subq.disassemble_instruction(bytearray.fromhex(‘5507’))

>>> str(op.src)
'EA Mode: EAMode.IMM, Data: 2'
>>> str(op.dest)
'EA Mode: EAMode.DRD, Data: 7'

SUBQ.W #5,D1 >>> op = Subq.disassemble_instruction(bytearray.fromhex(‘5B41’))

>>> str(op.src)
'EA Mode: EAMode.IMM, Data: 5'
>>> str(op.dest)
'EA Mode: EAMode.DRD, Data: 1'

SUBQ.L #7,(A0) >>> op = Subq.disassemble_instruction(bytearray.fromhex(‘5F90’))

>>> str(op.src)
'EA Mode: EAMode.IMM, Data: 7'
>>> str(op.dest)
'EA Mode: EAMode.ARI, Data: 0'

SUBQ.L #3,$4000 >>> op = Subq.disassemble_instruction(bytearray.fromhex(‘57B84000’))

>>> str(op.src)
'EA Mode: EAMode.IMM, Data: 3'
>>> str(op.dest)
'EA Mode: EAMode.AWA, Data: 16384'

Parses some raw data into an instance of the opcode class :param data: The data used to convert into an opcode instance :return: The constructed instance or none if there was an error and

the amount of data in words that was used (e.g. extra for immediate data) or 0 for not a match
execute(simulator: easier68k.simulator.m68k.M68K)[source]

Executes this command in a simulator :param simulator: The simulator to execute the command on :return: Nothing

classmethod from_str(command: str, parameters: str)[source]

Parses a SUBQ command from text.

>>> str(Subq.from_str('SUBQ.B', '#4, D1'))
'Subq command: Size OpSize.BYTE, src EA Mode: EAMode.IMM, Data: 4, dest EA Mode: EAMode.DRD, Data: 1'
>>> str(Subq.from_str('SUBQ.L', '#1, (A0)'))
'Subq command: Size OpSize.LONG, src EA Mode: EAMode.IMM, Data: 1, dest EA Mode: EAMode.ARI, Data: 0'
Parameters:
  • command – The command itself (e.g. ‘MOVE.B’, ‘LEA’, etc.)
  • parameters – The parameters after the command (such as the source and destination of a move)
Returns:

The parsed command

classmethod get_word_length(command: str, parameters: str) → int[source]
>>> Subq.get_word_length('SUBQ.B', '#5, D3')
1
>>> Subq.get_word_length('SUBQ.W', '#4, ($BBBB).W')
2
>>> Subq.get_word_length('SUBQ.L', '#7, ($BBBB).W')
2
>>> Subq.get_word_length('SUBQ.W', '#1, ($BBBB).L')
3
>>> Subq.get_word_length('SUBQ.W', '#8, ($BBBB).L')
3
>>> Subq.get_word_length('SUB.L', '#5, ($BBBB).L')
3

Gets what the end length of this command will be in memory :param command: The text of the command itself (e.g. “LEA”, “MOVE.B”, etc.) :param parameters: The parameters after the command :return: The length of the bytes in memory in words, as well as a list of warnings or errors encountered

classmethod is_valid(command: str, parameters: str) -> (<class 'bool'>, <class 'list'>)[source]

Tests whether the given command is valid

>>> Subq.is_valid('SUBQ.B', '#2, D1')[0]
True
>>> Subq.is_valid('SUBQ.W', 'D0')[0]
False
>>> Subq.is_valid('SUBQ.G', '#5, D1')[0]
False
>>> Subq.is_valid('SUBQ.L', 'D0, A2')[0]
False
>>> Subq.is_valid('SU.L', '#2, D1')[0]
False
>>> Subq.is_valid('SUBQ.', '#5, D1')[0]
False
>>> Subq.is_valid('SUBQ.W', '#2, #6500')[0]
False
Parameters:
  • command – The command itself (e.g. ‘MOVE.B’, ‘LEA’, etc.)
  • parameters – The parameters after the command (such as the source and destination of a move)
Returns:

Whether the given command is valid and a list of issues/warnings encountered

valid_sizes = [<OpSize.BYTE: 1>, <OpSize.WORD: 2>, <OpSize.LONG: 4>]

easier68k.core.opcodes.trap module

class easier68k.core.opcodes.trap.Trap(param: easier68k.core.enum.trap_vector.TrapVectors)[source]

Bases: easier68k.core.opcodes.opcode.Opcode

TRAP

Operation: Trap

1 → S-Bit of SR *SSP – 2 → SSP; Format/Offset → (SSP); SSP – 4 → SSP; PC → (SSP); SSP – 2 → SSP; SR → (SSP); Vector Address → PC *The MC68000 and MC68008 do not write vector offset or format code to the system stack.

Syntax: TRAP # < vector >

Attributes: Unsized

Description: Causes a TRAP # < vector > exception. The instruction adds the immediate operand (vector) of the instruction to 32 to obtain the vector number. The range of vector values is 0 – 15, which provides 16 vectors.

Condition Codes: Not affected.

assemble() → bytes[source]

Assembles this opcode into hex to be inserted into memory :return:

classmethod command_matches(command: str) → bool[source]

Checks if a command string matches :param command: :return:

classmethod disassemble_instruction(data: bytearray) → easier68k.core.opcodes.opcode.Opcode[source]

Parses raw data into an instance of Trap :param data: :return:

execute(simulator: easier68k.simulator.m68k.M68K)[source]

Executes this command in a simulator :param simulator: :return:

classmethod from_str(command: str, parameters: str)[source]

Parses a TRAP command from text

>>> str(Trap.from_str('TRAP', '#15'))
'TRAP 15'
>>> str(Trap.from_str('trap', '#%1111'))
'TRAP 15'
Parameters:
  • command
  • parameters
Returns:

classmethod get_word_length(command: str, parameters: str) → int[source]

Get the length in words that this will take up in memory :param command: :param parameters: :return:

classmethod is_valid(command: str, parameters: str) -> (<class 'bool'>, <class 'list'>)[source]

Tests whether the given command is valid :param command: :param parameters: :return: