Advertisement
retrophil

Megadrive

Nov 19th, 2018
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. helpful: https://www.rapidtables.com/convert/number/hex-to-decimal.html
  2.  
  3. --DATA SIZES--
  4.  
  5. size                    binary                                          hexadecimal
  6.  
  7. nybble                  0010                                            2
  8. byte                    0010 1100                                       2C
  9. word                    0010 1100 1111 0101                             2C F5
  10. long-word               0010 1100 1111 0101 1001 1101 0111 0110         2C F5 9D 76
  11. ---------------------------------------------------------------------------------------------------------------------------------------
  12. If you group two nybbles together (e.g. 0100 1101), you get what is known as a “byte”.
  13. If you group two “bytes” together (e.g. 0100 1101 1011 0000), you get what is known as a “word”.
  14. If you group two “words” together (e.g. 0100 1101 1011 0000 1111 0001 0000 0110), you get what is known as a “long-word”.
  15. ---------------------------------------------------------------------------------------------------------------------------------------
  16.  
  17. --SYMBOLS--
  18.  
  19. #   Number that follows is an offset/address.
  20. $   Hex numbers will follow.
  21. %   Binary numbers will follow.
  22. " " Nothing means it'll be a decimal number that follows.
  23. ---------------------------------------------------------------------------------------------------------------------------------------
  24.  
  25. --ADDRESS REGISTERS--
  26.  
  27. move.b  #$44, (a0)          moves 44 into (not replace) a0.
  28.  
  29. ---------------------------------------------------------------------------------------------------------------------------------------
  30. scenario: (a0) contains 00000039       
  31.  
  32. move.b    #$9B,$04(a0)              =   #$9B goes into 00000039; then add 04
  33.  
  34. Answer: 0000003D
  35. ---------------------------------------------------------------------------------------------------------------------------------------
  36. movea.l   #$00000010,a0
  37. move.b    #$20,$01(a0)
  38. move.b    #$40,$02(a0)
  39. move.b    #$F0,$0F(a0)
  40. move.b    #$0E,(a0)
  41.  
  42. 00000010 is moved into a0
  43. 20 is moved to 00000010 plus 01     =   00000011
  44. 40 is moved to 00000010 plus 02     =   00000012
  45. F0 is moved to 00000010 plus 0F     =   0000001F
  46. 0E is moved to 00000010 directly    =   00000010
  47. ---------------------------------------------------------------------------------------------------------------------------------------
  48.  
  49. --AUTO INCREMENT--
  50.  
  51. movea.l   #$00000020,a0             =   00000020
  52. move.b    #$B5,(a0)+                =   00000021        (B5 moves into 00000020 then is increamented by 1)
  53. move.b    #$11,(a0)+                =   00000022
  54. ---------------------------------------------------------------------------------------------------------------------------------------
  55. movea.l   #$00000020,a0             =   00000020  (spreads over to 21 because of its size)
  56. move.w    #$A90E,(a0)+              =   00000022
  57. ---------------------------------------------------------------------------------------------------------------------------------------
  58.  
  59. --AUTO DECREMENT--
  60.  
  61. movea.l   #$00000020,a0             =   00000020
  62. move.b    #$2E,-(a0)                =   0000001F
  63. ---------------------------------------------------------------------------------------------------------------------------------------
  64. move.w    d0,d1                     =   this will copy whatevers in d0 to d1 (words worth amount)
  65. ---------------------------------------------------------------------------------------------------------------------------------------
  66. move.w    d0,$0000104E              =   If d0 contains 99004980, then 4980 is copied to memory at offsets 0000104E and 0000104F
  67. ---------------------------------------------------------------------------------------------------------------------------------------
  68.  
  69. --ADD--
  70.  
  71. addi.b    #$08,d0       =   adds 8 to whatevers in d0 (a bytes worth)
  72. ---------------------------------------------------------------------------------------------------------------------------------------
  73. addi.b    #$08,d0       =   if d0 started with 00001008, after the instruction d0 will contain 00001010 (because, 8 9 A B C D E F 10)
  74. ---------------------------------------------------------------------------------------------------------------------------------------
  75. add.w     d0,d1         =   If d0 contains FED00100, and d1 contains 00000100, after the instruction d1 will contain 00000200.
  76. ---------------------------------------------------------------------------------------------------------------------------------------
  77.  
  78. --SUB--
  79.  
  80. subi.b    #$10,d0           =   if d0 has 0000002E, after it will have 0000001E
  81. ---------------------------------------------------------------------------------------------------------------------------------------
  82.  
  83. --NOT--
  84.  
  85. not.b     d0                =   let’s say d0 contains FE800174; 74 is 0111 0100 in binary; 0111 0100 becomes 1000 1011. 74 > 8B
  86. ---------------------------------------------------------------------------------------------------------------------------------------
  87.  
  88. --SWAP--
  89.  
  90. swap      d0            =   2222EEEE changes to EEEE2222
  91. ---------------------------------------------------------------------------------------------------------------------------------------
  92.  
  93. --EXG--
  94.  
  95. exg.l     d0,d1         =   if d0 has 00000000 and d1 has 11111111; d0 will have 11111111 and d1 will have 00000000
  96. ---------------------------------------------------------------------------------------------------------------------------------------
  97.  
  98. --CLR--                 =   if d0 has 01234567, d0 will have 01234500 (wipes a bytes worth)
  99. ---------------------------------------------------------------------------------------------------------------------------------------
  100.  
  101. --AND--
  102.  
  103. Scenario: d0 contains 01234567
  104.  
  105. andi.b    #$E2,d0           =   E2 in binary is 11100010 | 67 in binary is 01100111.  Each number is compared to true or false.  1 & 1                      scores 1 anything else will score 0.
  106.  
  107. Answer: 01100010            =   E2 AND 67 = 62  (Answers 62)
  108. ---------------------------------------------------------------------------------------------------------------------------------------
  109.  
  110. --OR--
  111.  
  112. Scenario: d0 contains 01234567
  113.  
  114. ori.b     #$EC,d0           =   EC in binary is 11101100 and as we know 67 in binary is 01100111.  Each number is compared to true and false.                           Anything with a 1 in it scores 1, otherwise its 0.
  115.  
  116. Answer: 11101111            =   EC OR 67 = EF   (Answers EF)
  117. ---------------------------------------------------------------------------------------------------------------------------------------
  118. --EOR-- / --XOR--
  119.  
  120. Scenario: do contains 01234567
  121.  
  122. eori.b    #$E2,d0           =   E2 in binary is 11100010 and yet again as we know 67 in binary is 01100111.  Each number is comapred to true and                    false.  Anything with just a single 1 in it will score 1 otherwise it'll be a 0.
  123.  
  124. Answer: 10000101            =   E2 XOR 67 = 85  (Answers 85)
  125. ---------------------------------------------------------------------------------------------------------------------------------------
  126. --BSET--
  127.  
  128. Scenario: d0 is cleared, 32bits all contain 0's
  129.  
  130. bset.l    #$0E,d0           =   This puts a 1 in 0E, from which in binary is 0000 0000 0000 0000 0100 0000 0000 0000, from which in hex is 00004000
  131.  
  132. Notes:                          If what ever is being injected takes the register over 1F (1F is the highest number); the register will     wrap back round to 00 again. 20 becomes 00, 21 is 01, 22 is 02 etc... needs to be within range.
  133. ---------------------------------------------------------------------------------------------------------------------------------------
  134. --BCLR--
  135.  
  136. Notes: Does the same as BSET but instead of putting a 1 in, it puts a 0.
  137. ---------------------------------------------------------------------------------------------------------------------------------------
  138. --BCHG--
  139.  
  140. Notes: Swaps whatever the binary number is. 1 becomes 0, 0 becomes 1.
  141. ---------------------------------------------------------------------------------------------------------------------------------------
  142. --SIGNED-- / --UNSIGNED--
  143.  
  144. 00 to 7F                =   signed. (negative)
  145. 80 to FF                =   signed. (positive)
  146.  
  147. 00 to FF                =   unsigned. (positive)
  148. ---------------------------------------------------------------------------------------------------------------------------------------
  149. --NEG--
  150.  
  151. Scenario: d0 has 220002
  152.  
  153. neg.b     d0            =   002200FE (02 to FE, +2 to -2, rolls back)
  154.  
  155. Notes: This wont work with neutral numbers, 00 can't cancel out 00; 80 is the beginning of the negative, therefore it will have nothing (00).
  156. ---------------------------------------------------------------------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement