ml을 사용해서 어셈블링을 하는데 어셈블링 결과가 processor: 8086/8088 memory model: small이 뜹니다. 왜?????
걍 간단한 예제를 아래에 실었습니다.
어셈블링은 visualStudio2005을 사용하고 커스텀 명령라인은 다음과 같고 밑에 예제코드가 있습니다.
왜 어셈블결과가 processor: 8086/8088 memory model: small인지 모르겠습니다.
실제로 tracing을 하면 "push ecx"가 "push cx"로 컴파일 되는데 이것 또한 이해가 가지 않습니다.
뭐가 문제죠???????
고수분들의 도움 부탁드립니다;;;;
ml -I$(ProjectDir)..\include\ -c -Zi "-Fl$(IntDir)\$(InputName).lst" "-FR$(IntDir)\$(InputName).obj debug\$(InputName).sbr" "-Fo$(IntDir)\$(InputName).obj" "$(InputPath)"
page ,132
title chkstk - C stack checking routine
;***
;refer:
; ms-help://MS.VSCC.v80/MS.MSDN.v80/MS.VisualStudio.v80.ko/dv_vcmasm/html/1446d55f-e2e7-4fd1-a9b8-b15cf7d4e47c.htm
;*******************************************************************************
;***
;chkstk.asm - C stack checking routine
;
; Copyright (c) Microsoft Corporation. All rights reserved.
;
;Purpose:
; Provides support for automatic stack checking in C procedures
; when stack checking is enabled.
;
;*******************************************************************************
.xlist
include debug__assembler.inc
include cruntime.inc
.list
%define X386P 1
IFDEF X386P
;%error
;.386P ; If use CR0 reg
.486P ;
ENDIF
; size of a page of memory
_PAGESIZE_ equ 1000h
CODESEG
page
;***
;_chkstk - check stack upon procedure entry
;
;Purpose:
; Provide stack checking on procedure entry. Method is to simply probe
; each page of memory required for the stack in descending order. This
; causes the necessary pages of memory to be allocated via the guard
; page scheme, if possible. In the event of failure, the OS raises the
; _XCPT_UNABLE_TO_GROW_STACK exception.
;
; NOTE: Currently, the (EAX < _PAGESIZE_) code path falls through
; to the "lastpage" label of the (EAX >= _PAGESIZE_) code path. This
; is small; a minor speed optimization would be to special case
; this up top. This would avoid the painful save/restore of
; ecx and would shorten the code path by 4-6 instructions.
;
;Entry:
; EAX = size of local frame
;
;Exit:
; ESP = new stackframe, if successful
;
;Uses:
; EAX
;
;Exceptions:
; _XCPT_GUARD_PAGE_VIOLATION - May be raised on a page probe. NEVER TRAP
; THIS!!!! It is used by the OS to grow the
; stack on demand.
; _XCPT_UNABLE_TO_GROW_STACK - The stack cannot be grown. More precisely,
; the attempt by the OS memory manager to
; allocate another guard page in response
; to a _XCPT_GUARD_PAGE_VIOLATION has
; failed.
;
;*******************************************************************************
public _alloca_probe
_chkstk proc
_alloca_probe = _chkstk
push ecx
; Calculate new TOS.
lea ecx, [esp] + 8 - 4 ; TOS before entering function + size for ret value
sub ecx, eax ; new TOS
; Handle allocation size that results in wraparound.
; Wraparound will result in StackOverflow exception.
sbb eax, eax ; 0 if CF==0, ~0 if CF==1
not eax ; ~0 if TOS did not wrapped around, 0 otherwise
and ecx, eax ; set to 0 if wraparound
mov eax, esp ; current TOS
and eax, not ( _PAGESIZE_ - 1) ; Round down to current page boundary
cs10:
cmp ecx, eax ; Is new TOS
jb short cs20 ; in probed page?
mov eax, ecx ; yes.
pop ecx
xchg esp, eax ; update esp
mov eax, dword ptr [eax] ; get return address
mov dword ptr [esp], eax ; and put it at new TOS
ret
; Find next lower page and probe
cs20:
sub eax, _PAGESIZE_ ; decrease by PAGESIZE
test dword ptr [eax],eax ; probe page.
jmp short cs10
_chkstk endp
end
MASM 어셈블리가 맞는지 모르겠습니다만...
본지가 오래되서 그런지 지시어 형식이 좀 생소하군요.
파일이 전부 있지 않아서 확인하기는 힘듭니다만..
윈도우용 어셈블리라면 딱 3가지만 선언되면 됩니다. 아래의 3가지가 선언되지 않으면 CPU가 8086으로 인식되고 기본 메모리 모델인 small 모델로 선택됩니다.
이 부분 대신
로 넣고 해 보시기 바랍니다.
댓글 달기