Guest User

Untitled

a guest
Jun 15th, 2018
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.             .PSIZE  52
  2.             .TITLE  "Assignment 2"
  3.  
  4. /****************************************************************
  5. FILENAME: assign2.a68
  6.  
  7. STUDENT NAME (AUTHOR): Shawn McBride
  8.  
  9. STUDENT NUMBER:111 222 333
  10.  
  11. STUDENT E-MAIL ADDRESS: mcbrids@algonquincollege.com
  12.  
  13. LAB SECTION: 011
  14.  
  15. ASSIGNMENT NUMBER AND NAME: 2 - Multiplication
  16.  
  17. PROFESSOR'S NAME: Shawn McBride
  18.  
  19. PURPOSE: Multiply 2 unsigned integers using repeated addition
  20. ****************************************************************/
  21. |
  22. |Include the file ASCII.i.
  23. |
  24.                 .NOLIST
  25.                 .INCLUDE    "..\\Include\\ASCII.i"
  26.                 .LIST
  27.  
  28.                 .TEXT   1
  29. Prompt1:        .ASCII      "This program calculates the product of 2"
  30.                 .ASCII      " unsigned hex integers."
  31.                 .BYTE       CR,LF,0
  32.                
  33. Prompt2:        .BYTE       CR,LF
  34.                 .ASCIZ      "Enter an unsigned integer (HEX): "
  35.                
  36. Prompt3:        .BYTE       CR,LF,CR,LF
  37.                 .ASCIZ          "The product is: "
  38.                
  39. Prompt4:        .BYTE       CR,LF
  40.                 .ASCIZ          "Press any key to end program."
  41.  
  42.                 .TEXT       0
  43.                
  44.                 .GLOBAL     Assign2
  45. /*****************************************************************************
  46. HISTORY
  47.    10-Jan-07    Writen by S. McBride
  48.    ??-Jan-07    Errors corrected by "Your name here"
  49. FUNCTION
  50.    Assign2 -    This program multiplies 2 unsigned integers
  51.                     by doing repeated addition.  User must enter
  52.                     values greater than 0.
  53. DESCRIPTION
  54.     GET Num1
  55.     GET Num2
  56.     Product <- 0
  57.     DO
  58.        Product <- Product + Num1
  59.        Num2 <- Num2 - 1
  60.     WHILE (Num2 NOT= 0)
  61.     PUT Product
  62. INPUTS
  63.   None
  64. OUTPUTS
  65.   None
  66. EXTERNAL INPUTS
  67.   2 integers
  68. EXTERNAL OUTPUTS
  69.   Prompts
  70.   Product
  71. REGISTERS DESTROYED
  72.    a0, d0, d1, d3, d4
  73. *****************************************************************************/
  74.  
  75. Assign2:
  76.             movea.l #Prompt1,a0
  77.             jsr     PrintMsg
  78.  
  79.             movea.l #Prompt2,a0
  80.             jsr     PrintMsg
  81.            
  82.             move.l  #8,d1      
  83.             jsr     InHex       | GET 1st integer
  84.             move.l  d0,d3
  85.  
  86.             jsr     PrintMsg
  87.             move.l  #8,d1       | GET 2nd integer
  88.             jsr     InHex
  89.             move.l  d0,d4
  90.  
  91.             move.l  #0,d0       | Product <- 0
  92.  
  93. MultLoop:
  94.             add.l       d3,d0
  95.             subq.w  #1,d4
  96.             bne.b   MultLoop
  97.  
  98.             movea.l #Prompt3,a0 | Display Product
  99.             jsr     PrintMsg
  100.             move.l  #8,d1
  101.             jsr     OutHex
  102.  
  103.             movea.l #Prompt4,a0|Change to 0?
  104.             jsr     PrintMsg
  105.             jsr     ConsoleIn
  106.             rts
Add Comment
Please, Sign In to add comment