강의

멘토링

커뮤니티

Inflearn Community Q&A

seo32099744's profile image
seo32099744

asked

[MMORPG Game Development with C++ and Unreal Series] Part 1: Introduction to C++ Programming

Function Basics

ret 질문입니다

Written on

·

268

0

mov eax, 11

mov ebx,10

call MAX

; PRINT_DEC 4, ecx

; NEWLINE

 

xor rax, rax

ret

 

PRINT_MSG:

PRINT_STRING msg

NEWLINE

ret

 

MAX:

cmp eax, ebx

jg L1

mov ecx, ebx

jmp L2

 

L1:

mov ecx, eax

 

L2:

PRINT_DEC 4, ecx

NEWLINE

 

L2에 ret을 넣지 않았는데 값은 제대로 나옵니다

문제 되는 게 있을까요?

그리고 ret은 단순히 함수의 끝을 나타내는 건가요?

C++

Answer 1

0

Rookiss님의 프로필 이미지
Rookiss
Instructor

네 필요합니다. ret을 해야 함수에서 빠져나와 원래 주소로 돌아가기 때문입니다.
관련 내용은 C++에서 또 다루게 되니 지금은 넘어가시기 바랍니다.

seo32099744님의 프로필 이미지
seo32099744
Questioner

감사합니다!

seo32099744's profile image
seo32099744

asked

Ask a question