Assembly 汇编语言新行
我是汇编语言编程的新手,我希望我的输出有单独的行,以便更易于阅读。然而,我编写了代码并使其正常工作,但随后被告知,我实际上无法使用Irvine过程来生成新行。我的课本只使用了Irvine的“Crlf”,其他人在这个网站上问了类似问题的代码完全破坏了我的程序,所以现在我迷路了 我尝试的一个方法是:Assembly 汇编语言新行,assembly,line,masm,irvine32,Assembly,Line,Masm,Irvine32,我是汇编语言编程的新手,我希望我的输出有单独的行,以便更易于阅读。然而,我编写了代码并使其正常工作,但随后被告知,我实际上无法使用Irvine过程来生成新行。我的课本只使用了Irvine的“Crlf”,其他人在这个网站上问了类似问题的代码完全破坏了我的程序,所以现在我迷路了 我尝试的一个方法是: mov ah, 0Eh ;print new line sequence mov al, 0Dh int 10h mov al, 0Ah int 10h 无论如何,这是我的完整代码与欧文函
mov ah, 0Eh ;print new line sequence
mov al, 0Dh
int 10h
mov al, 0Ah
int 10h
无论如何,这是我的完整代码与欧文函数仍然。有人能帮我在不使用“呼叫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
如果您使用这两个值创建了一个字符串,可能是
提示字节'Hello!',13,10,0
或仅由cr/lf 13,10,0组合组成,无需特殊程序即可输出。要扩展adam的答案,这可能正是您想要的:
carriageReturn BYTE ' ', 13, 10, 0
然后称之为:
mov edx,OFFSET report1 ;Display sum result
call WriteString
call WriteInt
mov edx,OFFSET carriageReturn ; new line
call WriteString
那样的话,马车回来后就写好了好极了!这比我想做的容易多了。非常感谢您的快速响应!记住,在*尼克斯,你省去13,只使用10作为换行符。