2011-12-19 42 views
2

我對裝配非常新,我正在嘗試構建一個小程序。我無法弄清楚如何使用Easy68k在程序集中插入換行符。例如,我開始寫基本的黑色插孔模擬器,我需要在問候第一個播放器之後做一個換行符。我嘗試在變量聲明中加入「\ n」,但它只是打印出來,就好像它是文本的一部分。將換行符插入彙編代碼Easy 68k(68000)

根據Easy 68K幫助I/O部分,我可以使用 「LF EQU $ 0A新行(換行)」,但我不知道如何實現這一點。

START ORG  $400    ; Start of program area 
    CLR.L  D0    ; Clear D0 
    CLR.L  D1    ; Clear D1 
    CLR.L  D2    ; Clear D2 
    CLR.L  D3    ; Clear D3 
    CLR.L  D4    ; Clear D4 
    CLR.L  D5    ; Clear D5 
    CLR.L  D6    ; Clear D6 
    MOVE.L  playerTotal, D2 ; Store Player total in D1 
    MOVE.L  card, D3   ; Store current card in D2 
    MOVE.B  playerAce, D4 ; Store number of aces player has in D3 
    MOVE  #14, D0  
    LEA  playerGreeting, A1 ; Load Player Greeting in A1 
    TRAP  #15    ; Display Player Greeting 
* insert line break  
    STOP  #$2700 ; Stop execution 

     ORG   $1000 ;Start of data area 
playerTotal DS.L  1  ; Save 1 byte of memory for playerTotal 
dealerTotal DS.L  1  ; Save 1 byte of memory for dealerTotal 
card  DC.L  5  ; Save 1 byte of memory for card dealt 
keepPlaying DS.B  1  ; Save 1 byte of memory for Play again value 
playerAce DS.B  1  ; Save 1 byte of memory to track player Aces 
playerGreeting DC.B  'Hello Player 1!', 0 ; Message 

       LF  EQU  $0A 
       END  START     ; End of program and entry point 

回答

6

試試這個:

CR EQU $0D 
LF EQU $0A 
playerGreeting DC.B  'Hello Player 1!',CR,LF,0 ; Message 

這將插入你的消息後回車(CR)和換行(LF)。基本上,它會在空終止符(0)之前將兩個附加字符添加到輸出字符串中。

+1

Omg,太棒了。謝謝!!!對於任何未來的讀者,請確保在信息部分中將CR定義爲「CR EQU $ 0D;回車」(除了LF)。 – kelly 2011-12-19 19:41:04

+0

@kelly,好點。我更新了答案,使其更清晰。 – 2011-12-19 19:49:09

+0

你有什麼特別的理由需要回車嗎?我很困惑,究竟是什麼馬車。新線是否足以阻止繩子向下移動? – Callat 2016-11-03 17:09:49