Ambil presents

ASM-to-Hex code reference

V 1.10

 

Welcome to my Motorola 68000 programming reference. It consists a table containing useful examples of the 68k instructions, and it can be a very nice tool for everyone who is hacking MegaDrive / Genesis games in a hex editor. For your help and confort, the parameters in the ASM commands have been coloured along with their respective places in the 16-bit instruction codes.

 

The guide may have plenty of errors, contact me in case you have feedback for me regarding these assembly notes. Next versions of this reference will certainly be more complete as you cooperate in it.

 

WARNING: This is a programming reference that requires several previous technical knowledge in order to be understood. If you wish to get started in the 68k assembly code, have a read in Hacking CulT’s guides to get started, get the official Motorola 68000 documentation from Eidolon's Inn and read some useful examples at SWS2B’s Engineering Archive.

 

 

 

Assembly language

Binary instruction

Hex code

 

Abcd.b d0, d1

1100 0011 0000 0000

C300

Abcd.b –(a2), -(a3)

1100 0111 0001 1010

C71A

Add.b #$31, d0

1101 0000 0011 1100

D03C 0031

Add.w d1, (a1)

1101 0011 0101 0001

D351

Add.l d2, ($FFFFFF20).l

1101 0101 1011 1001

D5B9 FF20

Adda.w (a0), a1

1101 0010 1101 0000

D2D0

Adda.w ($FFFFF100).w, a1

1101 0010 1111 1000

D2F8 F100

Adda.l ($FFFFF100).l, a1

1101 0011 1111 1001

D3F9 F100

Adda.w #$1337, a1

1101 0010 1111 1100

D2FC 1337

Addi.b #$20, d1

0000 0110 0000 0001

0601 0020

Addi.w #$1337, ($FFFFF100).w

0000 0110 0111 1000

0678 1337 F100

Addi.l #$19650917, ($FFFFF100).l

0000 0110 1011 1001

06F9 1965 0917 F100

Addq.b #1, ($FFFFF100).w

0101 0010 0011 1000

5238 F100

Addq.b #2, ($FFFFF100).w

0101 0100 0011 1000

5438 F100

Addq.b #8, ($FFFFF100).w

0101 0000 0011 1000

5038 F100

Addx.b d0, d1

1101 0011 0000 0000

D300

Addx.w –(a1), -(a0)

1101 0001 0100 1001

D149

And.b #$31, d0

1100 0000 0011 1100

C03C 0031

And.w d1, (a1)

1100 0011 0101 0001

C351

Add.l d2, ($FFFFFF20).l

1100 0101 1011 1001

C5B9 FF20

Andi.b #$36, d1

0000 0010 0000 0001

0201 0036

Andi.w #$2005, ($FFFFF100).w

0000 0010 0111 1000

0238 2005 F100

Andi.b #$3F, CCR

0000 0010 0011 1100

023C 003F

Asl.w #1, d0

1110 0011 0100 0000

E340

Asr.l d1, d2

1110 0010 1010 0010

E2A2

Asl.w (a0)

1110 0001 1101 0000

E1B0

Asr.w ($FFFFF704).w

1110 0000 1111 1000

E0F8 F704

Bchg.b d1, ($FFFFF04C).w

0000 0011 0111 1000

0378 F40C

Bchg.l d0, d2

0000 0001 0100 0010

0143

Bchg.b #7, ($FFFFF050).w

0000 1000 0111 1000

0878 0007 F050

Bchg.b #10, (a1)

0000 1000 0101 0001

0851 000A

Bchg.l #21, d3

0000 1000 0100 0011

0843 0015

Bclr.b d1, ($FFFFF04C).w

0000 0011 1011 1000

03B8 F40C

Bclr.l d0, d2

0000 0001 1000 0010

0183

Bclr.b #7, ($FFFFF050).w

0000 1000 1011 1000

08B8 0007 F050

Bclr.b #10, (a1)

0000 1000 1001 0001

0891 000A

Bclr.l #21, d3

0000 1000 1000 0011

0883 0015

Bset.b d1, ($FFFFF04C).w

0000 0011 1111 1000

03F8 F40C

Bset.l d0, d2

0000 0001 1100 0010

01C3

Bset.b #7, ($FFFFF050).w

0000 1000 1111 1000

08F8 0007 F050

Bset.b #10, (a1)

0000 1000 1101 0001

08D1 000A

Bset.l #21, d3

0000 1000 1100 0011

08C3 0015

Btst.b d1, ($FFFFF04C).w

0000 0011 0011 1000

0338 F40C

Btst.l d0, d2

0000 0001 0000 0010

0103

Btst.b #7, ($FFFFF050).w

0000 1000 0011 1000

0838 0007 F050

Btst.b #10, (a1)

0000 1000 0001 0001

0811 000A

Btst.l #21, d3

0000 1000 0000 0011

0803 0015

Bra.s #$24

0110 0000 0010 0100

6024

Bra #$4E1A

0110 0000 0000 0000

6000 4E1A

Bsr.s #$10

0110 0001 0001 0000

6110

Bhi.s #$10

0110 0010 0001 0000

6210

Bls.s #$10

0110 0011 0001 0000

6310

Bcc.s #$10

0110 0100 0001 0000

6410

Bcs.s #$10

0110 0101 0001 0000

6510

Bne.s #$10

0110 0110 0001 0000

6610

Beq.s #$10

0110 0111 0001 0000

6710

Bvc.s #$10

0110 1000 0001 0000

6810

Bvs.s #$10

0110 1001 0001 0000

6910

Bpl.s #$10

0110 1010 0001 0000

6A10

Bmi.s #$10

0110 1011 0001 0000

6B10

Bge.s #$10

0110 1100 0001 0000

6C10

Blt.s #$10

0110 1101 0001 0000

6D10

Bgt.s #$10

0110 1110 0001 0000

6E10

Ble.s #$10

0110 1111 0001 0000

6F10

Chk.w (a0), d1

0100 0011 1001 0000

4390

Chk.w ($FFFFFF36).w, d6

0100 1101 1011 1000

4DB8 FF36

Clr.l d0

0100 0010 1000 0000

4280

Clr.w ($FFFF4500).w

0100 0010 0111 1000

4278 4500

Cmp.b ($FFFF4500).w, d0

1011 0000 0011 1000

B038 4500

Cmp.w (a1), d3

1011 0110 0101 0001

B651

Cmp.l d4, d5

1011 1010 1000 0100

BA84

Cmpa.w ($FFFF4500).w, a0

1011 0000 1111 1000

B0F8 4500

Cmpa.l (a1), a3

1011 0111 1101 0001

B7D1

Cmpa.l d4, a5

1011 1011 1100 0100

BBC4

Cmpi.b #$26, ($FFFFFFE4).w

0000 1100 0011 1000

0C38 0026 FFE4

Cmpi.w #$4170, ($FFFFFFB0).w

0000 1100 0111 1000

0C78 4170 FFB0

Cmpi.l #$0, d2

0000 1100 1000 0010

0C82 0000 0000

Cmpm.b (a1)+, (a2)+

1011 0101 0000 1001

B509

Cmpm.w (a3)+, (a4)+

1011 1001 0100 1011

B94B

Cmpm.l (a5)+, (a6)+

1011 1101 1000 1101

BD8D

Dbf.w d0, $556A

0101 0001 1100 0000

51C0 556A

Divs.w #$A, d0

1000 0001 1111 1100

81FC 000A

Divu.w ($FFFFF314).w, d1

1000 0010 1111 1000

82F8 F314

Eor.b d0, #$31,

1011 0000 0011 1100

B03C 0031

Eor.w d1, (a1)

1011 0011 0101 0001

B351

Eor.l d2, ($FFFFFF20).l

1011 0101 1011 1001

B5B9 FF20

Eori.b #$80, ($FFFFF00E).w

0000 1010 0011 1000

0A38 0080 F00E

Eori.w #$3119, ($FFFFF010).w

0000 1010 0111 1000

0A78 3119 F010

Eori.l #$FFFF, (a0)

0000 1010 1001 0000

0A90 FFFF

Exg.l d1, d2

1100 0011 0100 0010

C342

Exg.l a3, a4

1100 0111 0100 1100

C74C

Exg.l d5, a6

1100 1011 1000 1110

CB8E

Ext.w d0

0100 1000 1000 0000

4880

Ext.l d1

0100 1000 1100 0001

48C1

Illegal

0100 1010 1111 1100

4AFC

Jmp (a1)

0100 1110 1100 0001

4EA1

Jmp $65A70

0100 1110 1111 1001

4EF9 0006 5A70

Jsr $4B98C

0100 1110 1011 1001

4EB9 0004 B98C

Lea.l (a1), a2

0100 0101 1101 0001

45D1

Lea.l ($FFFFFFF4).w, a0

0100 0001 1111 1000

41F8 FFF4

Link.w a4, #$1087

0100 1110 0101 0100

4E54 1087

Lsl.b #1, d0

1110 0011 0000 1001

E309

Lsr.w d2, d1

1110 0100 0110 1010

E54A

Move.b #$64, ($FFFFFFE0).w

0001 0001 1111 1100

11FC 0064 FFE0

Move.w #$03E8, ($FFFFFFE0).w

0011 0001 1111 1100

31FC 03E8 FFE0

Move.l #$05F5E100, ($FFFFFFE0).l

0010 0001 1111 1100

21FC 05F5 E100 FFE0

Move.b #$20, d1

0001 0010 0011 1100

123C 0020

Move.w ($FFFF01A5).w, ($FFFFFFE0).w

0011 0011 1111 1001

33F9 01A5 FFE0

Move.l d1, ($FFFFFFE0).w

0010 0011 1100 0001

23C1 FFE0

Move.w CCR, d0

0100 0010 1100 0000

42C0

Move.w ($FFFFFC70).w, CCR

0100 0100 1111 1000

42F8 FC70

Move.w #%1001, CCR

0100 0100 1111 1100

42FA 0009

Move.w SR, ($FFFFFC74).w

0100 0000 1111 1000

40F8 FC74

Movea.w #$6000, a4

0011 1000 0111 1100

387C 6000

Moveq.l #$80, d1

0111 0010 1000 0000

7280

Muls.w #$19, d1

1100 0011 1111 1100

E3FC 0019

Mulu.w #$19, d2

1100 0100 1111 1100

E4FC 0019

Nbcd.b d0

0100 1000 0000 0000

4800

Nbcd.b ($FFFFFF00).w

0100 1000 0011 1000

4838 FF00

Neg.w ($FFFFFE26).w

0100 0100 0111 1000

4478 FE26

Neg.l d0

0100 0100 1000 0000

4480

Negx.w ($FFFFFE26).w

0100 0000 0111 1000

4078 FE26

Negx.l d0

0100 0000 1000 0000

4080

Nop

0100 1110 0111 0001

4E71

Not.w ($FFFFFE26).w

0100 0110 0111 1000

4678 FE26

Not.l d0

0100 0110 1000 0000

4680

Or.b #$31, d0

1000 0000 0011 1100

403C 0031

Or.w d1, (a1)

1000 0011 0101 0001

4351

Or.l d2, ($FFFFFF20).l

1000 0101 1011 1001

45B9 FF20

Ori.b #$36, d1

0000 0000 0000 0001

0001 0036

Ori.w #$2005, ($FFFFF100).w

0000 0000 0111 1000

0074 2005 F100

Pea.l ($FFFFE53C).w

0100 1000 0111 1000

4878 E53C

Rol.w d0, d1

1110 0001 0111 1001

E1E9

Ror.l #1, d3

1110 0010 1001 1011

E69A

Rol.w ($FFFFFFE0).w

1110 0111 1111 1000

E7F8 FFE0

Roxl.w d0, d1

1110 0001 0111 0001

E1F1

Roxr.l #1, d3

1110 0010 1001 0011

E693

Roxl.w ($FFFFFFE0).w

1110 0101 1111 1000

E5F8 FFE0

Rtd #$1E32

0100 1110 0111 0100

4E74 1E32

Rtr

0100 1110 0111 0111

4E77

Rts

0100 1110 0111 0101

4E75

Sbcd.b d0, d1

1000 0001 0000 0000

8100

Sbcd.b –(a2), -(a3)

1000 0011 0001 0010

8312

St.b ($FFFFF000).w

0101 0000 1111 1000

50F0 F000

Sf.b ($FFFFF000).w

0101 0001 1111 1000

51F0 F000

Shi.b ($FFFFF000).w

0101 0010 1111 1000

52F0 F000

Sls.b ($FFFFF000).w

0101 0011 1111 1000

53F0 F000

Scc.b ($FFFFF000).w

0101 0100 1111 1000

54F0 F000

Scs.b ($FFFFF000).w

0101 0101 1111 1000

55F0 F000

Sne.b ($FFFFF000).w

0101 0110 1111 1000

56F0 F000

Seq.b ($FFFFF000).w

0101 0111 1111 1000

57F0 F000

Svc.b ($FFFFF000).w

0101 1000 1111 1000

58F0 F000

Svs.b ($FFFFF000).w

0101 1001 1111 1000

59F0 F000

Spl.b ($FFFFF000).w

0101 1010 1111 1000

5AF0 F000

Smi.b ($FFFFF000).w

0101 1011 1111 1000

5BF0 F000

Sge.b ($FFFFF000).w

0101 1100 1111 1000

5CF0 F000

Slt.b ($FFFFF000).w

0101 1101 1111 1000

5DF0 F000

Sgt.b ($FFFFF000).w

0101 1110 1111 1000

5EF0 F000

Sle.b ($FFFFF000).w

0101 1111 1111 1000

5FF0 F000

Sub.b #$31, d0

1001 0000 0011 1100

903C 0031

Sub.w d1, (a1)

1001 0011 0101 0001

9351

Sub.l d2, ($FFFFFF20).l

1001 0101 1011 1001

95B9 FF20

Suba.w (a0), a1

1001 0010 1101 0001

92D1

Suba.w ($FFFFF100).w, a2

1001 0100 1111 1000

92F8 F100

Suba.l ($FFFFF100).l, a3

1001 1011 1111 1001

93F9 F100

Suba.w #$1337, a4

1001 1100 1111 1100

92FC 1337

Subi.b #$20, d1

0000 0100 0000 0001

0601 0020

Subi.w #$1337, ($FFFFF100).w

0000 0100 0111 1000

0678 1337 F100

Subi.l #$19650917, ($FFFFF100).l

0000 0100 1111 1001

06F9 1965 0917 F100

Subq.b #1, ($FFFFF100).w

0101 0011 0011 1000

5238 F100

Subq.b #2, ($FFFFF100).w

0101 0101 0011 1000

5438 F100

Subq.b #8, ($FFFFF100).w

0101 0001 0011 1000

5038 F100

Subx.b d0, d1

1001 0011 0000 0000

9300

Subx.w –(a1), -(a0)

1001 0001 0100 1001

9149

Swap.w d0

0100 1000 0100 0000

4840

Tas.b ($FFFFFE00).w

0100 1010 1111 1000

4AF8 FE00

Trap #1

0100 1110 0100 0001

4E41

Trapv

0100 1110 0111 0110

4E76

Tst.l d1

0100 1010 1000 0001

4A81

Tst.w ($FFFFAA80).w

0100 1010 0111 1000

4A78 AA80

Tst.b ($FFFFAA80).w

0100 1010 0011 1000

4A38 AA80

Unlk a0

0100 1110 0101 1000

4E58

 

 

© 2005 Ambil. Special thanks go out to:

 

Aurochs – we both cooperate in Shadow Fire’s hacking project, The Lost Land 2

drx – for his assembly guides in Hacking CulT

Eidolon – for hosting the 68000 Programmer Guide

JoseTheBest – for being my 68k ASM teacher ;)

LaMuerte – for inviting me to join SWS2B

Mask of Destiny – he also has some assembly guides

Nemesis – for his Sonic ROM hacking guides

Sonic Hachelle-Bee – his notes have been very useful

Sonic 65 – he made me understand some instruction in hex

Simon Wai – for having an awesome website and forums, where I could meet all these people

StephenUK – for supporting me in this project

voice – for running the #sws2b IRC channel, and allow me to contact some Tech Members

Wyvernlord II – the Gallery of Dumbasses fuckin 0wnz

 

And maybe I forgot someone...

 

 

Well, that’s all folks. Hope you find it useful. You don’t like it? I don’t really give a shit. You think it’s great? Contact me and give me some advice. Thanks for your interest.