html 웹 페이지 상에서 자바 스크립트를 사용할때의 템플릿

<html>
<script type="text/javascript">
function function_name(var1, var2)
{
    // statements
}

</script>
</html>


'Programming > javascript & HTML' 카테고리의 다른 글

javascript - for / for .. in  (0) 2010.07.18
javascript - 변수 타입  (0) 2010.07.18
core javascript 문서  (2) 2010.07.18
javascript 관련 링크  (2) 2010.07.18
JSON - JavaScript Object Notation  (2) 2010.06.07
Posted by 구차니
java script에 관련한 스펙은 ECMA에 정의되어 있다지만 귀차니즘으로 패스 -ㅁ-
가장 아래의 pdf는 웹을 pdf로 바꾼것으로 보이며, 귀찮으면 가장 아래만 다운받아서 보면된다.


[링크 : https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference]

[링크 : http://www.webreference.com/javascript/reference/core/]
[링크 : http://www.webreference.com/javascript/reference/core_ref/contents.html]
[링크 : http://www.osxsux.net/NSCoreJS15.pdf]

'Programming > javascript & HTML' 카테고리의 다른 글

javascript - for / for .. in  (0) 2010.07.18
javascript - 변수 타입  (0) 2010.07.18
javascript template  (0) 2010.07.18
javascript 관련 링크  (2) 2010.07.18
JSON - JavaScript Object Notation  (2) 2010.06.07
Posted by 구차니
요즘들어 XML 공부 한답시고 시작했는데 Javascript로 빠져들고 있다.
예전에는 c만을 경배하다 보니 javascript는 무시했는데 생각보다 강력하고, 생각보다 c 와 유사하며, 생각보다 재미있다.

요즘하는 짓꺼리(?)는
javascript로 웹 브라우저 처럼 프레임 문서 만들어서 조작하기.
이게되면은 다음번에는 xml을 이용해서 단어장이나 해봐야지 -ㅁ-

[링크 : http://www.cadvance.org/doc/java]

'Programming > javascript & HTML' 카테고리의 다른 글

javascript - for / for .. in  (0) 2010.07.18
javascript - 변수 타입  (0) 2010.07.18
javascript template  (0) 2010.07.18
core javascript 문서  (2) 2010.07.18
JSON - JavaScript Object Notation  (2) 2010.06.07
Posted by 구차니
Programming/C Win32 MFC2010. 7. 4. 23:50
WM_DEVICECHANGE 를 통해서 장치의 변경을 알려준다고 한다.
(머.. 내가 쓸일이 있을려나..)

[링크 : http://blog.kkomzi.net/80] << 요거 참조
[링크 : http://www.codeproject.com/kb/dotnet/devicevolumemonitor.aspx]
[링크 : http://bytes.com/topic/c-sharp/answers/264280-how-can-i-detect-cdrom-usb-device-insertions]

[링크 : http://msdn.microsoft.com/en-us/library/aa363480%28VS.85%29.aspx]
Posted by 구차니
Firefox 즐겨찾기를 내보내는데 json 이라는 확장자가 생겼다.
머하는 확장자인가 해서 찾아 봤더니

JavaScript Object Notation

의 약자이고, 일종의 데이터 교환을 위한 텍스트 파일(이러한 컨셉은 XML과 유사)이다.

[링크 : http://www.json.org/json-ko.html]

'Programming > javascript & HTML' 카테고리의 다른 글

javascript - for / for .. in  (0) 2010.07.18
javascript - 변수 타입  (0) 2010.07.18
javascript template  (0) 2010.07.18
core javascript 문서  (2) 2010.07.18
javascript 관련 링크  (2) 2010.07.18
Posted by 구차니
2010/04/22 - [Programming/C / Win32 / MFC] - 변수인데 왜 operation on 'variable' may be undefined 야?

디스어셈블된 내용중에
lea         edi,[ebp-48h]
이러한 부분이 있었는데 []의 의미를 몰랐다가 이제서야 찾아본다.
[]는 C언어의 []와 유사하게 그 변수의 내용을 메모리 번지로 해석해서 그 번지의 내용을 받아오는 연산자이다.
그러니까 ebp의 내용에서 0x48을 뺀 주소를 edi에 저정하라는 의미이다. (LEA)

LEA--Load Effective Address

Opcode

Instruction

Description

8D /r

LEA r16,m

Store effective address for m in register r16

8D /r

LEA r32,m

Store effective address for m in register r32


[링크 : http://www.intel.com/software/.../instruct32_hh/vc150.htm]

8.9.6 메모리 참조
------------------

  인텔문법에서 메모리를 간접적으로 참조하는 형식은 다음과 같다.
    SECTION:[BASE + INDEX*SCALE + DISP]
  이것은 다음과 같은 AT&T 방식으로 참조된다.
    SECTION:DISP(BASE, INDEX, SCALE)

[링크 : http://vozlt.tistory.com/8]

'Programming > Assembly(어셈블리)' 카테고리의 다른 글

.DATA? 지시어  (0) 2011.07.31
x86 register  (2) 2011.07.17
PowerPC(PPC) 어셈관련 내용  (0) 2011.04.04
어셈블리 언어  (0) 2010.05.03
어셈블리 언어 기본 템플릿  (0) 2010.04.17
Posted by 구차니

'Programming > Assembly(어셈블리)' 카테고리의 다른 글

.DATA? 지시어  (0) 2011.07.31
x86 register  (2) 2011.07.17
PowerPC(PPC) 어셈관련 내용  (0) 2011.04.04
어셈블리 메모리 참조 (x86 memory addressing)  (0) 2010.05.03
어셈블리 언어 기본 템플릿  (0) 2010.04.17
Posted by 구차니
Programming/C Win32 MFC2010. 4. 22. 14:28

#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.

[링크 : http://bytes.com/topic/c/answers/222558-operation-x-may-undefined]

위의 소스를 gcc -Wall 옵션을 주고 컴파일 할 경우에
$ 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이 들어가는게 아닐까 생각된다.

아니면 말구?

[링크 : http://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html]


winXP SP3 32bit / VC++ 6 에서 해본 결과
 2 1 1


linux / gcc 결과
 3 3 1


objdump를 소스와 함께 디스어셈블 하기 위해서는
gcc -g 옵션으로 디버깅 정보를 주어야 한다.
[링크 : http://wikidocs.net/mybook/1473]


솔찍히 어셈을 몰라서 모르겠다 ㅋㅋ
결론 : 한줄에 ++나 -- 연산자를 중복으로 사용하지 말자.
Posted by 구차니
음.. 역시 모든 언어는 skeleton code를 외우면 상대적으로 익히기가 쉬운듯!
(문득 C언어 배울때 #include <stdio.h> void main() {} 하던 기억이.. OTL)

.386
.MODEL Flat, STDCALL
.DATA
; Your initialized data. <comment>
.DATA?
;Your uninitialized data. <comment>
.CONST
.CODE
label:
    end label

[링크 : http://win32assembly.online.fr/tut1.html]

'Programming > Assembly(어셈블리)' 카테고리의 다른 글

.DATA? 지시어  (0) 2011.07.31
x86 register  (2) 2011.07.17
PowerPC(PPC) 어셈관련 내용  (0) 2011.04.04
어셈블리 메모리 참조 (x86 memory addressing)  (0) 2010.05.03
어셈블리 언어  (0) 2010.05.03
Posted by 구차니
Programming/언어론2010. 4. 17. 17:39
convention 은

[링크 : http://engdic.daum.net/dicen/contents.do?query1=E255050]
이런 의미를 가지는데, 굳이 해석하자면, 호출 규약 혹은 관용적인 호출방법 이라고 하면 되려나?

아무튼 문득 Iczelion 의 강좌를 읽다보니 어셈블리 기본 구조에
STDCALL 이라는 용어가 나오고, calling convention 이 나오길래 자세히 읽어 봤더니
'함수를 호출시에 인자를 넘겨주는 데이터를 stack에 넣는 방법'을 의미한다.

.MODEL FLAT, STDCALL
.MODEL is an assembler directive that specifies memory model of your program. Under Win32, there's only on model, FLAT model.
STDCALL tells MASM about parameter passing convention. Parameter passing convention specifies the order of  parameter passing, left-to-right or right-to-left, and also who will balance the stack frame after the function call.
Under Win16, there are two types of calling convention, C and PASCAL
C calling convention passes parameters from right to left, that is , the rightmost parameter is pushed first. The caller is responsible for balancing the stack frame after the call. For example, in order to call a function named foo(int first_param, int second_param, int third_param) in C calling convention the asm codes will look like this:

push  [third_param]               ; Push the third parameter
push  [second_param]            ; Followed by the second
push  [first_param]                ; And the first
call    foo
add    sp, 12                                ; The caller balances the stack frame
PASCAL calling convention is the reverse of C calling convention. It passes parameters from left to right and the callee is responsible for the stack balancing after the call.
Win16 adopts
PASCAL convention because it produces smaller codes. C convention is useful when you don't know how many parameters will be passed to the function as in the case of wsprintf(). In the case of wsprintf(), the function has no way to determine beforehand how many parameters will be pushed on the stack, so it cannot do the stack balancing.
STDCALL is the hybrid of C and PASCAL convention. It passes parameter from right to left but the callee is responsible for stack balancing after the call.Win32 platform use STDCALL exclusively. Except in one case: wsprintf(). You must use C calling convention with wsprintf().


[링크 : http://win32assembly.online.fr/tut1.html]

예를 들어, C언어의 경우에는  STDCALL을 사용하며,
인자(argument)들은 오른쪽 부터 stack에 push() 된다.

즉,
push(arg4);
push(arg3);
push(arg2);
push(arg1);
이런식으로 함수 호출시 인자를 넘겨주게 된다.


음.. 개인적인 생각이지만, C언어의 경우 heap은 아래에서 위로 커나가는데 그 방향을 맞추려고
stack에도 데이터를 이렇게 반대 순서로 넣는게 아닐까 싶다.

물론 argument 순서가 의미는 없기 때문에(받아들이는 쪽에서 알아서 받는다면)
가장 위에 첫 인자가 있을 이유는 없는데, 굳이 이런식으로 방향성을 가진다는건...
메모리 구조에 기인한게 아닐려나?

(아니면 말구 -ㅁ-!)

'Programming > 언어론' 카테고리의 다른 글

dangling if-else  (0) 2014.08.13
double의 정확도 자릿수  (0) 2011.03.25
함수 포인터 (function pointer)  (0) 2010.09.16
type system  (0) 2010.09.15
Posted by 구차니