Vegetarianboy30

rookie 68000 programming session results

Jan 19th, 2021
1,105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. I left a list using a load of instructions here that was used during a rookie programming session, so, let’s see how well I did.
  2.  
  3.  
  4. Results
  5.  
  6.           move.w    #$0010,d0
  7.           mulu.w    #$0003,d0
  8.           neg.w     d0
  9.           ext.l     d0
  10.           asr.l     #$01,d0
  11.           ror.w     #$01,d0
  12.           ext.l     d0
  13.           divu.w    #$0002,d0
  14.  
  15. d0 starts with 00000000.
  16.  
  17.           move.w    #$0010,d0
  18.  
  19. d0 now contains 00000010.
  20.  
  21.           mulu.w    #$0003,d0
  22.  
  23. 0010 x 0003 = 00000030
  24.  
  25. d0 now contains 00000030.
  26.  
  27.           neg.w     d0
  28.  
  29. 0030 is changed to -0030 (FFD0).  Now d0 contains 0000FFD0.
  30.  
  31.           ext.l     d0
  32.  
  33. The word FFD0 inside d0 is extended to long-word, currently d0 contains:
  34.  
  35. 0000 0000 0000 0000 1111 1111 1101 0000
  36.  
  37. The MSB of FFD0 is 1 (set), so d0 is extended to:
  38.  
  39. 1111 1111 1111 1111 1111 1111 1101 0000
  40.  
  41. Now d0 contains FFFFFFD0.
  42.  
  43.           asr.l     #$01,d0
  44.  
  45. d0 contains FFFFFFD0 in binary:
  46.  
  47. 1111 1111 1111 1111 1111 1111 1101 0000
  48.  
  49. Arithmetically shifting right by 1 will give us:
  50.  
  51. > 1111 1111 1111 1111 1111 1111 1110 1000 >
  52.  
  53. Now d0 contains FFFFFFE8.
  54.  
  55.           ror.w     #$01,d0
  56.  
  57. The word FFE8 of d0 is now rotated right by 01 bit:
  58.  
  59. > 0111 1111 1111 0100 v
  60. ^ < < < < < < < < < < <
  61.  
  62. Now d0 contains FFFF7FF4.
  63.  
  64.           ext.l     d0
  65.  
  66. The word 7FF4 inside d0 is extended to long-word, currently d0 contains:
  67.  
  68. 1111 1111 1111 1111 0111 1111 1111 0100
  69.  
  70. The MSB of 7FF4 is 0 (clear), so d0 is extended to:
  71.  
  72. 0000 0000 0000 0000 0111 1111 1111 0100
  73.  
  74. Now d0 contains 00007FF4.
  75.  
  76.           divu.w    #$0002,d0
  77.  
  78. 00007FF4 ÷ 0002 = 3FFA r0000
  79.  
  80. Now d0 contains 00003FFA.
  81.  
  82. And there is my answer, d0 contains 00003FFA afterwards.  Please remember, I don’t expect myself  to work these all out in my head, if I’d prefer to use a calculator, that’s fine. -APU
  83.  
Add Comment
Please, Sign In to add comment