Advertisement
Guest User

Untitled

a guest
Oct 26th, 2016
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.26 KB | None | 0 0
  1. *input***************************
  2. *read a number through keyboard*
  3. MOVE.B #13,D0 ; task 13: display a string without CRLF
  4. LEA MES0,A1 ; assign address of MES to A1
  5. TRAP #15
  6.  
  7. MOVE.B #4, D0 ; task 4: load number to D1.L
  8. TRAP #15
  9.  
  10.  
  11.  
  12. TRAP #15
  13.  
  14. MOVE.B #3,D0 ; task 3: display signed number in D1.L
  15. TRAP #15
  16.  
  17. ********************************
  18.  
  19.  
  20. *modulo*************************
  21. MOVE.L D1,D3 ; store input number in D3.L
  22. CLR.L D1 ; clear D1
  23.  
  24. DIVU Y,D3 ; compute modulo and remainder of D3/Y
  25. ; remainder is stored in higher bits of D3.L
  26. ; quotient is stored in lower bits of D3.L
  27.  
  28. SWAP D3 ; swap content of lower bits and higher bits
  29. ; now, modulo is stored in the lower bit of D3.L
  30.  
  31. MOVE.W D3,D1 ; move modulo to D1
  32.  
  33. MOVE.B #14,D0 ; display MES2
  34. LEA MES2,A1
  35. TRAP #15
  36.  
  37. MOVE.B #3,D0 ; display modulo in D1.L
  38. TRAP #15
  39.  
  40. MOVE.B #14,D0 ; newline
  41. LEA NEWLINE,A1
  42. TRAP #15
  43. ********************************
  44.  
  45.  
  46. *array**************************
  47. *random access of an array*
  48.  
  49.  
  50. LEA SOMEARRAY,A2 ; get address of SOMEARRAY
  51. MOVE.W (A2),D1 ; get SOMEARRAY[0]
  52. MOVE.B #3,D0 ; display SOMEARRAY[0]
  53. TRAP #15
  54.  
  55. MOVE.B #14,D0 ; newline
  56. LEA NEWLINE,A1
  57. TRAP #15
  58.  
  59. ADD.W #6,A2 ; fourth element
  60. ; since the array is initialized with DC.W, each element takes 2 bytes
  61. ; so, the address of the 4th element= address of the 1st element + (2 bytes)*(4-1)
  62.  
  63. MOVE.W (A2),D1 ; get SOMEARRAY[3]
  64. MOVE.B #3,D0 ; display SOMEARRAY[3]
  65. TRAP #15
  66. ********************************
  67.  
  68.  
  69. SIMHALT
  70.  
  71. * Put variables and constants here
  72. NEWLINE DC.B $D,$A,0
  73. MES0 DC.B 'Input the size of the array: ',0 ; Here, 0 indicates the end of a string, which is similar to '\0' in c-style strings
  74. MES1 DC.B 'Your input is: ',0
  75.  
  76. Y DC.W 10
  77. MES2 DC.B 'The modulo is: ',0
  78.  
  79. SOMEARRAY DC.W 2,3,8,1,6,5,4
  80.  
  81. END START ; last line of source
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement