null, a special keyword denoting a null value; null is also a primitive value.
Because JavaScript is case-sensitive, null is not the same as Null, NULL, or
any other variant l undefined, a top-level property whose value is undefined; undefined is also a primitive value
디스어셈블된 내용중에
lea edi,[ebp-48h]
이러한 부분이 있었는데 []의 의미를 몰랐다가 이제서야 찾아본다.
[]는 C언어의 []와 유사하게 그 변수의 내용을 메모리 번지로 해석해서 그 번지의 내용을 받아오는 연산자이다.
그러니까 ebp의 내용에서 0x48을 뺀 주소를 edi에 저정하라는 의미이다. (LEA)
#include "stdio.h"
int main(int argc, char *argv[])
{
int x = 1;
printf("%d %d %d\n", ++x, x, x++);
return 0;
}
You're running into two issues:
1. Undefined behavior -- you are attempting to modify the value of an
object more than once between sequence points, and the Standard imposes
no requirement on how to handle that behavior. Basically, any
expression of the forms:
i = i++;
j = k++ * k++;
foo(i,i++,--i);
invoke undefined behavior. Read up on the semantics of the "++" and
"--" operators in an *authoritative* reference (the Standard would
obviously be one, but also K&R2 or H&S5); they don't work the
way most
people think they should.
2. Order of evaluation -- AFAIK, there's no requirement that
expressions in a function parameter list be evaluated in any particular
order. At first blush, it *looks* like the arguments were evaluated
from right to left (if x = 1, then x++ evaluates to 1, with the side
effect that x == 2, and ++x evaluates to 3, with the side effect that x
== 3), but given that you've invoked undefined behavior the actual
reason may be something else entirely.
$ gcc -Wall cc_test.c
cc_test.c: In function ‘main’:
cc_test.c:6: warning: operation on ‘x’ may be undefined
cc_test.c:6: warning: operation on ‘x’ may be undefined
이런 경고가 발생한다.
분명 x는 변수인데, 그에 대한 operation이 정의되지 않았다는게 무슨 말인지 모르겠지만,
아무튼 실행을 하면
$ ./a.out
3 3 1
요런 희한한 결과가 나온다.
아무튼, calling convention과도 연관이 있어 보이는데,
c언어 특성상 right-left 로 push 하므로(가장 위에는 왼쪽 값이 오도록)
가장 먼저들어가는, 오른쪽 x++ 은 1이 들어가고
1을 더해준다음, 다음 명령어를 수행하면서(++x) 한번에 2가 증가하게 되고
그럼으로 인해 x, ++x 순으로 3이 들어가는게 아닐까 생각된다.