title: Display Register in decimal - assembly language EASy68K
body: <p>I am trying to display D0 in decimal, but when I run the program, nothing is displayed. I don't get any errors, and when I look in register D0 I see the expected number in hex, but the decimal equivalent isn't being displayed. I am trying to use TRAP to do so, which we were shown in class. What am I doing wrong? The line of code in question is the 17th line down from where the code starts. It says "TRAP    #15     Display D0 in decimal." Thanks for any help.</p>
  
  <pre><code>*-----------------------------------------------------------
  * Program Number: 0
  * Written by    : Bryan Kriss
  * Date Created  : 10/06/2013
  * Description   : This program performs If-then-else statement.
  *
  *-----------------------------------------------------------
  START   ORG $1000   Program starts at loc $1000
  IF  CMP     #12,P   Is P &gt; 12? 
      BLE     ENDIF   If P &lt; 12, go to ENDIF
      ASL     P       Shift left
      ASL     P       Shift left
      ASL     P       Shift left
      ADD     #4,P    P + 4
      MOVE    P,D0    Move P into D0
      EXT.L   D0
      TRAP    #15     Display D0 in decimal
      STOP    #$2700   Stop execution
  
  ENDIF   MOVE    Q,D1     Move the value of Q into D1
          SUB     D1,D0    P - D1 (P-Q)
          MOVE    D0,D1    Move P into D1
  
          STOP    #$2700    Stop execution
  * Data section
      ORG $2000   Data starts at loc 2000
  P   DC.W    15  int P = 15;
  Q   DC.W    7   int Q = 7;
      END START
  </code></pre>