汇编语言新行

时间:2015-05-23 14:19:48

标签: assembly line masm irvine32

我是汇编语言编程的新手,我希望我的输出有单独的行,以便更容易阅读,但是,我编写了我的代码并让它工作,但随后被告知我不能事实上,使用Irvine程序来制作新的一行。我的教科书只使用了Irvine“Crlf”,其他人在本网站上提出类似问题的代码完全破坏了我的程序,所以现在我迷路了。

我试过的一个是:

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

无论如何,这是我的完整代码与Irvine功能仍然。有人可以帮助我获得我正在寻找的输出而不使用“调用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

2 个答案:

答案 0 :(得分:4)

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

如果你创建了一个包含这两个值的字符串,可能是import UIKit import iAd class ViewController: UIViewController, ADBannerViewDelegate, GADBannerViewDelegate { var iAdBannerView : ADBannerView = ADBannerView() var adMobBannerView : GADBannerView = GADBannerView() override func viewDidLoad() { super.viewDidLoad() loadAds() } func loadAds() { // iAd // Changed banners width to match the width of the view it is on // You need to set the y origin relative to your view. Not a static number. iAdBannerView = ADBannerView(frame: CGRectMake(0, self.view.frame.size.height - iAdBannerView.frame.height, self.view.frame.size.width, iAdBannerView.frame.height)) iAdBannerView.delegate = self view.addSubview(iAdBannerView) // Hide iAd initially iAdBannerView.alpha = 0.0 // AdMob // Changed adSize to Googles set banner size adMobBannerView.adSize = kGADAdSizeBanner // Changed banners width to match the width of the view it is on // You need to set the y origin relative to your view. Not a static number. adMobBannerView.frame = CGRectMake(0, self.view.frame.size.height - adMobBannerView.frame.height , self.view.frame.size.width, adMobBannerView.frame.height) adMobBannerView.rootViewController = self adMobBannerView.delegate = self adMobBannerView.adUnitID = "AdMobPublisherID" // Dont need var request = GADRequest() adMobBannerView.loadRequest(GADRequest()) // Do not hide AdMob initially view.addSubview(adMobBannerView) } // Use bannerViewDidLoadAd function so we know ad is fully loaded func bannerViewDidLoadAd(banner: ADBannerView!) { println("iAd has an ad to show") // Animate fade of banners UIView.beginAnimations(nil, context: nil) // Show iAd iAdBannerView.alpha = 1.0 // Hide AdMob adMobBannerView.alpha = 0.0 UIView.commitAnimations() } func bannerView(banner: ADBannerView!, didFailToReceiveAdWithError error: NSError!) { println("iAd failed to load an ad because \(error)") // Animate fade of banners UIView.beginAnimations(nil, context: nil) // Hide iAd iAdBannerView.alpha = 0.0 // Show AdMob adMobBannerView.alpha = 1.0 UIView.commitAnimations() } 或者只包含cr / lf 13,10,0组合,你可以在没有特殊程序的情况下输出它。

答案 1 :(得分:3)

为了扩展亚当的答案,这可能正是您所寻找的:

carriageReturn BYTE ' ', 13, 10, 0

然后将其称为:

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

这样回车就在WriteInt

之后