I’m trying to display the values of the array by using the call function. So far
ID: 3738313 • Letter: I
Question
I’m trying to display the values of the array by using the call function. So far this is my code. I don’t want to use dump regs but display values by labels. The Irvine library is used in this. HelpINCLUDE Irvine32.inc
.data applesSold SDWORD 8, 6, 7, 5, 3 ; your comment orangesSold SDWORD 1, 9, 4, 2 ; your comment totalApplesSold SDWORD ? ; your comment totalOrangesSold SDWORD ? ; your comment totalFruits SDWORD ? ; your comment
.code main PROC mov eax,0 mov ebx,0 mov ecx,0
mov edi, OFFSET applesSold ; address of intarray mov ecx, LENGTHOF applesSold ; loop counter mov eax,0 ; zero the accumulator SUM_L1: add eax, [edi] ; add an integer add edi, TYPE applesSold ; point to next integer loop SUM_L1 ; repeat until ECX = 0 mov totalApplesSold, edi endloop:
mov edi, OFFSET orangesSold ; address of intarray mov ecx, LENGTHOF orangesSold ; loop counter mov eax,0 loopOrange: add eax, [edi] ; add an integer add edi, TYPE OrangesSold ; point to next integer loop loopOrange ; repeat until ECX = 0 mov totalOrangesSold, edi
mov eax, totalApplesSold mov ebx, totalOrangesSold mov totalFruits,0 add totalFruits, eax add totalFruits, ebx
exit main ENDP displayTotals PROC uses eax edx mov eax, totalApplesSold ; load eax with total apples to display mov edx, offset totalApplesString ; load edx with address of total apple string call writeString ; display "label" call writeInt ; display total apples (showing sign) call crlf ;
mov eax, totalOrangesSold ; load eax with total oranges to display mov edx, offset totalOrangesString ; load edx with address of total orange string call writeString ; display "label" call writeInt ; display total oranges (showing sign) call crlf mov eax, totalFruitSold ; load eax with total fruit to display mov edx, offset totalFruitString ; load edx with address of total fruit string call writeString ; display "label" call writeInt ; display total fruit (showing sign) call crlf ret displayTotals ENDP
;) END main
I’m trying to display the values of the array by using the call function. So far this is my code. I don’t want to use dump regs but display values by labels. The Irvine library is used in this. Help
INCLUDE Irvine32.inc
.data applesSold SDWORD 8, 6, 7, 5, 3 ; your comment orangesSold SDWORD 1, 9, 4, 2 ; your comment totalApplesSold SDWORD ? ; your comment totalOrangesSold SDWORD ? ; your comment totalFruits SDWORD ? ; your comment
.code main PROC mov eax,0 mov ebx,0 mov ecx,0
mov edi, OFFSET applesSold ; address of intarray mov ecx, LENGTHOF applesSold ; loop counter mov eax,0 ; zero the accumulator SUM_L1: add eax, [edi] ; add an integer add edi, TYPE applesSold ; point to next integer loop SUM_L1 ; repeat until ECX = 0 mov totalApplesSold, edi endloop:
mov edi, OFFSET orangesSold ; address of intarray mov ecx, LENGTHOF orangesSold ; loop counter mov eax,0 loopOrange: add eax, [edi] ; add an integer add edi, TYPE OrangesSold ; point to next integer loop loopOrange ; repeat until ECX = 0 mov totalOrangesSold, edi
mov eax, totalApplesSold mov ebx, totalOrangesSold mov totalFruits,0 add totalFruits, eax add totalFruits, ebx
exit main ENDP displayTotals PROC uses eax edx mov eax, totalApplesSold ; load eax with total apples to display mov edx, offset totalApplesString ; load edx with address of total apple string call writeString ; display "label" call writeInt ; display total apples (showing sign) call crlf ;
mov eax, totalOrangesSold ; load eax with total oranges to display mov edx, offset totalOrangesString ; load edx with address of total orange string call writeString ; display "label" call writeInt ; display total oranges (showing sign) call crlf mov eax, totalFruitSold ; load eax with total fruit to display mov edx, offset totalFruitString ; load edx with address of total fruit string call writeString ; display "label" call writeInt ; display total fruit (showing sign) call crlf ret displayTotals ENDP
;) END main
I’m trying to display the values of the array by using the call function. So far this is my code. I don’t want to use dump regs but display values by labels. The Irvine library is used in this. Help
INCLUDE Irvine32.inc
.data applesSold SDWORD 8, 6, 7, 5, 3 ; your comment orangesSold SDWORD 1, 9, 4, 2 ; your comment totalApplesSold SDWORD ? ; your comment totalOrangesSold SDWORD ? ; your comment totalFruits SDWORD ? ; your comment
.code main PROC mov eax,0 mov ebx,0 mov ecx,0
mov edi, OFFSET applesSold ; address of intarray mov ecx, LENGTHOF applesSold ; loop counter mov eax,0 ; zero the accumulator SUM_L1: add eax, [edi] ; add an integer add edi, TYPE applesSold ; point to next integer loop SUM_L1 ; repeat until ECX = 0 mov totalApplesSold, edi endloop:
mov edi, OFFSET orangesSold ; address of intarray mov ecx, LENGTHOF orangesSold ; loop counter mov eax,0 loopOrange: add eax, [edi] ; add an integer add edi, TYPE OrangesSold ; point to next integer loop loopOrange ; repeat until ECX = 0 mov totalOrangesSold, edi
mov eax, totalApplesSold mov ebx, totalOrangesSold mov totalFruits,0 add totalFruits, eax add totalFruits, ebx
exit main ENDP displayTotals PROC uses eax edx mov eax, totalApplesSold ; load eax with total apples to display mov edx, offset totalApplesString ; load edx with address of total apple string call writeString ; display "label" call writeInt ; display total apples (showing sign) call crlf ;
mov eax, totalOrangesSold ; load eax with total oranges to display mov edx, offset totalOrangesString ; load edx with address of total orange string call writeString ; display "label" call writeInt ; display total oranges (showing sign) call crlf mov eax, totalFruitSold ; load eax with total fruit to display mov edx, offset totalFruitString ; load edx with address of total fruit string call writeString ; display "label" call writeInt ; display total fruit (showing sign) call crlf ret displayTotals ENDP
;) END main
Explanation / Answer
Check if console handles are initialized properly in the code otherise initialize the handle in the begnning of your code as below :
Check Initflag is set to 0 and then call Initialize routine.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.