Blogtrottr
Yahoo!奇摩知識+ - 分類問答 - 電腦網路 - 發問中
Yahoo!奇摩知識+ - 分類問答 - 電腦網路 - 發問中
請問各位大大這題組合語言的bug在哪裡?
Apr 18th 2013, 20:44

我要寫一個輸入兩整數讓其能夠相減的組合語言程式,但是再命令提示字元下執行卻出現一大堆亂碼,請大大告訴我哪裡寫錯了。
 TITLE Integer Subtraction Program     (Sub2.asm)


; This program prompts the user for three integers, 
; stores them in an array, calculates the sub of the
; array, and displays the sub.


INCLUDE Irvine16.inc


INTEGER_COUNT = 3


.data
str1  BYTE  "Enter a signed integer: ",0
str2  BYTE  "The sub of the integers is: ",0
array DWORD  INTEGER_COUNT DUP(?)


.code 
main PROC
callClrscr
movesi,OFFSET array
movecx,INTEGER_COUNT
callPromptForIntegers
callArraySub
callDisplaySub
exit
main ENDP


;-----------------------------------------------------
PromptForIntegers PROC USES ecx edx esi
;
; Prompts the user for an arbitrary number of integers 
; and inserts the integers into an array.
; Receives: ESI points to the array, ECX = array size
; Returns:  nothing
;-----------------------------------------------------
movedx,OFFSET str1; "Enter a signed integer"

L1:callWriteString; display string
callReadInt; read integer into EAX
callCrlf; go to next output line
mov[esi],eax; store in array
subesi,TYPE DWORD; next integer
loopL1


ret
PromptForIntegers ENDP




;-----------------------------------------------------
Arraysub PROC USES esi ecx
;
; Calculates the sub of an array of 32-bit integers.
; Receives: ESI points to the array, ECX = number 
;   of array elements
; Returns:  EAX = sub of the array elements
;-----------------------------------------------------
moveax,0; set the sub to zero
L1:subeax,[esi]; add each integer to sub
subesi,TYPE DWORD; point to next integer
loopL1; repeat for array size
ret; sub is in EAX
ArraySub ENDP


;-----------------------------------------------------
Displaysub PROC USES edx
;
; Displays the sub on the screen
; Receives: EAX = the sub
; Returns:  nothing
;-----------------------------------------------------
movedx,OFFSET str2; "The sub of the..."
callWriteString
callWriteInt; display EAX
callCrlf
ret
DisplaySub ENDP
END main


This entry passed through the Full-Text RSS service — if this is your content and you're reading it on someone else's site, please read the FAQ at fivefilters.org/content-only/faq.php#publishers. Five Filters recommends: Jousting With Toothpicks - The Case For Challenging Corporate Journalism http://www.medialens.org/index.php/alerts/alert-archive/alerts-2013/719-jousting-with-toothpicks-the-case-for-challenging-corporate-journalism.html.

You are receiving this email because you subscribed to this feed at blogtrottr.com.

If you no longer wish to receive these emails, you can unsubscribe from this feed, or manage all your subscriptions
arrow
arrow
    全站熱搜

    candycrushsaga2 發表在 痞客邦 留言(0) 人氣()