Skip to content

Commit

Permalink
Added some more op defs.
Browse files Browse the repository at this point in the history
  • Loading branch information
ExpandingMan committed May 15, 2017
1 parent ed3050c commit 3c45ea3
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/boilerplate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ function opdict(opcode::UInt8, nbytes::Int, ncycles::Int)
:(OPCODES[$opcode] = ($(opfuncname(opcode)), $nbytes, $ncycles))
end

function opdef_Implicit(opname::Symbol, opcode::UInt8)
fname = opfuncname(opcode)
quote
$fname(cs::Chipset, bytes::AbstractVector{UInt8}) = $opname(cs.cpu)
end
end

function opdef_Immediate(opname::Symbol, opcode::UInt8)
fname = opfuncname(opcode)
Expand Down
78 changes: 78 additions & 0 deletions src/opcodes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,84 @@ end
Absolute, 0x8c, 2, 4
end

@opdef tax! begin
Implicit, 0xaa, 1, 2
end

@opdef tay! begin
Implicit, 0xa8, 1, 2
end

@opdef txa! begin
Implicit, 0x8a, 1, 2
end

@opdef tya! begin
Implicit, 0x98, 1, 2
end

@opdef tsx! begin
Implicit, 0xba, 1, 2
end

@opdef txs! begin
Implicit, 0x9a, 1, 2
end

@opdef pha! begin
Implicit, 0x48, 1, 2
end

@opdef php! begin
Implicit, 0x08, 1, 3
end

@opdef pla! begin
Implicit, 0x68, 1, 4
end

@opdef plp! begin
Implicit, 0x28, 1, 4
end

@opdef and! begin
Immediate, 0x29, 2, 2
ZeroPage, 0x25, 2, 3
ZeroPageX, 0x35, 2, 4
Absolute, 0x2d, 3, 4
AbsoluteX, 0x3d, 3, 4
AbsoluteY, 0x39, 3, 4
IndirectX, 0x21, 2, 6
IndirectY, 0x31, 2, 5
end

@opdef eor! begin
Immediate, 0x49, 2, 2
ZeroPage, 0x45, 2, 3
ZeroPageX, 0x55, 2, 4
Absolute, 0x4d, 3, 4
AbsoluteX, 0x5d, 3, 4
AbsoluteY, 0x59, 3, 4
IndirectX, 0x41, 2, 6
IndirectY, 0x51, 2, 5
end

@opdef ora! begin
Immediate, 0x09, 2, 2
ZeroPage, 0x05, 2, 3
ZeroPageX, 0x15, 2, 4
Absolute, 0x0d, 3, 4
AbsoluteX, 0x1d, 3, 4
AbsoluteY, 0x19, 3, 4
IndirectX, 0x01, 2, 6
IndirectY, 0x11, 2, 5
end

@opdef bit! begin
ZeroPage, 0x24, 2, 3
Absolute, 0x2c, 3, 4
end

#===================================================================================================
</opcodes>
===================================================================================================#
4 changes: 3 additions & 1 deletion test/opcodes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ cs.ram[0xa001] = 0x06

# @p Sim6502.op0x65!(cs, [0x00])
# @p Sim6502.op0x6d!(cs, [0x01, 0xa0])
@program [0x65, 0x00, 0x6d, 0x01, 0xa0]
# @p Sim6502.op0xaa!(cs, UInt8[])
@program [0x65, 0x00, 0x6d, 0x01, 0xa0, 0xaa]

@p tick!(cs)
@p tick!(cs)
@p tick!(cs)

0 comments on commit 3c45ea3

Please sign in to comment.