블로그 이미지
안녕1999

카테고리

전체 (3067)
자바스크립트 (20)
안드로이드 (14)
WebGL (4)
변비 (17)
정치,경제 (35)
C언어,ARM (162)
컴퓨터(PC, Note Book, 윈.. (41)
전자회로, PCB (27)
유머,안웃긴,GIF,동영상 (118)
국부론60 (71)
모듈(PCB) (3)
건강 (2)
FreeCAD (25)
PADS (43)
퇴직,퇴사,구직,취업 활동 (3)
C# (86)
엑셀 (8)
워드 (0)
LabView (6)
레고 (30)
FPGA (0)
Total
Today
Yesterday

달력

« » 2024.5
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31

공지사항

최근에 올라온 글

버퍼메모리를 8비트, 16비트, 32비트 배열로 액세스하는 방법

new Int32Array(); // new in ES2017
new Int32Array(length);
new Int32Array(typedArray);
new Int32Array(object);
new Int32Array(buffer [, byteOffset [, length]]);

this.svga_memory16 = new Uint16Array(this.svga_memory.buffer); this.svga_memory32 = new Int32Array(this.svga_memory.buffer); this.vga_memory = new Uint8Array(this.svga_memory.buffer, 0, 4 * VGA_BANK_SIZE); this.plane0 = new Uint8Array(this.svga_memory.buffer, 0 * VGA_BANK_SIZE, VGA_BANK_SIZE); this.plane1 = new Uint8Array(this.svga_memory.buffer, 1 * VGA_BANK_SIZE, VGA_BANK_SIZE); this.plane2 = new Uint8Array(this.svga_memory.buffer, 2 * VGA_BANK_SIZE, VGA_BANK_SIZE); this.plane3 = new Uint8Array(this.svga_memory.buffer, 3 * VGA_BANK_SIZE, VGA_BANK_SIZE);


'자바스크립트' 카테고리의 다른 글

클래스용 함수내에서 this는 무엇인가?  (0) 2017.06.14
Sleep  (0) 2017.06.12
this  (0) 2017.06.08
자바스크립트-멤버함수내에서 this를 항상 사용해야하는가?(생략가능한가?)  (0) 2017.06.07
sprintf  (0) 2017.05.27
Posted by 안녕1999
, |

'a'문자의 코드를 구하는 방법.

'a'.charCodeAt(0) === 97



바이트 배열 Uint8Array

--------------------------------------------

var i,b=new Uint8Array(12),c;


c='a'.charCodeAt(0);

for(i=0;i<12;i++)

{

b[i]=c;

c++;

console.log("b[i]=",b[i]);

}

b[0]=0x54;

wSocket.send(b);

Posted by 안녕1999
, |

var i,n,a=["문자열1","문자열2","문자열3"];


n=a.length;

for(i=0;i<n;i++)

{

console.log(a[i]);

}



'a'문자의 코드를 구하는 방법.

'a'.charCodeAt(0) === 97



바이트 배열 Uint8Array

--------------------------------------------

var i,b=new Uint8Array(12),c;


c='a'.charCodeAt(0);

for(i=0;i<12;i++)

{

b[i]=c;

c++;

console.log("b[i]=",b[i]);

}

b[0]=0x54;

wSocket.send(b);

Posted by 안녕1999
, |

자바스크립트에서는 아래와 같이 배열 선언가능

var a=new Array();



function new_Array2(a,b)

{

var i,r=new Array(a);

for(i=0;i<b;i++)

{

r[i]=new Array(b);//각 요소마다 배열을 선언해주어야 한다.

}

return r;

}


※주의 : 배열 차원을 잘못 사용하면, 배열전체가 초기화됨(자바언어의 특징)

예) 2차원 배열 -> 1차원 배열로 사용할 경우

var a2=new_Array2(3,4);


a2[0][0]=2;

a2[0]=10;//a2를 다른형태로 사용하면, 배열전체가 바뀌어버림,

console.log("a2[0]=",a2[0]);//a2[0]= 10

console.log("a2[0][0]=",a2[0][0]);//undefined



※배열차원을 넘어서면, 에러.

예) 2차배열을 3차배열로 사용할 경우.

//a3[0][0][1][2]=3;//j.c:306 Uncaught TypeError: Cannot set property '2' of undefined




function test_new_Array2()

{

console.log("test_new_Array2()");

var a2=new_Array2(3,4);


//a2[0]=10;//a2를 다른형태로 사용(선언)하면, 바뀌어버림,

//console.log("a2[0]=",a2[0]);//a2[0]= 10

console.log("a2[0][0]=",a2[0][0]);//undefined

console.log("a2[0][1]=",a2[0][1]);//undefined

a2[0][0]=2;

console.log("-a2[0][0]=",a2[0][0]);//undefined ???? a2를 다른형태로 사용(선언)하면, 바뀌어버림,

a2[0][1]=3;

//a2[0][1][2]=3;//undefined

console.log("a2[0][1]=",a2[0][1]);//ok

//console.log("a2[0][1][2]=",a2[0][1][2]);//undefined

}

test_new_Array2();

Posted by 안녕1999
, |

디버그모드에서 ASM코드를 보니, 3번째 코드가 가장 간결하다.
물론, 릴리즈모드에서는 어떻게 바뀔지 알 수 없다.


msg[4]=p[i];//1

msg[5]=p[i+1];//2

msg[6]=p[i+2];//3

msg[7]=p[i+3];//4

msg[8]=p[i+4];//5

msg[9]=p[i+5];//6


  msg[4]=*p;p++;//1

msg[5]=*p;p++;//2

msg[6]=*p;p++;//3

msg[7]=*p;p++;//4

msg[8]=*p;p++;//5

msg[9]=*p;p++;//6


  msg[4]=p[0];//1

msg[5]=p[1];//2

msg[6]=p[2];//3

msg[7]=p[3];//4

msg[8]=p[4];//5

msg[9]=p[5];p+=6;//6


Posted by 안녕1999
, |

최근에 달린 댓글

글 보관함