; Listing generated by Microsoft (R) Optimizing Compiler Version 13.10.3077 

	TITLE	.\ArraySum.cpp
	.386P
include listing.inc
if @Version gt 510
.model FLAT
else
_TEXT	SEGMENT PARA USE32 PUBLIC 'CODE'
_TEXT	ENDS
_DATA	SEGMENT DWORD USE32 PUBLIC 'DATA'
_DATA	ENDS
CONST	SEGMENT DWORD USE32 PUBLIC 'CONST'
CONST	ENDS
_BSS	SEGMENT DWORD USE32 PUBLIC 'BSS'
_BSS	ENDS
$$SYMBOLS	SEGMENT BYTE USE32 'DEBSYM'
$$SYMBOLS	ENDS
$$TYPES	SEGMENT BYTE USE32 'DEBTYP'
$$TYPES	ENDS
_TLS	SEGMENT DWORD USE32 PUBLIC 'TLS'
_TLS	ENDS
;	COMDAT ?MySub@@YAXXZ
_TEXT	SEGMENT PARA USE32 PUBLIC 'CODE'
_TEXT	ENDS
;	COMDAT ?ArraySum@@YAHQAHH@Z
_TEXT	SEGMENT PARA USE32 PUBLIC 'CODE'
_TEXT	ENDS
;	COMDAT _main
_TEXT	SEGMENT PARA USE32 PUBLIC 'CODE'
_TEXT	ENDS
sxdata	SEGMENT DWORD USE32 'SXDATA'
sxdata	ENDS
FLAT	GROUP _DATA, CONST, _BSS
	ASSUME	CS: FLAT, DS: FLAT, SS: FLAT
endif

INCLUDELIB LIBC
INCLUDELIB OLDNAMES

PUBLIC	?MySub@@YAXXZ					; MySub
EXTRN	___security_cookie:DWORD
EXTRN	@__security_check_cookie@4:NEAR
EXTRN	__fltused:NEAR
; Function compile flags: /Ogty
; File c:\data\asmbook5\examples\ch12\visualcpp\arraysum\arraysum.cpp
;	COMDAT ?MySub@@YAXXZ
_TEXT	SEGMENT
__$ArrayPad$ = -4					; size = 4
__$ReturnAddr$ = 4					; size = 4
?MySub@@YAXXZ PROC NEAR					; MySub, COMDAT

; 3    : {

	push	ecx
	mov	eax, DWORD PTR ___security_cookie
	mov	DWORD PTR __$ArrayPad$[esp+4], eax

; 4    : 	char A = 'A';
; 5    : 	int B = 10;
; 6    : 	char name[20];
; 7    : 	name[0] = 'B';
; 8    : 	double c = 1.2;
; 9    : }

	mov	ecx, DWORD PTR __$ArrayPad$[esp+4]
	add	esp, 4
	jmp	@__security_check_cookie@4
?MySub@@YAXXZ ENDP					; MySub
_TEXT	ENDS
PUBLIC	?ArraySum@@YAHQAHH@Z				; ArraySum
; Function compile flags: /Ogty
;	COMDAT ?ArraySum@@YAHQAHH@Z
_TEXT	SEGMENT
_array$ = 8						; size = 4
_count$ = 12						; size = 4
?ArraySum@@YAHQAHH@Z PROC NEAR				; ArraySum, COMDAT

; 14   : 	int sum = 0;
; 15   : 
; 16   : 	for(int i = 0; i < count; i++)

	mov	edx, DWORD PTR _count$[esp-4]
	xor	eax, eax
	xor	ecx, ecx
	test	edx, edx
	jle	SHORT $L282
	push	esi
	mov	esi, DWORD PTR _array$[esp]
$L280:

; 17   : 	  sum += array[i];

	add	eax, DWORD PTR [esi+ecx*4]
	inc	ecx
	cmp	ecx, edx
	jl	SHORT $L280
	pop	esi
$L282:

; 18   : 	
; 19   : 	return sum;
; 20   : }

	ret	0
?ArraySum@@YAHQAHH@Z ENDP				; ArraySum
_TEXT	ENDS
PUBLIC	_main
; Function compile flags: /Ogty
;	COMDAT _main
_TEXT	SEGMENT
_main	PROC NEAR					; COMDAT

; 25   : 	int Array[50];
; 26   : 
; 27   : 	int sum = ArraySum( Array, 50 );
; 28   : 
; 29   : 
; 30   : }

	xor	eax, eax
	ret	0
_main	ENDP
_TEXT	ENDS
END
