2013-10-08 107 views
4

我試圖用十進制顯示D0,但是當我運行程序時,什麼都不顯示。我沒有得到任何錯誤,並且當我查看寄存器D0時,我看到了十六進制的期望值,但是未顯示十進制等值。我正在嘗試使用TRAP來做到這一點,我們在課堂上展示了這一點。我究竟做錯了什麼?有問題的代碼行是代碼開始處的第17行。它說「TRAP#15以十進制顯示D0」。謝謝你的幫助。以十進制顯示寄存器 - 彙編語言EASy68K

*----------------------------------------------------------- 
* 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 > 12? 
    BLE  ENDIF If P < 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 

回答

3

根據該文件,你需要把D0的選擇和D1的實際值。

變化:

MOVE P,D0 Move P into D0 
EXT.L D0 
TRAP #15  Display D0 in decimal 

到:

MOVE P,D1 Move P into D1 
EXT.L D1 
MOVE.B #3,D0 Put required TRAP #15 selector (3) in D0 
TRAP #15  Display D0 in decimal 

一些進一步澄清:TRAP #15是用於進行由easy68k環境支持的各種任務的通用機制。爲了指定要執行的任務,您將任務選擇器傳遞給D0。然後,根據您使用的是哪個選擇器,還需要將其他參數加載到正確的寄存器中,通常爲D1A1

有一個comprehensive list of selectors on the easy68k web site - 前幾個選擇是:

TRAP #15 is used for I/O. Put the task number in D0. 

Task 
    0 Display string at (A1), D1.W bytes long (max 255) with carriage return and line feed (CR, LF). (see task 13) 
    1 Display string at (A1), D1.W bytes long (max 255) without CR, LF. (see task 14) 
    2 Read string from keyboard and store at (A1), NULL terminated, length retuned in D1.W (max 80) 
    3 Display signed number in D1.L in decimal in smallest field. (see task 15 & 20) 
    ... 
+0

謝謝!它的工作,但只是讓我更好地理解,什麼是選擇,你怎麼知道要輸入什麼數字? – Brett

+1

當然 - 請參閱上面的最新編輯,並鏈接到相關的easy68k文檔。 –

+0

再次感謝! – Brett