在汇编代码中插入换行符很简单,68k (68000)

时间:2022-01-20 19:28:29

I am very new to assembly, and I'm trying to build a small program. I can't figure out how to insert a line break in assembly using the Easy68k. For example, I am starting to write basic black jack simulator, and I need to do a line break after greeting the first player. I tried incorporating "\n" into the variable declaration, but it just prints out as if it were part of the text.

我对汇编非常陌生,我正在尝试建立一个小程序。我不知道如何使用Easy68k在程序集中插入换行符。例如,我开始编写基本的黑杰克模拟器,我需要在问候第一个玩家之后进行换行。我尝试将“\n”合并到变量声明中,但它只是打印出来,好像它是文本的一部分。

According to the Easy 68K Help I/O section, I can use "LF EQU $0A New line (line feed)" but I have no idea how to implement this.

根据Easy 68K Help I/O部分,我可以使用“LF公式$0A New line(换行)”,但我不知道如何实现这一点。

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

1 个解决方案

#1


6  

Try this:

试试这个:

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

This will insert a carriage return (CR) and line feed (LF) after your message. Basically it tacks on two additional characters to your output string before the null terminator (0).

这将在消息之后插入回车(CR)和换行(LF)。基本上,在null结束符(0)之前,它对输出字符串有两个额外的字符。

#1


6  

Try this:

试试这个:

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

This will insert a carriage return (CR) and line feed (LF) after your message. Basically it tacks on two additional characters to your output string before the null terminator (0).

这将在消息之后插入回车(CR)和换行(LF)。基本上,在null结束符(0)之前,它对输出字符串有两个额外的字符。