汇编语言换行

Assembly Language New Line

我是汇编语言编程的新手,我希望我的输出有单独的行,这样更容易阅读,但是,我编写了我的代码并使其运行,但随后被告知我实际上无法使用 Irvine 程序创建新行。我的教科书只使用 Irvine "Crlf",而在本网站上提出类似问题的其他人的代码完全破坏了我的程序,所以现在我迷路了。

我尝试的一个是:

mov ah, 0Eh       ;print new line sequence
mov al, 0Dh
int 10h
mov al, 0Ah
int 10h

无论如何,这里是我的完整代码,仍然带有 Irvine 函数。有人可以帮助我在不使用 "call Crlf" 的情况下获得我正在寻找的输出吗?或者让我知道为什么上面的代码会破坏我的程序?我确定我缺少某些东西。

INCLUDE Irvine32.inc


.data
prompt BYTE 'Enter a positive integer: ', 0     
report1 BYTE 'The sum is: ', 0              
report2 BYTE 'The product is: ', 0
report3 BYTE 'The power result is: ', 0
temp DWORD ? ;
.code

main PROC
; Main program control procedure.
; Calls: GetInteger, AddNumbers, MultiplyNumbers,
;       WriteInt, CalculatePower

call GetInteger             ;Get the first user entered integer
mov ebx, eax                ;Store the value into the EBX register
call GetInteger             ;Get the second user entered integer
mov temp,eax                ;Copy the value into temp for holding
call AddNumbers             ;Find the sum of the two integers
mov edx,OFFSET report1      ;Display sum result
call WriteString
call WriteInt
mov eax, temp               ;Replace the EAX value with the second user entered integer
call MultiplyNumbers        ;Find the product of the two integers
call Crlf                   ;New line
mov edx,OFFSET report2      ;Display the product result
call WriteString
call WriteInt
mov eax, temp               ;Replace the EAX value with the second user entered integer
call CalculatePower         ;Find the power result of the two integers
call Crlf                   ;New line
mov edx,OFFSET report3      ;Display the power result
call WriteString
call WriteInt
    exit                    ;exit to operating system
main ENDP

;-------------------------------------------------------------
GetInteger PROC
;
; Prompts the user for two integers and stores 
; them into EAX and EBX registers
; Receives: Doubleword integers 
; Returns: The two integer values in the EAX and EBX registers
; Calls: WriteString, ReadInt
;----------------------------------------------------------------
    mov edx,OFFSET prompt   ;Prompt user for integer entry
    call WriteString
    call ReadInt
    ret
GetInteger ENDP

;-----------------------------------------------------------------
AddNumbers PROC
;
; Calculates the sum of two 32-bit integers
; Receives: The integer values in the registers EAX and EBX
; Returns: The sum in the EAX register
; Calls: none
;------------------------------------------------------------------
    add eax,ebx         ;Find the sum 
    ret
AddNumbers ENDP

;--------------------------------------------------------------------
MultiplyNumbers PROC
;
; Calculates the product of two 32-bit integers
; Receives: The integer values in the registers EAX and EBX 
; Returns: The product in the EAX register
; Calls: none
;---------------------------------------------------------------------
    mul ebx             ;Find the product
    ret 
MultiplyNumbers ENDP

;--------------------------------------------------------------------
CalculatePower PROC
;
; Calculates the result of the first 32 bit integer to the power
; of the second by using MultiplyNumbers
; Receives: The result of MultiplyNumbers
; Returns: The power result in EAX register
; Calls: MultiplyNumbers
;---------------------------------------------------------------------
    mov ecx,eax         ;Set the counter with the value of the second integer
    sub ecx, 1          ;Subtract one so the counter calls MultiplyNumbers the correct amount
    mov eax,ebx         ;Copy EBX into EAX so that MultiplyNumbers finds the power result

    FindPower:
        call MultiplyNumbers;Find the power result
        loop FindPower  ;Repeat the loop till the count is 0

    ret
CalculatePower ENDP

END main

CRLF 只是添加到输出的两个字节序列,值 13 和 10。

如果你用这两个值创建了一个字符串,可能 prompt BYTE 'Hello!', 13, 10, 0 或者只包含 cr/lf 13,10,0 组合,你可以输出它而无需特殊过程。

为了扩展亚当的回答,这可能正是您正在寻找的内容:

carriageReturn BYTE ' ', 13, 10, 0

然后将其命名为:

mov edx,OFFSET report1       ;Display sum result
call WriteString
call WriteInt
mov edx,OFFSET carriageReturn ; new line
call WriteString

这样马车return在WriteInt

之后