1. Project 생성
Visual Studio에서 파일 -> 새로 만들기 -> 프로젝트 -> Windows Console Application 선택하여 프로젝트를 생성한다.
2. Source Files 작성
cpp 파일을 삭제 후 Windows MASM 32비트 어셈블리 코드 를 작성한다.
// main.asm
.386
.model flat
.code
start PROC
mov eax,213
add eax,432
ret
start endp
end start
3. masm 빌드 설정
- project 우클릭 -> Build Dependencies -> Build Customizations... -> masm 선택
- assmebly 파일 우클릭 -> Properites(속성) -> Configuration Properites -> General -> Build Types 에 Microsoft Macro Assembler 선택
- project 우클릭 -> Configuration Properites -> Linker -> Advanced -> Entry Point 에 start 설정
4. Build
build -> 솔루션 build
5. Debugging
1. breadk point 찍고 debug -> start debugging
2. debug -> windows 에서 memory, register, disassebly 창 추가하여 메모리 확인
- EAX = 0x285 = 645
- 계산 결과가 저장됨
- 213 + 432 = 645
- EIP (Instruction Pointer)
- 다음 실행할 명령어 주소
- 현재 프로그램 카운터
- ESP (Stack Pointer)
- 스택의 최상단 주소
- 함수 호출/복귀에 사용
- EFL (Flags)
- 상태 플래그 (Zero, Carry, Overflow 등)