mirror of
https://github.com/Zeal-Operating-System/ZealOS.git
synced 2025-06-07 08:14:48 +00:00
cnt -> count
This commit is contained in:
parent
420ff49c6f
commit
1fcbe40f9e
Binary file not shown.
@ -2,7 +2,7 @@ U0 BgtDataRead()
|
|||||||
{
|
{
|
||||||
CBgtEntry *tmpb;
|
CBgtEntry *tmpb;
|
||||||
CBgtTemplate *tmpt;
|
CBgtTemplate *tmpt;
|
||||||
I64 i,cnt,size;
|
I64 i,count,size;
|
||||||
U8 *b,*ptr;
|
U8 *b,*ptr;
|
||||||
I64 max_num;
|
I64 max_num;
|
||||||
U8 **s=StrFileRead(bgt_string_file,&max_num);
|
U8 **s=StrFileRead(bgt_string_file,&max_num);
|
||||||
@ -15,8 +15,8 @@ U0 BgtDataRead()
|
|||||||
t_head.b.date=Now;
|
t_head.b.date=Now;
|
||||||
|
|
||||||
if (ptr=b=FileRead(bgt_data_file,&size)) {
|
if (ptr=b=FileRead(bgt_data_file,&size)) {
|
||||||
cnt=*ptr(I64 *)++;
|
count=*ptr(I64 *)++;
|
||||||
for (i=0;i<cnt;i++) {
|
for (i=0;i<count;i++) {
|
||||||
tmpb=CAlloc(sizeof(CBgtEntry));
|
tmpb=CAlloc(sizeof(CBgtEntry));
|
||||||
MemCpy(&tmpb->start,ptr,BE_SIZE);
|
MemCpy(&tmpb->start,ptr,BE_SIZE);
|
||||||
tmpb->credit=StrNew(s[tmpb->credit_idx]);
|
tmpb->credit=StrNew(s[tmpb->credit_idx]);
|
||||||
@ -26,8 +26,8 @@ U0 BgtDataRead()
|
|||||||
ptr+=BE_SIZE;
|
ptr+=BE_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
cnt=*ptr(I64 *)++;
|
count=*ptr(I64 *)++;
|
||||||
for (i=0;i<cnt;i++) {
|
for (i=0;i<count;i++) {
|
||||||
tmpt=CAlloc(sizeof(CBgtTemplate));
|
tmpt=CAlloc(sizeof(CBgtTemplate));
|
||||||
MemCpy(&tmpt->start,ptr,BT_SIZE);
|
MemCpy(&tmpt->start,ptr,BT_SIZE);
|
||||||
ptr+=BT_SIZE;
|
ptr+=BT_SIZE;
|
||||||
@ -48,7 +48,7 @@ U0 BgtDataRead()
|
|||||||
|
|
||||||
U0 BgtDataWrite()
|
U0 BgtDataWrite()
|
||||||
{
|
{
|
||||||
I64 i,num=0,size,cnt1,cnt2;
|
I64 i,num=0,size,count1,count2;
|
||||||
CHashTable *table=HashTableNew(1024);
|
CHashTable *table=HashTableNew(1024);
|
||||||
CBgtEntry *tmpb;
|
CBgtEntry *tmpb;
|
||||||
CBgtTemplate *tmpt;
|
CBgtTemplate *tmpt;
|
||||||
@ -64,33 +64,33 @@ U0 BgtDataWrite()
|
|||||||
}
|
}
|
||||||
|
|
||||||
tmpb=b_head.next;
|
tmpb=b_head.next;
|
||||||
cnt1=0;
|
count1=0;
|
||||||
while (tmpb!=&b_head) {
|
while (tmpb!=&b_head) {
|
||||||
if (tmpb->type!=BE_TEMPLATE_COPY) {
|
if (tmpb->type!=BE_TEMPLATE_COPY) {
|
||||||
tmpb->credit_idx =StrFileAdd(tmpb->credit,&num,table);
|
tmpb->credit_idx =StrFileAdd(tmpb->credit,&num,table);
|
||||||
tmpb->debit_idx =StrFileAdd(tmpb->debit,&num,table);
|
tmpb->debit_idx =StrFileAdd(tmpb->debit,&num,table);
|
||||||
tmpb->desc_idx =StrFileAdd(tmpb->desc,&num,table);
|
tmpb->desc_idx =StrFileAdd(tmpb->desc,&num,table);
|
||||||
cnt1++;
|
count1++;
|
||||||
}
|
}
|
||||||
tmpb=tmpb->next;
|
tmpb=tmpb->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
tmpt=t_head.next;
|
tmpt=t_head.next;
|
||||||
cnt2=0;
|
count2=0;
|
||||||
while (tmpt!=&t_head) {
|
while (tmpt!=&t_head) {
|
||||||
tmpt->b.credit_idx =StrFileAdd(tmpt->b.credit,&num,table);
|
tmpt->b.credit_idx =StrFileAdd(tmpt->b.credit,&num,table);
|
||||||
tmpt->b.debit_idx =StrFileAdd(tmpt->b.debit,&num,table);
|
tmpt->b.debit_idx =StrFileAdd(tmpt->b.debit,&num,table);
|
||||||
tmpt->b.desc_idx =StrFileAdd(tmpt->b.desc,&num,table);
|
tmpt->b.desc_idx =StrFileAdd(tmpt->b.desc,&num,table);
|
||||||
cnt2++;
|
count2++;
|
||||||
tmpt=tmpt->next;
|
tmpt=tmpt->next;
|
||||||
}
|
}
|
||||||
StrFileWrite(bgt_string_file,table);
|
StrFileWrite(bgt_string_file,table);
|
||||||
StrFileDel(table);
|
StrFileDel(table);
|
||||||
|
|
||||||
size=sizeof(I64)*2+cnt1*BE_SIZE+cnt2*(BT_SIZE+BE_SIZE);
|
size=sizeof(I64)*2+count1*BE_SIZE+count2*(BT_SIZE+BE_SIZE);
|
||||||
buf=ptr=MAlloc(size);
|
buf=ptr=MAlloc(size);
|
||||||
|
|
||||||
MemCpy(ptr,&cnt1,sizeof(I64));
|
MemCpy(ptr,&count1,sizeof(I64));
|
||||||
ptr+=sizeof(I64);
|
ptr+=sizeof(I64);
|
||||||
tmpb=b_head.next;
|
tmpb=b_head.next;
|
||||||
while (tmpb!=&b_head) {
|
while (tmpb!=&b_head) {
|
||||||
@ -101,7 +101,7 @@ U0 BgtDataWrite()
|
|||||||
tmpb=tmpb->next;
|
tmpb=tmpb->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
MemCpy(ptr,&cnt2,sizeof(I64));
|
MemCpy(ptr,&count2,sizeof(I64));
|
||||||
ptr+=sizeof(I64);
|
ptr+=sizeof(I64);
|
||||||
tmpt=t_head.next;
|
tmpt=t_head.next;
|
||||||
while (tmpt!=&t_head) {
|
while (tmpt!=&t_head) {
|
||||||
|
@ -137,8 +137,8 @@ U0 BgtRegen()
|
|||||||
//and line entries, so we never had to resync.
|
//and line entries, so we never had to resync.
|
||||||
|
|
||||||
doc_ce=pdoc->cur_entry;
|
doc_ce=pdoc->cur_entry;
|
||||||
timeout_jiffy=cnts.jiffies+JIFFY_FREQ; //Max one second.
|
timeout_jiffy=counts.jiffies+JIFFY_FREQ; //Max one second.
|
||||||
while (doc_ce!=pdoc && cnts.jiffies<timeout_jiffy) {
|
while (doc_ce!=pdoc && counts.jiffies<timeout_jiffy) {
|
||||||
while (doc_ce->type_u8!=DOCT_MENU_VAL || !(tmpb_ce=doc_ce->user_data)) {
|
while (doc_ce->type_u8!=DOCT_MENU_VAL || !(tmpb_ce=doc_ce->user_data)) {
|
||||||
doc_ce=doc_ce->next;
|
doc_ce=doc_ce->next;
|
||||||
if (doc_ce==pdoc) goto br_cont;
|
if (doc_ce==pdoc) goto br_cont;
|
||||||
|
@ -78,14 +78,14 @@ I64 StrEntriesCompare(CHashGeneric *h1,CHashGeneric *h2)
|
|||||||
|
|
||||||
public U0 StrFileWrite(U8 *name,CHashTable *table,Bool no_nums=FALSE)
|
public U0 StrFileWrite(U8 *name,CHashTable *table,Bool no_nums=FALSE)
|
||||||
{
|
{
|
||||||
I64 i,j,cnt,color=BLACK;
|
I64 i,j,count,color=BLACK;
|
||||||
CDoc *doc=DocNew(name);
|
CDoc *doc=DocNew(name);
|
||||||
CHashGeneric *tmph,**a;
|
CHashGeneric *tmph,**a;
|
||||||
if (table) {
|
if (table) {
|
||||||
cnt=0; //Count Strings
|
count=0; //Count Strings
|
||||||
for (i=0;i<=table->mask;i++)
|
for (i=0;i<=table->mask;i++)
|
||||||
cnt+=LinkedLstCnt(table->body[i]);
|
count+=LinkedLstCount(table->body[i]);
|
||||||
a=MAlloc(cnt*sizeof(CHashGeneric *));
|
a=MAlloc(count*sizeof(CHashGeneric *));
|
||||||
j=0; //Load Strings
|
j=0; //Load Strings
|
||||||
for (i=0;i<=table->mask;i++) {
|
for (i=0;i<=table->mask;i++) {
|
||||||
tmph=table->body[i];
|
tmph=table->body[i];
|
||||||
@ -94,8 +94,8 @@ public U0 StrFileWrite(U8 *name,CHashTable *table,Bool no_nums=FALSE)
|
|||||||
tmph=tmph->next;
|
tmph=tmph->next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
QSortI64(a,cnt,&StrEntriesCompare);
|
QSortI64(a,count,&StrEntriesCompare);
|
||||||
for (i=0;i<cnt;i++) {
|
for (i=0;i<count;i++) {
|
||||||
tmph=a[i];
|
tmph=a[i];
|
||||||
if (tmph->user_data1&15!=color) {
|
if (tmph->user_data1&15!=color) {
|
||||||
DocPrint(doc,"$$FG,%d$$",tmph->user_data1&15);
|
DocPrint(doc,"$$FG,%d$$",tmph->user_data1&15);
|
||||||
|
@ -5,8 +5,8 @@
|
|||||||
|
|
||||||
class Ball
|
class Ball
|
||||||
{
|
{
|
||||||
I32 vertex_cnt;
|
I32 vertex_count;
|
||||||
I32 tri_cnt;
|
I32 tri_count;
|
||||||
CD3I32 v[VERTICES_NUM];
|
CD3I32 v[VERTICES_NUM];
|
||||||
CMeshTri t[TRIS_NUM];
|
CMeshTri t[TRIS_NUM];
|
||||||
} *b;
|
} *b;
|
||||||
@ -35,10 +35,10 @@ U0 BDCorrect(BallDefineStruct *bd)
|
|||||||
I64 AddVertex(BallDefineStruct *,I64 x,I64 y,I64 z)
|
I64 AddVertex(BallDefineStruct *,I64 x,I64 y,I64 z)
|
||||||
{
|
{
|
||||||
I64 i;
|
I64 i;
|
||||||
for (i=0;i<b->vertex_cnt;i++)
|
for (i=0;i<b->vertex_count;i++)
|
||||||
if (b->v[i].x==x && b->v[i].y==y && b->v[i].z==z)
|
if (b->v[i].x==x && b->v[i].y==y && b->v[i].z==z)
|
||||||
return i;
|
return i;
|
||||||
i=b->vertex_cnt++;
|
i=b->vertex_count++;
|
||||||
b->v[i].x=x;
|
b->v[i].x=x;
|
||||||
b->v[i].y=y;
|
b->v[i].y=y;
|
||||||
b->v[i].z=z;
|
b->v[i].z=z;
|
||||||
@ -47,7 +47,7 @@ I64 AddVertex(BallDefineStruct *,I64 x,I64 y,I64 z)
|
|||||||
|
|
||||||
I64 AddTri(BallDefineStruct *,I64 c,I64 n0,I64 n1,I64 n2)
|
I64 AddTri(BallDefineStruct *,I64 c,I64 n0,I64 n1,I64 n2)
|
||||||
{
|
{
|
||||||
I64 res=b->tri_cnt++;
|
I64 res=b->tri_count++;
|
||||||
b->t[res].color=c;
|
b->t[res].color=c;
|
||||||
b->t[res].nums[0]=n0;
|
b->t[res].nums[0]=n0;
|
||||||
b->t[res].nums[1]=n1;
|
b->t[res].nums[1]=n1;
|
||||||
@ -59,16 +59,16 @@ U8 *Ball2CSprite()
|
|||||||
{
|
{
|
||||||
//See $LK,"::/Zenith/Gr/GrSpritePlot.HC",A="FL:::/Zenith/Gr/GrSpritePlot.HC,1"$ for how CSprite are stored.
|
//See $LK,"::/Zenith/Gr/GrSpritePlot.HC",A="FL:::/Zenith/Gr/GrSpritePlot.HC,1"$ for how CSprite are stored.
|
||||||
U8 *res=MAlloc(sizeof(CSpriteMeshU8s)+
|
U8 *res=MAlloc(sizeof(CSpriteMeshU8s)+
|
||||||
b->vertex_cnt*sizeof(CD3I32)+b->tri_cnt*sizeof(CMeshTri)
|
b->vertex_count*sizeof(CD3I32)+b->tri_count*sizeof(CMeshTri)
|
||||||
+sprite_elem_base_sizes[SPT_END]),
|
+sprite_elem_base_sizes[SPT_END]),
|
||||||
*dst=res;
|
*dst=res;
|
||||||
*dst++ =SPT_MESH;
|
*dst++ =SPT_MESH;
|
||||||
*dst(I32 *)++ =b->vertex_cnt;
|
*dst(I32 *)++ =b->vertex_count;
|
||||||
*dst(I32 *)++ =b->tri_cnt;
|
*dst(I32 *)++ =b->tri_count;
|
||||||
MemCpy(dst,&b->v,b->vertex_cnt*sizeof(CD3I32));
|
MemCpy(dst,&b->v,b->vertex_count*sizeof(CD3I32));
|
||||||
dst+=b->vertex_cnt*sizeof(CD3I32);
|
dst+=b->vertex_count*sizeof(CD3I32);
|
||||||
MemCpy(dst,&b->t,b->tri_cnt*sizeof(CMeshTri));
|
MemCpy(dst,&b->t,b->tri_count*sizeof(CMeshTri));
|
||||||
dst+=b->tri_cnt*sizeof(CMeshTri);
|
dst+=b->tri_count*sizeof(CMeshTri);
|
||||||
*dst++ =SPT_END;
|
*dst++ =SPT_END;
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
@ -116,7 +116,7 @@ public U8 *BallGen()
|
|||||||
"%h7c",'\n';
|
"%h7c",'\n';
|
||||||
Sprite(res,"\t\t$$SP,\"<1>\",BI=%d$$");
|
Sprite(res,"\t\t$$SP,\"<1>\",BI=%d$$");
|
||||||
"%h7c",'\n';
|
"%h7c",'\n';
|
||||||
"Vertices:%d\n",b->vertex_cnt;
|
"Vertices:%d\n",b->vertex_count;
|
||||||
Free(b);
|
Free(b);
|
||||||
"Do another";
|
"Do another";
|
||||||
if (YorN)
|
if (YorN)
|
||||||
|
@ -5,8 +5,8 @@
|
|||||||
|
|
||||||
class Man
|
class Man
|
||||||
{
|
{
|
||||||
I32 vertex_cnt;
|
I32 vertex_count;
|
||||||
I32 tri_cnt;
|
I32 tri_count;
|
||||||
CD3I32 v[VERTICES_NUM];
|
CD3I32 v[VERTICES_NUM];
|
||||||
CMeshTri t[TRIS_NUM];
|
CMeshTri t[TRIS_NUM];
|
||||||
} *m;
|
} *m;
|
||||||
@ -142,7 +142,7 @@ U0 MDCorrect(ManDefineStruct *md)
|
|||||||
|
|
||||||
I64 AddVertex(ManDefineStruct *md,I64 x,I64 y,I64 z)
|
I64 AddVertex(ManDefineStruct *md,I64 x,I64 y,I64 z)
|
||||||
{
|
{
|
||||||
I64 res=m->vertex_cnt++;
|
I64 res=m->vertex_count++;
|
||||||
m->v[res].x=-x;
|
m->v[res].x=-x;
|
||||||
m->v[res].y=-y-md->leg_len-md->foot_rad*2;
|
m->v[res].y=-y-md->leg_len-md->foot_rad*2;
|
||||||
m->v[res].z=-z;
|
m->v[res].z=-z;
|
||||||
@ -151,7 +151,7 @@ I64 AddVertex(ManDefineStruct *md,I64 x,I64 y,I64 z)
|
|||||||
|
|
||||||
I64 AddTri(ManDefineStruct *,I64 c,I64 n0,I64 n1,I64 n2)
|
I64 AddTri(ManDefineStruct *,I64 c,I64 n0,I64 n1,I64 n2)
|
||||||
{
|
{
|
||||||
I64 res=m->tri_cnt++;
|
I64 res=m->tri_count++;
|
||||||
m->t[res].color=c;
|
m->t[res].color=c;
|
||||||
m->t[res].nums[0]=n1;
|
m->t[res].nums[0]=n1;
|
||||||
m->t[res].nums[1]=n0;
|
m->t[res].nums[1]=n0;
|
||||||
@ -213,16 +213,16 @@ U8 *Man2CSprite()
|
|||||||
{
|
{
|
||||||
//See $LK,"::/Zenith/Gr/GrSpritePlot.HC",A="FL:::/Zenith/Gr/GrSpritePlot.HC,1"$ for how CSprite are stored.
|
//See $LK,"::/Zenith/Gr/GrSpritePlot.HC",A="FL:::/Zenith/Gr/GrSpritePlot.HC,1"$ for how CSprite are stored.
|
||||||
U8 *res=MAlloc(sizeof(CSpriteMeshU8s)+
|
U8 *res=MAlloc(sizeof(CSpriteMeshU8s)+
|
||||||
m->vertex_cnt*sizeof(CD3I32)+m->tri_cnt*sizeof(CMeshTri)+
|
m->vertex_count*sizeof(CD3I32)+m->tri_count*sizeof(CMeshTri)+
|
||||||
sprite_elem_base_sizes[SPT_END]),
|
sprite_elem_base_sizes[SPT_END]),
|
||||||
*dst=res;
|
*dst=res;
|
||||||
*dst++ =SPT_MESH;
|
*dst++ =SPT_MESH;
|
||||||
*dst(I32 *)++ =m->vertex_cnt;
|
*dst(I32 *)++ =m->vertex_count;
|
||||||
*dst(I32 *)++ =m->tri_cnt;
|
*dst(I32 *)++ =m->tri_count;
|
||||||
MemCpy(dst,&m->v,m->vertex_cnt*sizeof(CD3I32));
|
MemCpy(dst,&m->v,m->vertex_count*sizeof(CD3I32));
|
||||||
dst+=m->vertex_cnt*sizeof(CD3I32);
|
dst+=m->vertex_count*sizeof(CD3I32);
|
||||||
MemCpy(dst,&m->t,m->tri_cnt*sizeof(CMeshTri));
|
MemCpy(dst,&m->t,m->tri_count*sizeof(CMeshTri));
|
||||||
dst+=m->tri_cnt*sizeof(CMeshTri);
|
dst+=m->tri_count*sizeof(CMeshTri);
|
||||||
*dst++ =SPT_END;
|
*dst++ =SPT_END;
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
@ -641,7 +641,7 @@ mo_got_message:
|
|||||||
tmpn=psm.cur_note;
|
tmpn=psm.cur_note;
|
||||||
while (tmpn!=&psm.head) {
|
while (tmpn!=&psm.head) {
|
||||||
if (tmpn->type!=PSMT_METER) {
|
if (tmpn->type!=PSMT_METER) {
|
||||||
timeout_val=cnts.jiffies;
|
timeout_val=counts.jiffies;
|
||||||
if (ms.pos_text.y-Fs->win_top<18)
|
if (ms.pos_text.y-Fs->win_top<18)
|
||||||
message_code=ScanMessage(&arg1,&arg2,1<<MESSAGE_KEY_DOWN|
|
message_code=ScanMessage(&arg1,&arg2,1<<MESSAGE_KEY_DOWN|
|
||||||
1<<MESSAGE_MS_L_DOWN|1<<MESSAGE_MS_R_UP|1<<MESSAGE_CMD);
|
1<<MESSAGE_MS_L_DOWN|1<<MESSAGE_MS_R_UP|1<<MESSAGE_CMD);
|
||||||
|
@ -24,7 +24,7 @@ U0 SpanDel(CMathODE *ode)
|
|||||||
|
|
||||||
U8 *SpanSave(CMathODE *ode,I64 *_size=NULL)
|
U8 *SpanSave(CMathODE *ode,I64 *_size=NULL)
|
||||||
{
|
{
|
||||||
I64 cnt;
|
I64 count;
|
||||||
U8 *res,*ptr;
|
U8 *res,*ptr;
|
||||||
MyMass *tmpm;
|
MyMass *tmpm;
|
||||||
MySpring *tmps;
|
MySpring *tmps;
|
||||||
@ -41,9 +41,9 @@ U8 *SpanSave(CMathODE *ode,I64 *_size=NULL)
|
|||||||
else
|
else
|
||||||
h.num_springs=0;
|
h.num_springs=0;
|
||||||
|
|
||||||
cnt=sizeof(SpanHeader)+h.num_masses*M_SIZE+h.num_springs*S_SIZE;
|
count=sizeof(SpanHeader)+h.num_masses*M_SIZE+h.num_springs*S_SIZE;
|
||||||
|
|
||||||
ptr=res=MAlloc(cnt);
|
ptr=res=MAlloc(count);
|
||||||
MemCpy(ptr,&h,sizeof(SpanHeader));
|
MemCpy(ptr,&h,sizeof(SpanHeader));
|
||||||
ptr+=sizeof(SpanHeader);
|
ptr+=sizeof(SpanHeader);
|
||||||
|
|
||||||
@ -60,7 +60,7 @@ U8 *SpanSave(CMathODE *ode,I64 *_size=NULL)
|
|||||||
ptr+=S_SIZE;
|
ptr+=S_SIZE;
|
||||||
tmps=tmps->next;
|
tmps=tmps->next;
|
||||||
}
|
}
|
||||||
if (_size) *_size=cnt;
|
if (_size) *_size=count;
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -274,14 +274,14 @@ U0 MPMenDraw(CDC *dc2)
|
|||||||
{
|
{
|
||||||
CTask *task=dc2->win_task;
|
CTask *task=dc2->win_task;
|
||||||
CDC *dc=DCAlias(dc2,task);
|
CDC *dc=DCAlias(dc2,task);
|
||||||
I64 i,r[16],lo=Gs->num*U_NUM/mp_cnt,hi=(Gs->num+1)*U_NUM/mp_cnt,
|
I64 i,r[16],lo=Gs->num*U_NUM/mp_count,hi=(Gs->num+1)*U_NUM/mp_count,
|
||||||
yy,phase,scroll_y=MAP_HEIGHT-100-100*(tS-t0);
|
yy,phase,scroll_y=MAP_HEIGHT-100-100*(tS-t0);
|
||||||
Unit *tmpu;
|
Unit *tmpu;
|
||||||
Explosion *tmpe;
|
Explosion *tmpe;
|
||||||
U8 *tmps,**_tmps;
|
U8 *tmps,**_tmps;
|
||||||
F64 tt,ts=tS;
|
F64 tt,ts=tS;
|
||||||
|
|
||||||
for (i=Gs->num;i<E_NUM;i+=mp_cnt) {
|
for (i=Gs->num;i<E_NUM;i+=mp_count) {
|
||||||
tmpe=&e[i];
|
tmpe=&e[i];
|
||||||
yy=(tmpe->y-scroll_y)&(MAP_HEIGHT-1);
|
yy=(tmpe->y-scroll_y)&(MAP_HEIGHT-1);
|
||||||
if (-32<=yy<=task->pix_bottom+32 && !tmpe->dead) {
|
if (-32<=yy<=task->pix_bottom+32 && !tmpe->dead) {
|
||||||
@ -376,8 +376,8 @@ U0 DrawIt(CTask *task,CDC *dc)
|
|||||||
}
|
}
|
||||||
|
|
||||||
DCDepthBufAlloc(dc);
|
DCDepthBufAlloc(dc);
|
||||||
mp_not_done_flags=1<<mp_cnt-1;
|
mp_not_done_flags=1<<mp_count-1;
|
||||||
for (i=0;i<mp_cnt;i++)
|
for (i=0;i<mp_count;i++)
|
||||||
JobQueue(&MPMenDraw,dc,i);
|
JobQueue(&MPMenDraw,dc,i);
|
||||||
while (mp_not_done_flags)
|
while (mp_not_done_flags)
|
||||||
Yield;
|
Yield;
|
||||||
@ -509,9 +509,9 @@ U0 CheckCollisions()
|
|||||||
x=tmpu->x;
|
x=tmpu->x;
|
||||||
y=(tmpu->y-scroll_y)&(MAP_HEIGHT-1);
|
y=(tmpu->y-scroll_y)&(MAP_HEIGHT-1);
|
||||||
if (0<=x<GR_WIDTH && 0<=y<GR_HEIGHT) {
|
if (0<=x<GR_WIDTH && 0<=y<GR_HEIGHT) {
|
||||||
dc2->collision_cnt=0;
|
dc2->collision_count=0;
|
||||||
GrRect(dc2,x-3,y-9,6,8);
|
GrRect(dc2,x-3,y-9,6,8);
|
||||||
if (dc2->collision_cnt)
|
if (dc2->collision_count)
|
||||||
ManDie(tmpu,TRUE);
|
ManDie(tmpu,TRUE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -817,7 +817,7 @@ U0 Titanium()
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
while (TRUE) {
|
while (TRUE) {
|
||||||
next_update_jiffy=cnts.jiffies+JIFFY_FREQ/100;
|
next_update_jiffy=counts.jiffies+JIFFY_FREQ/100;
|
||||||
while (message_code=ScanMessage(&ch,&sc,1<<MESSAGE_KEY_DOWN+1<<MESSAGE_KEY_UP)) {
|
while (message_code=ScanMessage(&ch,&sc,1<<MESSAGE_KEY_DOWN+1<<MESSAGE_KEY_UP)) {
|
||||||
switch (message_code) {
|
switch (message_code) {
|
||||||
case MESSAGE_KEY_DOWN:
|
case MESSAGE_KEY_DOWN:
|
||||||
|
@ -10,7 +10,7 @@ U0 PlayerIndirect()
|
|||||||
remaining++;
|
remaining++;
|
||||||
}
|
}
|
||||||
while (remaining) {
|
while (remaining) {
|
||||||
if (!alive_cnt[0] || !alive_cnt[1])
|
if (!alive_count[0] || !alive_count[1])
|
||||||
throw('GameOver',TRUE);
|
throw('GameOver',TRUE);
|
||||||
message_code=GetMessage(&arg1,&arg2,1<<MESSAGE_KEY_DOWN|1<<MESSAGE_MS_L_DOWN|1<<MESSAGE_MS_L_UP|
|
message_code=GetMessage(&arg1,&arg2,1<<MESSAGE_KEY_DOWN|1<<MESSAGE_MS_L_DOWN|1<<MESSAGE_MS_L_UP|
|
||||||
1<<MESSAGE_MS_R_UP);
|
1<<MESSAGE_MS_R_UP);
|
||||||
@ -68,7 +68,7 @@ U0 PlayerMove()
|
|||||||
I64 message_code,arg1,arg2;
|
I64 message_code,arg1,arg2;
|
||||||
ViewPlayerSet(cur_player);
|
ViewPlayerSet(cur_player);
|
||||||
while (TRUE) {
|
while (TRUE) {
|
||||||
if (!alive_cnt[0] || !alive_cnt[1])
|
if (!alive_count[0] || !alive_count[1])
|
||||||
throw('GameOver',TRUE);
|
throw('GameOver',TRUE);
|
||||||
message_code=GetMessage(&arg1,&arg2,1<<MESSAGE_KEY_DOWN|1<<MESSAGE_MS_L_DOWN|1<<MESSAGE_MS_L_UP|
|
message_code=GetMessage(&arg1,&arg2,1<<MESSAGE_KEY_DOWN|1<<MESSAGE_MS_L_DOWN|1<<MESSAGE_MS_L_UP|
|
||||||
1<<MESSAGE_MS_R_UP);
|
1<<MESSAGE_MS_R_UP);
|
||||||
@ -113,7 +113,7 @@ U0 PlayerDirect()
|
|||||||
I64 message_code,arg1,arg2;
|
I64 message_code,arg1,arg2;
|
||||||
ViewPlayerSet(cur_player);
|
ViewPlayerSet(cur_player);
|
||||||
while (TRUE) {
|
while (TRUE) {
|
||||||
if (!alive_cnt[0] || !alive_cnt[1])
|
if (!alive_count[0] || !alive_count[1])
|
||||||
throw('GameOver',TRUE);
|
throw('GameOver',TRUE);
|
||||||
message_code=GetMessage(&arg1,&arg2,1<<MESSAGE_KEY_DOWN|1<<MESSAGE_MS_L_DOWN|1<<MESSAGE_MS_L_UP|
|
message_code=GetMessage(&arg1,&arg2,1<<MESSAGE_KEY_DOWN|1<<MESSAGE_MS_L_DOWN|1<<MESSAGE_MS_L_UP|
|
||||||
1<<MESSAGE_MS_R_UP);
|
1<<MESSAGE_MS_R_UP);
|
||||||
|
Binary file not shown.
@ -69,7 +69,7 @@ Bool DamageDo(Unit *target,F64 damage)
|
|||||||
Sleep(1000*animation_delay);
|
Sleep(1000*animation_delay);
|
||||||
target->life=0;
|
target->life=0;
|
||||||
VisRecalc(VR_FRIENDLY_UNIT_DIED,target);
|
VisRecalc(VR_FRIENDLY_UNIT_DIED,target);
|
||||||
alive_cnt[target->player]--;
|
alive_count[target->player]--;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
} else {
|
} else {
|
||||||
if (target->armor) {
|
if (target->armor) {
|
||||||
@ -201,7 +201,7 @@ Bool HexOccupy(Bool overrun,Unit *tmpu,Unit *target)
|
|||||||
} else {
|
} else {
|
||||||
tmpu->life=0;
|
tmpu->life=0;
|
||||||
VisRecalc(VR_FRIENDLY_UNIT_DIED,tmpu);
|
VisRecalc(VR_FRIENDLY_UNIT_DIED,tmpu);
|
||||||
alive_cnt[tmpu->player]--;
|
alive_count[tmpu->player]--;
|
||||||
"$$RED$$Failure$$FG$$\n";
|
"$$RED$$Failure$$FG$$\n";
|
||||||
while (scrncast.ona) //see $LK,"Snd",A="MN:Snd"$()
|
while (scrncast.ona) //see $LK,"Snd",A="MN:Snd"$()
|
||||||
Yield;
|
Yield;
|
||||||
|
@ -78,7 +78,7 @@ U8 vis_unit_bitmap[2][(((UNITS_NUM+7)&~7)*UNITS_NUM)>>3];
|
|||||||
#define PHASE_END 6
|
#define PHASE_END 6
|
||||||
|
|
||||||
I64 phase,cur_player,enemy_player,view_player,turn,
|
I64 phase,cur_player,enemy_player,view_player,turn,
|
||||||
cursor_row,cursor_col,alive_cnt[2],
|
cursor_row,cursor_col,alive_count[2],
|
||||||
player_indirect[2],player_move[2],player_direct[2];
|
player_indirect[2],player_move[2],player_direct[2];
|
||||||
F64 animation_delay=0.5;
|
F64 animation_delay=0.5;
|
||||||
|
|
||||||
|
@ -71,10 +71,10 @@ U0 DrawHexes()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
U0 MakeTerrain(U8 color,I64 cnt,I64 clus_lo,I64 clus_hi)
|
U0 MakeTerrain(U8 color,I64 count,I64 clus_lo,I64 clus_hi)
|
||||||
{
|
{
|
||||||
I64 i,j,l,row,col;
|
I64 i,j,l,row,col;
|
||||||
for (i=0;i<cnt;i++) {
|
for (i=0;i<count;i++) {
|
||||||
col=RandU32%map_cols;
|
col=RandU32%map_cols;
|
||||||
row=RandU32%map_rows;
|
row=RandU32%map_rows;
|
||||||
l=clus_lo+RandU16%(clus_hi-clus_lo+1);
|
l=clus_lo+RandU16%(clus_hi-clus_lo+1);
|
||||||
@ -234,9 +234,9 @@ U0 InitUnits()
|
|||||||
I64 i,j,row,col,type;
|
I64 i,j,row,col,type;
|
||||||
Unit *tmpu;
|
Unit *tmpu;
|
||||||
MemSet(units,0,sizeof(units));
|
MemSet(units,0,sizeof(units));
|
||||||
alive_cnt[0]=alive_cnt[1]=UNITS_NUM;
|
alive_count[0]=alive_count[1]=UNITS_NUM;
|
||||||
for (j=0;j<2;j++)
|
for (j=0;j<2;j++)
|
||||||
for (i=0;i<alive_cnt[j];i++) {
|
for (i=0;i<alive_count[j];i++) {
|
||||||
tmpu=&units[j][i];
|
tmpu=&units[j][i];
|
||||||
tmpu->player=j;
|
tmpu->player=j;
|
||||||
tmpu->num=i;
|
tmpu->num=i;
|
||||||
|
@ -133,7 +133,7 @@ Bool MPVisRecalc(MPCtrl1 *job)
|
|||||||
|
|
||||||
Bool VisRecalc(I64 mode,Unit *tmpu=NULL)
|
Bool VisRecalc(I64 mode,Unit *tmpu=NULL)
|
||||||
{
|
{
|
||||||
I64 i,hi,k,cnt;
|
I64 i,hi,k,count;
|
||||||
Bool res;
|
Bool res;
|
||||||
/*The compiler doesn't go out of it's way
|
/*The compiler doesn't go out of it's way
|
||||||
to know if something is const.;-)This
|
to know if something is const.;-)This
|
||||||
@ -143,8 +143,8 @@ AOT binaries.ZenithOS has a limited
|
|||||||
stk size, so don't get in the habit.
|
stk size, so don't get in the habit.
|
||||||
$LK,"MAlloc",A="MN:MAlloc"$() would probably be the better choice.
|
$LK,"MAlloc",A="MN:MAlloc"$() would probably be the better choice.
|
||||||
*/
|
*/
|
||||||
MPCtrl1 job[mp_cnt];
|
MPCtrl1 job[mp_count];
|
||||||
CJob *cmd[mp_cnt];
|
CJob *cmd[mp_count];
|
||||||
|
|
||||||
if (mode==VR_FRIENDLY_UNIT_DIED) {
|
if (mode==VR_FRIENDLY_UNIT_DIED) {
|
||||||
MemSet((&vis_unit_bitmap[enemy_player])(U8 *)+
|
MemSet((&vis_unit_bitmap[enemy_player])(U8 *)+
|
||||||
@ -153,7 +153,7 @@ $LK,"MAlloc",A="MN:MAlloc"$() would probably be the better choice.
|
|||||||
return 0; //Return any value--don't care
|
return 0; //Return any value--don't care
|
||||||
}
|
}
|
||||||
|
|
||||||
cnt=mp_cnt; //Cores
|
count=mp_count; //Cores
|
||||||
hi=UNITS_NUM;
|
hi=UNITS_NUM;
|
||||||
if (mode==VR_ONE_ENEMY_UNIT) {
|
if (mode==VR_ONE_ENEMY_UNIT) {
|
||||||
for (hi--;hi>=0;hi--)
|
for (hi--;hi>=0;hi--)
|
||||||
@ -162,22 +162,22 @@ $LK,"MAlloc",A="MN:MAlloc"$() would probably be the better choice.
|
|||||||
hi++;
|
hi++;
|
||||||
}
|
}
|
||||||
k=hi;
|
k=hi;
|
||||||
if (hi/mp_cnt<2)
|
if (hi/mp_count<2)
|
||||||
cnt=1;
|
count=1;
|
||||||
for (i=0;i<cnt;i++) {
|
for (i=0;i<count;i++) {
|
||||||
job[i].mode=mode;
|
job[i].mode=mode;
|
||||||
job[i].tmpu=tmpu;
|
job[i].tmpu=tmpu;
|
||||||
job[i].hi=k;
|
job[i].hi=k;
|
||||||
k-=hi/cnt;
|
k-=hi/count;
|
||||||
if (k<0) k=0;
|
if (k<0) k=0;
|
||||||
if (i==cnt-1) k=0;
|
if (i==count-1) k=0;
|
||||||
job[i].lo=k;
|
job[i].lo=k;
|
||||||
}
|
}
|
||||||
|
|
||||||
res=FALSE;
|
res=FALSE;
|
||||||
for (i=0;i<cnt;i++)
|
for (i=0;i<count;i++)
|
||||||
cmd[i]=JobQueue(&MPVisRecalc,&job[i],i,0);
|
cmd[i]=JobQueue(&MPVisRecalc,&job[i],i,0);
|
||||||
for (i=0;i<cnt;i++)
|
for (i=0;i<count;i++)
|
||||||
if (JobResGet(cmd[i]))
|
if (JobResGet(cmd[i]))
|
||||||
res=TRUE;
|
res=TRUE;
|
||||||
if (mode==VR_UPDATE_FRIENDLY_UNIT)
|
if (mode==VR_UPDATE_FRIENDLY_UNIT)
|
||||||
@ -198,26 +198,26 @@ U0 MPVisRecalcMap(MPCtrl2 *job)
|
|||||||
|
|
||||||
U0 VisRecalcMap(I64 row,I64 col)
|
U0 VisRecalcMap(I64 row,I64 col)
|
||||||
{
|
{
|
||||||
I64 i,hi,k,cnt;
|
I64 i,hi,k,count;
|
||||||
MPCtrl2 job[mp_cnt];
|
MPCtrl2 job[mp_count];
|
||||||
CJob *cmd[mp_cnt];
|
CJob *cmd[mp_count];
|
||||||
|
|
||||||
cnt=mp_cnt; //Cores
|
count=mp_count; //Cores
|
||||||
hi=map_rows;
|
hi=map_rows;
|
||||||
k=hi;
|
k=hi;
|
||||||
if (hi/mp_cnt<2)
|
if (hi/mp_count<2)
|
||||||
cnt=1;
|
count=1;
|
||||||
for (i=0;i<cnt;i++) {
|
for (i=0;i<count;i++) {
|
||||||
job[i].row=row;
|
job[i].row=row;
|
||||||
job[i].col=col;
|
job[i].col=col;
|
||||||
job[i].hi=k;
|
job[i].hi=k;
|
||||||
k-=hi/cnt;
|
k-=hi/count;
|
||||||
if (k<0) k=0;
|
if (k<0) k=0;
|
||||||
if (i==cnt-1) k=0;
|
if (i==count-1) k=0;
|
||||||
job[i].lo=k;
|
job[i].lo=k;
|
||||||
}
|
}
|
||||||
for (i=0;i<cnt;i++)
|
for (i=0;i<count;i++)
|
||||||
cmd[i]=JobQueue(&MPVisRecalcMap,&job[i],i,0);
|
cmd[i]=JobQueue(&MPVisRecalcMap,&job[i],i,0);
|
||||||
for (i=0;i<cnt;i++)
|
for (i=0;i<count;i++)
|
||||||
JobResGet(cmd[i]);
|
JobResGet(cmd[i]);
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@ U0 TurnNew()
|
|||||||
moving_unit=NULL;
|
moving_unit=NULL;
|
||||||
|
|
||||||
SleepUntil(message_off_timeout);
|
SleepUntil(message_off_timeout);
|
||||||
message_off_timeout=cnts.jiffies+JIFFY_FREQ*2*animation_delay+1;
|
message_off_timeout=counts.jiffies+JIFFY_FREQ*2*animation_delay+1;
|
||||||
Snd(74);
|
Snd(74);
|
||||||
StrPrint(message_buf,"Turn %d",++turn);
|
StrPrint(message_buf,"Turn %d",++turn);
|
||||||
VRSetUp(0);
|
VRSetUp(0);
|
||||||
@ -35,7 +35,7 @@ U0 PhaseNew()
|
|||||||
}
|
}
|
||||||
|
|
||||||
SleepUntil(message_off_timeout);
|
SleepUntil(message_off_timeout);
|
||||||
message_off_timeout=cnts.jiffies+JIFFY_FREQ*2*animation_delay+1;
|
message_off_timeout=counts.jiffies+JIFFY_FREQ*2*animation_delay+1;
|
||||||
Snd(74);
|
Snd(74);
|
||||||
switch (phase) {
|
switch (phase) {
|
||||||
case PHASE_INDIRECT0:
|
case PHASE_INDIRECT0:
|
||||||
@ -94,7 +94,7 @@ U0 CharDo(U8 ch)
|
|||||||
U0 UserCheck()
|
U0 UserCheck()
|
||||||
{
|
{
|
||||||
I64 ch;
|
I64 ch;
|
||||||
if (!alive_cnt[0] || !alive_cnt[1])
|
if (!alive_count[0] || !alive_count[1])
|
||||||
throw('GameOver',TRUE);
|
throw('GameOver',TRUE);
|
||||||
if (ch=ScanChar)
|
if (ch=ScanChar)
|
||||||
CharDo(ch);
|
CharDo(ch);
|
||||||
|
@ -6,12 +6,12 @@ Bool ParseAsmImm(CCompCtrl *cc,CAsmArg *arg)
|
|||||||
arg->num.local_asm_undef_hash=NULL;
|
arg->num.local_asm_undef_hash=NULL;
|
||||||
arg->num.glbl_asm_undef_hash=NULL;
|
arg->num.glbl_asm_undef_hash=NULL;
|
||||||
cc->asm_undef_hash=NULL;
|
cc->asm_undef_hash=NULL;
|
||||||
cc->abs_cnts=0;
|
cc->abs_counts=0;
|
||||||
cc->flags&=~(CCF_UNRESOLVED+CCF_LOCAL);
|
cc->flags&=~(CCF_UNRESOLVED+CCF_LOCAL);
|
||||||
if (!IsLexExpression2Bin(cc,&arg->num.machine_code))
|
if (!IsLexExpression2Bin(cc,&arg->num.machine_code))
|
||||||
LexSkipEol(cc);
|
LexSkipEol(cc);
|
||||||
else {
|
else {
|
||||||
if (cc->abs_cnts.externs)
|
if (cc->abs_counts.externs)
|
||||||
LexExcept(cc,"Extern Not Allowed at ");
|
LexExcept(cc,"Extern Not Allowed at ");
|
||||||
if (cc->flags & CCF_UNRESOLVED) {
|
if (cc->flags & CCF_UNRESOLVED) {
|
||||||
if (cc->flags & CCF_LOCAL) {
|
if (cc->flags & CCF_LOCAL) {
|
||||||
@ -114,8 +114,8 @@ U0 ParseAsmArg(CCompCtrl *cc,CAsmArg *arg,Bool rel)
|
|||||||
} else {
|
} else {
|
||||||
pa_asm_direct_imm:
|
pa_asm_direct_imm:
|
||||||
ParseAsmImm(cc,arg);
|
ParseAsmImm(cc,arg);
|
||||||
arg->num.abs_cnts=cc->abs_cnts;
|
arg->num.abs_counts=cc->abs_counts;
|
||||||
if (arg->size<=1 && !rel && arg->num.abs_cnts&1) {
|
if (arg->size<=1 && !rel && arg->num.abs_counts&1) {
|
||||||
if (cc->aotc->seg_size==16)
|
if (cc->aotc->seg_size==16)
|
||||||
arg->size=2;
|
arg->size=2;
|
||||||
else
|
else
|
||||||
@ -162,7 +162,7 @@ pa_asm_direct_imm:
|
|||||||
} else {
|
} else {
|
||||||
pa_asm_indirect_imm:
|
pa_asm_indirect_imm:
|
||||||
ParseAsmImm(cc,arg);
|
ParseAsmImm(cc,arg);
|
||||||
arg->num.abs_cnts=cc->abs_cnts;
|
arg->num.abs_counts=cc->abs_counts;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (cc->token!=']')
|
if (cc->token!=']')
|
||||||
@ -265,7 +265,7 @@ mm_done:
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
Bool AsmStoreNum(CCompCtrl *cc,CAsmNum2 *num2,I64 cnt,Bool U8_avail)
|
Bool AsmStoreNum(CCompCtrl *cc,CAsmNum2 *num2,I64 count,Bool U8_avail)
|
||||||
{
|
{
|
||||||
CAOTCtrl *aotc=cc->aotc;
|
CAOTCtrl *aotc=cc->aotc;
|
||||||
I64 i;
|
I64 i;
|
||||||
@ -273,8 +273,8 @@ Bool AsmStoreNum(CCompCtrl *cc,CAsmNum2 *num2,I64 cnt,Bool U8_avail)
|
|||||||
|
|
||||||
if (!num2->imm_flag)
|
if (!num2->imm_flag)
|
||||||
num2->num.i-=num2->rel;
|
num2->num.i-=num2->rel;
|
||||||
for (i=0;i<cnt;i++) {
|
for (i=0;i<count;i++) {
|
||||||
if (num2->U8_cnt==1) {
|
if (num2->U8_count==1) {
|
||||||
if (num2->num.local_asm_undef_hash||num2->num.glbl_asm_undef_hash)
|
if (num2->num.local_asm_undef_hash||num2->num.glbl_asm_undef_hash)
|
||||||
AsmUnresolvedAdd(cc,num2->num.machine_code,IET_REL_I8+num2->imm_flag,
|
AsmUnresolvedAdd(cc,num2->num.machine_code,IET_REL_I8+num2->imm_flag,
|
||||||
aotc->rip,num2->rel,num2->num.local_asm_undef_hash,
|
aotc->rip,num2->rel,num2->num.local_asm_undef_hash,
|
||||||
@ -283,7 +283,7 @@ Bool AsmStoreNum(CCompCtrl *cc,CAsmNum2 *num2,I64 cnt,Bool U8_avail)
|
|||||||
else if (!num2->imm_flag && !(I8_MIN<=num2->num.i<=I8_MAX))
|
else if (!num2->imm_flag && !(I8_MIN<=num2->num.i<=I8_MAX))
|
||||||
LexExcept(cc,"Branch out of range at ");
|
LexExcept(cc,"Branch out of range at ");
|
||||||
if (num2->imm_flag) {
|
if (num2->imm_flag) {
|
||||||
if (num2->num.abs_cnts.abs_addres&1) {
|
if (num2->num.abs_counts.abs_addres&1) {
|
||||||
tmpa=CAlloc(sizeof(CAOTAbsAddr));
|
tmpa=CAlloc(sizeof(CAOTAbsAddr));
|
||||||
tmpa->next=aotc->abss;
|
tmpa->next=aotc->abss;
|
||||||
aotc->abss=tmpa;
|
aotc->abss=tmpa;
|
||||||
@ -291,7 +291,7 @@ Bool AsmStoreNum(CCompCtrl *cc,CAsmNum2 *num2,I64 cnt,Bool U8_avail)
|
|||||||
tmpa->type=AAT_ADD_U8;
|
tmpa->type=AAT_ADD_U8;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (num2->num.abs_cnts.c_addres&1) {
|
if (num2->num.abs_counts.c_addres&1) {
|
||||||
tmpa=CAlloc(sizeof(CAOTAbsAddr));
|
tmpa=CAlloc(sizeof(CAOTAbsAddr));
|
||||||
tmpa->next=aotc->abss;
|
tmpa->next=aotc->abss;
|
||||||
aotc->abss=tmpa;
|
aotc->abss=tmpa;
|
||||||
@ -301,7 +301,7 @@ Bool AsmStoreNum(CCompCtrl *cc,CAsmNum2 *num2,I64 cnt,Bool U8_avail)
|
|||||||
}
|
}
|
||||||
AOTStoreCodeU8(cc,num2->num.i);
|
AOTStoreCodeU8(cc,num2->num.i);
|
||||||
} else {
|
} else {
|
||||||
if (num2->U8_cnt==2) {
|
if (num2->U8_count==2) {
|
||||||
if (num2->num.local_asm_undef_hash||num2->num.glbl_asm_undef_hash)
|
if (num2->num.local_asm_undef_hash||num2->num.glbl_asm_undef_hash)
|
||||||
AsmUnresolvedAdd(cc,num2->num.machine_code,IET_REL_I16+num2->imm_flag,
|
AsmUnresolvedAdd(cc,num2->num.machine_code,IET_REL_I16+num2->imm_flag,
|
||||||
aotc->rip,num2->rel,num2->num.local_asm_undef_hash,
|
aotc->rip,num2->rel,num2->num.local_asm_undef_hash,
|
||||||
@ -310,7 +310,7 @@ Bool AsmStoreNum(CCompCtrl *cc,CAsmNum2 *num2,I64 cnt,Bool U8_avail)
|
|||||||
else if (!num2->imm_flag && !(I16_MIN<=num2->num.i<=I16_MAX))
|
else if (!num2->imm_flag && !(I16_MIN<=num2->num.i<=I16_MAX))
|
||||||
LexExcept(cc,"Branch out of range at ");
|
LexExcept(cc,"Branch out of range at ");
|
||||||
if (num2->imm_flag) {
|
if (num2->imm_flag) {
|
||||||
if (num2->num.abs_cnts.abs_addres&1) {
|
if (num2->num.abs_counts.abs_addres&1) {
|
||||||
tmpa=CAlloc(sizeof(CAOTAbsAddr));
|
tmpa=CAlloc(sizeof(CAOTAbsAddr));
|
||||||
tmpa->next=aotc->abss;
|
tmpa->next=aotc->abss;
|
||||||
aotc->abss=tmpa;
|
aotc->abss=tmpa;
|
||||||
@ -318,7 +318,7 @@ Bool AsmStoreNum(CCompCtrl *cc,CAsmNum2 *num2,I64 cnt,Bool U8_avail)
|
|||||||
tmpa->type=AAT_ADD_U16;
|
tmpa->type=AAT_ADD_U16;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (num2->num.abs_cnts.c_addres&1) {
|
if (num2->num.abs_counts.c_addres&1) {
|
||||||
tmpa=CAlloc(sizeof(CAOTAbsAddr));
|
tmpa=CAlloc(sizeof(CAOTAbsAddr));
|
||||||
tmpa->next=aotc->abss;
|
tmpa->next=aotc->abss;
|
||||||
aotc->abss=tmpa;
|
aotc->abss=tmpa;
|
||||||
@ -328,7 +328,7 @@ Bool AsmStoreNum(CCompCtrl *cc,CAsmNum2 *num2,I64 cnt,Bool U8_avail)
|
|||||||
}
|
}
|
||||||
AOTStoreCodeU8(cc,num2->num.i.u8[0]);
|
AOTStoreCodeU8(cc,num2->num.i.u8[0]);
|
||||||
AOTStoreCodeU8(cc,num2->num.i.u8[1]);
|
AOTStoreCodeU8(cc,num2->num.i.u8[1]);
|
||||||
} else if (num2->U8_cnt==4) {
|
} else if (num2->U8_count==4) {
|
||||||
if (num2->num.local_asm_undef_hash||num2->num.glbl_asm_undef_hash)
|
if (num2->num.local_asm_undef_hash||num2->num.glbl_asm_undef_hash)
|
||||||
AsmUnresolvedAdd(cc,num2->num.machine_code,IET_REL_I32+num2->imm_flag,
|
AsmUnresolvedAdd(cc,num2->num.machine_code,IET_REL_I32+num2->imm_flag,
|
||||||
aotc->rip,num2->rel,num2->num.local_asm_undef_hash,
|
aotc->rip,num2->rel,num2->num.local_asm_undef_hash,
|
||||||
@ -337,7 +337,7 @@ Bool AsmStoreNum(CCompCtrl *cc,CAsmNum2 *num2,I64 cnt,Bool U8_avail)
|
|||||||
else if (!num2->imm_flag && !(I32_MIN<=num2->num.i<=I32_MAX))
|
else if (!num2->imm_flag && !(I32_MIN<=num2->num.i<=I32_MAX))
|
||||||
LexExcept(cc,"Branch out of range at ");
|
LexExcept(cc,"Branch out of range at ");
|
||||||
if (num2->imm_flag) {
|
if (num2->imm_flag) {
|
||||||
if (num2->num.abs_cnts.abs_addres&1) {
|
if (num2->num.abs_counts.abs_addres&1) {
|
||||||
tmpa=CAlloc(sizeof(CAOTAbsAddr));
|
tmpa=CAlloc(sizeof(CAOTAbsAddr));
|
||||||
tmpa->next=aotc->abss;
|
tmpa->next=aotc->abss;
|
||||||
aotc->abss=tmpa;
|
aotc->abss=tmpa;
|
||||||
@ -345,7 +345,7 @@ Bool AsmStoreNum(CCompCtrl *cc,CAsmNum2 *num2,I64 cnt,Bool U8_avail)
|
|||||||
tmpa->type=AAT_ADD_U32;
|
tmpa->type=AAT_ADD_U32;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (num2->num.abs_cnts.c_addres&1) {
|
if (num2->num.abs_counts.c_addres&1) {
|
||||||
tmpa=CAlloc(sizeof(CAOTAbsAddr));
|
tmpa=CAlloc(sizeof(CAOTAbsAddr));
|
||||||
tmpa->next=aotc->abss;
|
tmpa->next=aotc->abss;
|
||||||
aotc->abss=tmpa;
|
aotc->abss=tmpa;
|
||||||
@ -354,14 +354,14 @@ Bool AsmStoreNum(CCompCtrl *cc,CAsmNum2 *num2,I64 cnt,Bool U8_avail)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
AOTStoreCodeU32(cc,num2->num.i);
|
AOTStoreCodeU32(cc,num2->num.i);
|
||||||
} else if (num2->U8_cnt==8) {
|
} else if (num2->U8_count==8) {
|
||||||
if (num2->num.local_asm_undef_hash||num2->num.glbl_asm_undef_hash)
|
if (num2->num.local_asm_undef_hash||num2->num.glbl_asm_undef_hash)
|
||||||
AsmUnresolvedAdd(cc,num2->num.machine_code,IET_REL_I64+num2->imm_flag,
|
AsmUnresolvedAdd(cc,num2->num.machine_code,IET_REL_I64+num2->imm_flag,
|
||||||
aotc->rip,num2->rel,num2->num.local_asm_undef_hash,
|
aotc->rip,num2->rel,num2->num.local_asm_undef_hash,
|
||||||
num2->num.glbl_asm_undef_hash,cc->lex_include_stk->line_num,
|
num2->num.glbl_asm_undef_hash,cc->lex_include_stk->line_num,
|
||||||
U8_avail);
|
U8_avail);
|
||||||
if (num2->imm_flag) {
|
if (num2->imm_flag) {
|
||||||
if (num2->num.abs_cnts.abs_addres&1) {
|
if (num2->num.abs_counts.abs_addres&1) {
|
||||||
tmpa=CAlloc(sizeof(CAOTAbsAddr));
|
tmpa=CAlloc(sizeof(CAOTAbsAddr));
|
||||||
tmpa->next=aotc->abss;
|
tmpa->next=aotc->abss;
|
||||||
aotc->abss=tmpa;
|
aotc->abss=tmpa;
|
||||||
@ -369,7 +369,7 @@ Bool AsmStoreNum(CCompCtrl *cc,CAsmNum2 *num2,I64 cnt,Bool U8_avail)
|
|||||||
tmpa->type=AAT_ADD_U64;
|
tmpa->type=AAT_ADD_U64;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (num2->num.abs_cnts.c_addres&1) {
|
if (num2->num.abs_counts.c_addres&1) {
|
||||||
tmpa=CAlloc(sizeof(CAOTAbsAddr));
|
tmpa=CAlloc(sizeof(CAOTAbsAddr));
|
||||||
tmpa->next=aotc->abss;
|
tmpa->next=aotc->abss;
|
||||||
aotc->abss=tmpa;
|
aotc->abss=tmpa;
|
||||||
@ -392,7 +392,7 @@ Bool AsmStoreNum(CCompCtrl *cc,CAsmNum2 *num2,I64 cnt,Bool U8_avail)
|
|||||||
|
|
||||||
U8 asm_seg_prefixes[6]={0x26,0x2E,0x36,0x3E,0x64,0x65};
|
U8 asm_seg_prefixes[6]={0x26,0x2E,0x36,0x3E,0x64,0x65};
|
||||||
|
|
||||||
Bool ParseAsmInst(CCompCtrl *cc,CHashOpcode *tmpo,I64 argcnt)
|
Bool ParseAsmInst(CCompCtrl *cc,CHashOpcode *tmpo,I64 argcount)
|
||||||
{
|
{
|
||||||
CAOTCtrl *aotc=cc->aotc;
|
CAOTCtrl *aotc=cc->aotc;
|
||||||
I64 i,j,arg1,arg2,om,seg,arg1mask,arg2mask;
|
I64 i,j,arg1,arg2,om,seg,arg1mask,arg2mask;
|
||||||
@ -401,16 +401,16 @@ Bool ParseAsmInst(CCompCtrl *cc,CHashOpcode *tmpo,I64 argcnt)
|
|||||||
CInst *tmpins;
|
CInst *tmpins;
|
||||||
CAsmIns cur,best;
|
CAsmIns cur,best;
|
||||||
|
|
||||||
best.U8_cnt=255;
|
best.U8_count=255;
|
||||||
if (argcnt>0)
|
if (argcount>0)
|
||||||
arg1mask=AsmMakeArgMask(cc,&aotc->arg1);
|
arg1mask=AsmMakeArgMask(cc,&aotc->arg1);
|
||||||
else
|
else
|
||||||
arg1mask=1;
|
arg1mask=1;
|
||||||
if (argcnt>1)
|
if (argcount>1)
|
||||||
arg2mask=AsmMakeArgMask(cc,&aotc->arg2);
|
arg2mask=AsmMakeArgMask(cc,&aotc->arg2);
|
||||||
else
|
else
|
||||||
arg2mask=1;
|
arg2mask=1;
|
||||||
for (i=0;i<tmpo->inst_entry_cnt;i++) {
|
for (i=0;i<tmpo->inst_entry_count;i++) {
|
||||||
tmpins=&tmpo->ins[i];
|
tmpins=&tmpo->ins[i];
|
||||||
if (tmpins->arg1==ARGT_REL8 || tmpins->arg2==ARGT_REL8)
|
if (tmpins->arg1==ARGT_REL8 || tmpins->arg2==ARGT_REL8)
|
||||||
U8_avail=TRUE;
|
U8_avail=TRUE;
|
||||||
@ -433,7 +433,7 @@ Bool ParseAsmInst(CCompCtrl *cc,CHashOpcode *tmpo,I64 argcnt)
|
|||||||
arg2=tmpins->arg2;
|
arg2=tmpins->arg2;
|
||||||
tmpa1=&aotc->arg1;
|
tmpa1=&aotc->arg1;
|
||||||
tmpa2=&aotc->arg2;
|
tmpa2=&aotc->arg2;
|
||||||
cur.last_opcode_U8=tmpins->opcode[tmpins->opcode_cnt-1];
|
cur.last_opcode_U8=tmpins->opcode[tmpins->opcode_count-1];
|
||||||
|
|
||||||
if (tmpins->slash_val<8) {
|
if (tmpins->slash_val<8) {
|
||||||
cur.ModrM|=tmpins->slash_val<<3;
|
cur.ModrM|=tmpins->slash_val<<3;
|
||||||
@ -444,23 +444,23 @@ Bool ParseAsmInst(CCompCtrl *cc,CHashOpcode *tmpo,I64 argcnt)
|
|||||||
aotc->seg_size!=16 && tmpins->flags & IEF_OP_SIZE16)
|
aotc->seg_size!=16 && tmpins->flags & IEF_OP_SIZE16)
|
||||||
cur.has_operand_prefix=TRUE;
|
cur.has_operand_prefix=TRUE;
|
||||||
|
|
||||||
if (om==OM_IB) cur.imm.U8_cnt=1;
|
if (om==OM_IB) cur.imm.U8_count=1;
|
||||||
else if (om==OM_IW) cur.imm.U8_cnt=2;
|
else if (om==OM_IW) cur.imm.U8_count=2;
|
||||||
else if (om==OM_ID) cur.imm.U8_cnt=4;
|
else if (om==OM_ID) cur.imm.U8_count=4;
|
||||||
|
|
||||||
if (om==OM_CB) {
|
if (om==OM_CB) {
|
||||||
cur.imm.U8_cnt=1;
|
cur.imm.U8_count=1;
|
||||||
cur.imm.imm_flag=FALSE;
|
cur.imm.imm_flag=FALSE;
|
||||||
} else if (om==OM_CW) {
|
} else if (om==OM_CW) {
|
||||||
cur.imm.U8_cnt=2;
|
cur.imm.U8_count=2;
|
||||||
cur.imm.imm_flag=FALSE;
|
cur.imm.imm_flag=FALSE;
|
||||||
} else if (om==OM_CD) {
|
} else if (om==OM_CD) {
|
||||||
cur.imm.U8_cnt=4;
|
cur.imm.U8_count=4;
|
||||||
cur.imm.imm_flag=FALSE;
|
cur.imm.imm_flag=FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (argcnt==1) {
|
if (argcount==1) {
|
||||||
if (best.U8_cnt!=255 && !found_second_possible && !best.is_dft) {
|
if (best.U8_count!=255 && !found_second_possible && !best.is_dft) {
|
||||||
found_second_possible=TRUE;
|
found_second_possible=TRUE;
|
||||||
if (!aotc->arg1.size)
|
if (!aotc->arg1.size)
|
||||||
PrintWarn("no size specified at %s,%04d\n",
|
PrintWarn("no size specified at %s,%04d\n",
|
||||||
@ -490,7 +490,7 @@ Bool ParseAsmInst(CCompCtrl *cc,CHashOpcode *tmpo,I64 argcnt)
|
|||||||
tmpa1->reg1==REG_NONE) {
|
tmpa1->reg1==REG_NONE) {
|
||||||
cur.ModrM=cur.ModrM+5;
|
cur.ModrM=cur.ModrM+5;
|
||||||
MemCpy(&cur.disp.num,&tmpa1->num,sizeof(CAsmNum));
|
MemCpy(&cur.disp.num,&tmpa1->num,sizeof(CAsmNum));
|
||||||
cur.disp.U8_cnt=4;
|
cur.disp.U8_count=4;
|
||||||
if (aotc->seg_size==64)
|
if (aotc->seg_size==64)
|
||||||
cur.disp.imm_flag=FALSE;
|
cur.disp.imm_flag=FALSE;
|
||||||
} else {
|
} else {
|
||||||
@ -519,7 +519,7 @@ Bool ParseAsmInst(CCompCtrl *cc,CHashOpcode *tmpo,I64 argcnt)
|
|||||||
if (tmpa1->reg1>=20) //RBPu8,RSPu8,RSIu8,RDIu8?
|
if (tmpa1->reg1>=20) //RBPu8,RSPu8,RSIu8,RDIu8?
|
||||||
cur.has_REX=TRUE;
|
cur.has_REX=TRUE;
|
||||||
MemCpy(&cur.disp.num,&tmpa1->num,sizeof(CAsmNum));
|
MemCpy(&cur.disp.num,&tmpa1->num,sizeof(CAsmNum));
|
||||||
cur.disp.U8_cnt=4;
|
cur.disp.U8_count=4;
|
||||||
} else {
|
} else {
|
||||||
cur.SIB|=(tmpa1->reg1&7)<<3+tmpa1->reg2&7;
|
cur.SIB|=(tmpa1->reg1&7)<<3+tmpa1->reg2&7;
|
||||||
if (tmpa1->reg1&15>7)
|
if (tmpa1->reg1&15>7)
|
||||||
@ -533,7 +533,7 @@ Bool ParseAsmInst(CCompCtrl *cc,CHashOpcode *tmpo,I64 argcnt)
|
|||||||
if (tmpa1->reg2&7==REG_RBP &&
|
if (tmpa1->reg2&7==REG_RBP &&
|
||||||
!tmpa1->imm_or_off_present && tmpa1->indirect) {
|
!tmpa1->imm_or_off_present && tmpa1->indirect) {
|
||||||
cur.ModrM|=0x40;
|
cur.ModrM|=0x40;
|
||||||
cur.disp.U8_cnt=1;
|
cur.disp.U8_count=1;
|
||||||
ModrM_complete=TRUE;
|
ModrM_complete=TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -544,13 +544,13 @@ Bool ParseAsmInst(CCompCtrl *cc,CHashOpcode *tmpo,I64 argcnt)
|
|||||||
if (!cur.disp.num.machine_code &&
|
if (!cur.disp.num.machine_code &&
|
||||||
I8_MIN<=cur.disp.num.i<=I8_MAX) {
|
I8_MIN<=cur.disp.num.i<=I8_MAX) {
|
||||||
cur.ModrM|=0x40;
|
cur.ModrM|=0x40;
|
||||||
cur.disp.U8_cnt=1;
|
cur.disp.U8_count=1;
|
||||||
} else if (aotc->seg_size==16) {
|
} else if (aotc->seg_size==16) {
|
||||||
cur.ModrM|=0x80;
|
cur.ModrM|=0x80;
|
||||||
cur.disp.U8_cnt=2;
|
cur.disp.U8_count=2;
|
||||||
} else {
|
} else {
|
||||||
cur.ModrM|=0x80;
|
cur.ModrM|=0x80;
|
||||||
cur.disp.U8_cnt=4;
|
cur.disp.U8_count=4;
|
||||||
}
|
}
|
||||||
} else if (!tmpa1->indirect) {
|
} else if (!tmpa1->indirect) {
|
||||||
cur.has_addr_prefix=FALSE;
|
cur.has_addr_prefix=FALSE;
|
||||||
@ -558,7 +558,7 @@ Bool ParseAsmInst(CCompCtrl *cc,CHashOpcode *tmpo,I64 argcnt)
|
|||||||
} else {
|
} else {
|
||||||
if (tmpa1->reg1&7==REG_RBP) {
|
if (tmpa1->reg1&7==REG_RBP) {
|
||||||
cur.ModrM|=0x40;
|
cur.ModrM|=0x40;
|
||||||
cur.disp.U8_cnt=1;
|
cur.disp.U8_count=1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -569,8 +569,8 @@ Bool ParseAsmInst(CCompCtrl *cc,CHashOpcode *tmpo,I64 argcnt)
|
|||||||
cur.REX|=8;
|
cur.REX|=8;
|
||||||
MemCpy(&cur.imm.num,&tmpa1->num,sizeof(CAsmNum));
|
MemCpy(&cur.imm.num,&tmpa1->num,sizeof(CAsmNum));
|
||||||
}
|
}
|
||||||
} else if (argcnt==2) {
|
} else if (argcount==2) {
|
||||||
if (best.U8_cnt!=255 && !found_second_possible && !best.is_dft) {
|
if (best.U8_count!=255 && !found_second_possible && !best.is_dft) {
|
||||||
found_second_possible=TRUE;
|
found_second_possible=TRUE;
|
||||||
if (!aotc->arg1.size && !aotc->arg2.size)
|
if (!aotc->arg1.size && !aotc->arg2.size)
|
||||||
PrintWarn("no size specified at %s,%04d\n",
|
PrintWarn("no size specified at %s,%04d\n",
|
||||||
@ -658,7 +658,7 @@ Bool ParseAsmInst(CCompCtrl *cc,CHashOpcode *tmpo,I64 argcnt)
|
|||||||
if (tmpa1->reg1>=20) //RBPu8,RSPu8,RSIu8,RDIu8?
|
if (tmpa1->reg1>=20) //RBPu8,RSPu8,RSIu8,RDIu8?
|
||||||
cur.has_REX=TRUE;
|
cur.has_REX=TRUE;
|
||||||
MemCpy(&cur.disp.num,&tmpa1->num,sizeof(CAsmNum));
|
MemCpy(&cur.disp.num,&tmpa1->num,sizeof(CAsmNum));
|
||||||
cur.disp.U8_cnt=4;
|
cur.disp.U8_count=4;
|
||||||
} else {
|
} else {
|
||||||
cur.SIB|=(tmpa1->reg1&7)<<3+tmpa1->reg2&7;
|
cur.SIB|=(tmpa1->reg1&7)<<3+tmpa1->reg2&7;
|
||||||
if (tmpa1->reg1&15>7)
|
if (tmpa1->reg1&15>7)
|
||||||
@ -672,7 +672,7 @@ Bool ParseAsmInst(CCompCtrl *cc,CHashOpcode *tmpo,I64 argcnt)
|
|||||||
if (tmpa1->reg2&7==REG_RBP &&
|
if (tmpa1->reg2&7==REG_RBP &&
|
||||||
!tmpa1->imm_or_off_present && tmpa1->indirect) {
|
!tmpa1->imm_or_off_present && tmpa1->indirect) {
|
||||||
cur.ModrM|=0x40;
|
cur.ModrM|=0x40;
|
||||||
cur.disp.U8_cnt=1;
|
cur.disp.U8_count=1;
|
||||||
ModrM_complete=TRUE;
|
ModrM_complete=TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -682,7 +682,7 @@ Bool ParseAsmInst(CCompCtrl *cc,CHashOpcode *tmpo,I64 argcnt)
|
|||||||
tmpa1->indirect && tmpa1->reg1==REG_NONE) {
|
tmpa1->indirect && tmpa1->reg1==REG_NONE) {
|
||||||
cur.ModrM=cur.ModrM&0xF8+5;
|
cur.ModrM=cur.ModrM&0xF8+5;
|
||||||
MemCpy(&cur.disp.num,&tmpa1->num,sizeof(CAsmNum));
|
MemCpy(&cur.disp.num,&tmpa1->num,sizeof(CAsmNum));
|
||||||
cur.disp.U8_cnt=4;
|
cur.disp.U8_count=4;
|
||||||
if (aotc->seg_size==64)
|
if (aotc->seg_size==64)
|
||||||
cur.disp.imm_flag=FALSE;
|
cur.disp.imm_flag=FALSE;
|
||||||
} else {
|
} else {
|
||||||
@ -691,13 +691,13 @@ Bool ParseAsmInst(CCompCtrl *cc,CHashOpcode *tmpo,I64 argcnt)
|
|||||||
if (!cur.disp.num.machine_code &&
|
if (!cur.disp.num.machine_code &&
|
||||||
I8_MIN<=cur.disp.num.i<=I8_MAX) {
|
I8_MIN<=cur.disp.num.i<=I8_MAX) {
|
||||||
cur.ModrM|=0x40;
|
cur.ModrM|=0x40;
|
||||||
cur.disp.U8_cnt=1;
|
cur.disp.U8_count=1;
|
||||||
} else if (aotc->seg_size==16) {
|
} else if (aotc->seg_size==16) {
|
||||||
cur.ModrM|=0x80;
|
cur.ModrM|=0x80;
|
||||||
cur.disp.U8_cnt=2;
|
cur.disp.U8_count=2;
|
||||||
} else {
|
} else {
|
||||||
cur.ModrM|=0x80;
|
cur.ModrM|=0x80;
|
||||||
cur.disp.U8_cnt=4;
|
cur.disp.U8_count=4;
|
||||||
}
|
}
|
||||||
} else if (!tmpa1->indirect) {
|
} else if (!tmpa1->indirect) {
|
||||||
cur.has_addr_prefix=FALSE;
|
cur.has_addr_prefix=FALSE;
|
||||||
@ -705,7 +705,7 @@ Bool ParseAsmInst(CCompCtrl *cc,CHashOpcode *tmpo,I64 argcnt)
|
|||||||
} else {
|
} else {
|
||||||
if (tmpa1->reg1&7==REG_RBP) {
|
if (tmpa1->reg1&7==REG_RBP) {
|
||||||
cur.ModrM|=0x40;
|
cur.ModrM|=0x40;
|
||||||
cur.disp.U8_cnt=1;
|
cur.disp.U8_count=1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -713,64 +713,64 @@ Bool ParseAsmInst(CCompCtrl *cc,CHashOpcode *tmpo,I64 argcnt)
|
|||||||
} else if (ARGT_MOFFS8<=arg1<=ARGT_MOFFS64) {
|
} else if (ARGT_MOFFS8<=arg1<=ARGT_MOFFS64) {
|
||||||
MemCpy(&cur.disp.num,&tmpa1->num,sizeof(CAsmNum));
|
MemCpy(&cur.disp.num,&tmpa1->num,sizeof(CAsmNum));
|
||||||
if (aotc->seg_size==16)
|
if (aotc->seg_size==16)
|
||||||
cur.disp.U8_cnt=2;
|
cur.disp.U8_count=2;
|
||||||
else
|
else
|
||||||
cur.disp.U8_cnt=4;
|
cur.disp.U8_count=4;
|
||||||
cur.has_addr_prefix=FALSE;
|
cur.has_addr_prefix=FALSE;
|
||||||
} else if (ARGT_MOFFS8<=arg2<=ARGT_MOFFS64) {
|
} else if (ARGT_MOFFS8<=arg2<=ARGT_MOFFS64) {
|
||||||
MemCpy(&cur.disp.num,&tmpa2->num,sizeof(CAsmNum));
|
MemCpy(&cur.disp.num,&tmpa2->num,sizeof(CAsmNum));
|
||||||
if (aotc->seg_size==16)
|
if (aotc->seg_size==16)
|
||||||
cur.disp.U8_cnt=2;
|
cur.disp.U8_count=2;
|
||||||
else
|
else
|
||||||
cur.disp.U8_cnt=4;
|
cur.disp.U8_count=4;
|
||||||
cur.has_addr_prefix=FALSE;
|
cur.has_addr_prefix=FALSE;
|
||||||
} else if (ARGT_IMM8<=arg1<=ARGT_IMM64 ||
|
} else if (ARGT_IMM8<=arg1<=ARGT_IMM64 ||
|
||||||
ARGT_UIMM8<=arg1<=ARGT_UIMM64) {
|
ARGT_UIMM8<=arg1<=ARGT_UIMM64) {
|
||||||
MemCpy(&cur.imm.num,&tmpa1->num,sizeof(CAsmNum));
|
MemCpy(&cur.imm.num,&tmpa1->num,sizeof(CAsmNum));
|
||||||
if (arg1==ARGT_IMM8 || arg1==ARGT_UIMM8) cur.imm.U8_cnt=1;
|
if (arg1==ARGT_IMM8 || arg1==ARGT_UIMM8) cur.imm.U8_count=1;
|
||||||
else if (arg1==ARGT_IMM16 || arg1==ARGT_UIMM16) cur.imm.U8_cnt=2;
|
else if (arg1==ARGT_IMM16 || arg1==ARGT_UIMM16) cur.imm.U8_count=2;
|
||||||
else if (arg1==ARGT_IMM32 || arg1==ARGT_UIMM32) cur.imm.U8_cnt=4;
|
else if (arg1==ARGT_IMM32 || arg1==ARGT_UIMM32) cur.imm.U8_count=4;
|
||||||
else {
|
else {
|
||||||
cur.imm.U8_cnt=8;
|
cur.imm.U8_count=8;
|
||||||
cur.REX|=8;
|
cur.REX|=8;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ARGT_IMM8<=arg2<=ARGT_IMM64 ||
|
if (ARGT_IMM8<=arg2<=ARGT_IMM64 ||
|
||||||
ARGT_UIMM8<=arg2<=ARGT_UIMM64) {
|
ARGT_UIMM8<=arg2<=ARGT_UIMM64) {
|
||||||
MemCpy(&cur.imm.num,&tmpa2->num,sizeof(CAsmNum));
|
MemCpy(&cur.imm.num,&tmpa2->num,sizeof(CAsmNum));
|
||||||
if (arg2==ARGT_IMM8 || arg2==ARGT_UIMM8) cur.imm.U8_cnt=1;
|
if (arg2==ARGT_IMM8 || arg2==ARGT_UIMM8) cur.imm.U8_count=1;
|
||||||
else if (arg2==ARGT_IMM16 || arg2==ARGT_UIMM16) cur.imm.U8_cnt=2;
|
else if (arg2==ARGT_IMM16 || arg2==ARGT_UIMM16) cur.imm.U8_count=2;
|
||||||
else if (arg2==ARGT_IMM32 || arg2==ARGT_UIMM32) {
|
else if (arg2==ARGT_IMM32 || arg2==ARGT_UIMM32) {
|
||||||
cur.imm.U8_cnt=4;
|
cur.imm.U8_count=4;
|
||||||
if (tmpins->flags&IEF_REX_ONLY_R8_R15 && arg2==ARGT_UIMM32)
|
if (tmpins->flags&IEF_REX_ONLY_R8_R15 && arg2==ARGT_UIMM32)
|
||||||
cur.REX&=~8;
|
cur.REX&=~8;
|
||||||
} else {
|
} else {
|
||||||
cur.imm.U8_cnt=8;
|
cur.imm.U8_count=8;
|
||||||
cur.REX|=8;
|
cur.REX|=8;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cur.U8_cnt=tmpins->opcode_cnt+cur.disp.U8_cnt+cur.imm.U8_cnt;
|
cur.U8_count=tmpins->opcode_count+cur.disp.U8_count+cur.imm.U8_count;
|
||||||
if (cur.has_ModrM) cur.U8_cnt++;
|
if (cur.has_ModrM) cur.U8_count++;
|
||||||
if (cur.has_SIB) cur.U8_cnt++;
|
if (cur.has_SIB) cur.U8_count++;
|
||||||
if (aotc->seg_size==64 && cur.REX&0x40==0x40 &&
|
if (aotc->seg_size==64 && cur.REX&0x40==0x40 &&
|
||||||
(cur.REX!=0x40 || cur.has_REX) &&
|
(cur.REX!=0x40 || cur.has_REX) &&
|
||||||
(cur.REX&7 || !(tmpins->flags&IEF_REX_ONLY_R8_R15 ||
|
(cur.REX&7 || !(tmpins->flags&IEF_REX_ONLY_R8_R15 ||
|
||||||
tmpins->flags&IEF_REX_XOR_LIKE && tmpa1->reg1==tmpa2->reg1 &&
|
tmpins->flags&IEF_REX_XOR_LIKE && tmpa1->reg1==tmpa2->reg1 &&
|
||||||
cur.ModrM&0xC0==0xC0)))
|
cur.ModrM&0xC0==0xC0)))
|
||||||
cur.U8_cnt++;
|
cur.U8_count++;
|
||||||
if (cur.U8_cnt<best.U8_cnt &&
|
if (cur.U8_count<best.U8_count &&
|
||||||
!(tmpins->flags & IEF_DONT_SWITCH_MODES &&
|
!(tmpins->flags & IEF_DONT_SWITCH_MODES &&
|
||||||
(cur.has_addr_prefix || cur.has_operand_prefix)))
|
(cur.has_addr_prefix || cur.has_operand_prefix)))
|
||||||
MemCpy(&best,&cur,sizeof(CAsmIns));
|
MemCpy(&best,&cur,sizeof(CAsmIns));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (best.U8_cnt<255) {
|
if (best.U8_count<255) {
|
||||||
tmpins=best.tmpins;
|
tmpins=best.tmpins;
|
||||||
seg=REG_NONE;
|
seg=REG_NONE;
|
||||||
if (argcnt>1 && aotc->arg2.seg!=REG_NONE && !aotc->arg2.just_seg)
|
if (argcount>1 && aotc->arg2.seg!=REG_NONE && !aotc->arg2.just_seg)
|
||||||
seg=aotc->arg2.seg;
|
seg=aotc->arg2.seg;
|
||||||
else if (argcnt>0 && aotc->arg1.seg!=REG_NONE && !aotc->arg1.just_seg)
|
else if (argcount>0 && aotc->arg1.seg!=REG_NONE && !aotc->arg1.just_seg)
|
||||||
seg=aotc->arg1.seg;
|
seg=aotc->arg1.seg;
|
||||||
if (seg!=REG_NONE)
|
if (seg!=REG_NONE)
|
||||||
AOTStoreCodeU8(cc,asm_seg_prefixes[seg]);
|
AOTStoreCodeU8(cc,asm_seg_prefixes[seg]);
|
||||||
@ -784,7 +784,7 @@ Bool ParseAsmInst(CCompCtrl *cc,CHashOpcode *tmpo,I64 argcnt)
|
|||||||
tmpins->flags&IEF_REX_XOR_LIKE && tmpa1->reg1==tmpa2->reg1 &&
|
tmpins->flags&IEF_REX_XOR_LIKE && tmpa1->reg1==tmpa2->reg1 &&
|
||||||
best.ModrM&0xC0==0xC0)))
|
best.ModrM&0xC0==0xC0)))
|
||||||
AOTStoreCodeU8(cc,best.REX);
|
AOTStoreCodeU8(cc,best.REX);
|
||||||
for (j=0;j<tmpins->opcode_cnt-1;j++)
|
for (j=0;j<tmpins->opcode_count-1;j++)
|
||||||
AOTStoreCodeU8(cc,tmpins->opcode[j]);
|
AOTStoreCodeU8(cc,tmpins->opcode[j]);
|
||||||
AOTStoreCodeU8(cc,best.last_opcode_U8);
|
AOTStoreCodeU8(cc,best.last_opcode_U8);
|
||||||
|
|
||||||
@ -793,14 +793,14 @@ Bool ParseAsmInst(CCompCtrl *cc,CHashOpcode *tmpo,I64 argcnt)
|
|||||||
if (best.has_SIB)
|
if (best.has_SIB)
|
||||||
AOTStoreCodeU8(cc,best.SIB);
|
AOTStoreCodeU8(cc,best.SIB);
|
||||||
|
|
||||||
if (best.disp.U8_cnt) {
|
if (best.disp.U8_count) {
|
||||||
best.disp.rel=aotc->rip+best.disp.U8_cnt+best.imm.U8_cnt;
|
best.disp.rel=aotc->rip+best.disp.U8_count+best.imm.U8_count;
|
||||||
if (!AsmStoreNum(cc,&best.disp,1,U8_avail))
|
if (!AsmStoreNum(cc,&best.disp,1,U8_avail))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (best.imm.U8_cnt) {
|
if (best.imm.U8_count) {
|
||||||
best.imm.rel=aotc->rip+best.imm.U8_cnt;
|
best.imm.rel=aotc->rip+best.imm.U8_count;
|
||||||
if (!AsmStoreNum(cc,&best.imm,1,U8_avail))
|
if (!AsmStoreNum(cc,&best.imm,1,U8_avail))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
@ -811,13 +811,13 @@ Bool ParseAsmInst(CCompCtrl *cc,CHashOpcode *tmpo,I64 argcnt)
|
|||||||
LexExcept(cc,"Invalid inst at ");
|
LexExcept(cc,"Invalid inst at ");
|
||||||
}
|
}
|
||||||
|
|
||||||
U0 ParseAsmDefine(CCompCtrl *cc,I64 U8_cnt)
|
U0 ParseAsmDefine(CCompCtrl *cc,I64 U8_count)
|
||||||
{
|
{
|
||||||
Bool is_dup;
|
Bool is_dup;
|
||||||
I64 i,dup_val;
|
I64 i,dup_val;
|
||||||
U8 *ptr;
|
U8 *ptr;
|
||||||
CAsmNum2 num2;
|
CAsmNum2 num2;
|
||||||
num2.U8_cnt=U8_cnt;
|
num2.U8_count=U8_count;
|
||||||
|
|
||||||
while (cc->token && cc->token!=';') {
|
while (cc->token && cc->token!=';') {
|
||||||
num2.num.local_asm_undef_hash=NULL;
|
num2.num.local_asm_undef_hash=NULL;
|
||||||
@ -830,13 +830,13 @@ U0 ParseAsmDefine(CCompCtrl *cc,I64 U8_cnt)
|
|||||||
Lex(cc); //Skip Str
|
Lex(cc); //Skip Str
|
||||||
} else {
|
} else {
|
||||||
is_dup=FALSE;
|
is_dup=FALSE;
|
||||||
cc->abs_cnts=0;
|
cc->abs_counts=0;
|
||||||
cc->asm_undef_hash=NULL;
|
cc->asm_undef_hash=NULL;
|
||||||
cc->flags&=~(CCF_UNRESOLVED+CCF_LOCAL);
|
cc->flags&=~(CCF_UNRESOLVED+CCF_LOCAL);
|
||||||
if (!IsLexExpression2Bin(cc,&num2.num.machine_code))
|
if (!IsLexExpression2Bin(cc,&num2.num.machine_code))
|
||||||
LexSkipEol(cc);
|
LexSkipEol(cc);
|
||||||
else {
|
else {
|
||||||
if (cc->abs_cnts.externs)
|
if (cc->abs_counts.externs)
|
||||||
LexExcept(cc,"Extern Not Allowed at ");
|
LexExcept(cc,"Extern Not Allowed at ");
|
||||||
if (cc->flags & CCF_UNRESOLVED) {
|
if (cc->flags & CCF_UNRESOLVED) {
|
||||||
if (cc->flags & CCF_LOCAL) {
|
if (cc->flags & CCF_LOCAL) {
|
||||||
@ -866,10 +866,10 @@ U0 ParseAsmDefine(CCompCtrl *cc,I64 U8_cnt)
|
|||||||
}
|
}
|
||||||
num2.rel=0;
|
num2.rel=0;
|
||||||
num2.imm_flag=TRUE;
|
num2.imm_flag=TRUE;
|
||||||
num2.num.abs_cnts=cc->abs_cnts;
|
num2.num.abs_counts=cc->abs_counts;
|
||||||
if (is_dup) {
|
if (is_dup) {
|
||||||
if (num2.num.local_asm_undef_hash || num2.num.glbl_asm_undef_hash)
|
if (num2.num.local_asm_undef_hash || num2.num.glbl_asm_undef_hash)
|
||||||
LexExcept(cc,"Undefined DUP cnt at ");
|
LexExcept(cc,"Undefined DUP count at ");
|
||||||
num2.num.i=dup_val;
|
num2.num.i=dup_val;
|
||||||
AsmStoreNum(cc,&num2,i,FALSE);
|
AsmStoreNum(cc,&num2,i,FALSE);
|
||||||
} else {
|
} else {
|
||||||
@ -904,7 +904,7 @@ U0 ParseBinFile(CCompCtrl *cc)
|
|||||||
U0 ParseAsmBlk(CCompCtrl *cc,I64 cmp_flags)
|
U0 ParseAsmBlk(CCompCtrl *cc,I64 cmp_flags)
|
||||||
{
|
{
|
||||||
CAOTCtrl *aotc=cc->aotc;
|
CAOTCtrl *aotc=cc->aotc;
|
||||||
I64 i,j,k,argcnt,
|
I64 i,j,k,argcount,
|
||||||
old_flags=cc->flags & CCF_ASM_EXPRESSIONS;
|
old_flags=cc->flags & CCF_ASM_EXPRESSIONS;
|
||||||
CHashOpcode *tmpo;
|
CHashOpcode *tmpo;
|
||||||
CHashExport *tmpex;
|
CHashExport *tmpex;
|
||||||
@ -1008,15 +1008,15 @@ U0 ParseAsmBlk(CCompCtrl *cc,I64 cmp_flags)
|
|||||||
} else if (cc->hash_entry->type & HTT_OPCODE) {
|
} else if (cc->hash_entry->type & HTT_OPCODE) {
|
||||||
tmpo=cc->hash_entry;
|
tmpo=cc->hash_entry;
|
||||||
Lex(cc); //skip opcode
|
Lex(cc); //skip opcode
|
||||||
argcnt=0;
|
argcount=0;
|
||||||
if (tmpo->ins[0].arg1) {
|
if (tmpo->ins[0].arg1) {
|
||||||
argcnt++;
|
argcount++;
|
||||||
if (ARGT_REL8<=tmpo->ins[0].arg1<=ARGT_REL32)
|
if (ARGT_REL8<=tmpo->ins[0].arg1<=ARGT_REL32)
|
||||||
ParseAsmArg(cc,&aotc->arg1,TRUE);
|
ParseAsmArg(cc,&aotc->arg1,TRUE);
|
||||||
else
|
else
|
||||||
ParseAsmArg(cc,&aotc->arg1,FALSE);
|
ParseAsmArg(cc,&aotc->arg1,FALSE);
|
||||||
if (tmpo->ins[0].arg2) {
|
if (tmpo->ins[0].arg2) {
|
||||||
argcnt++;
|
argcount++;
|
||||||
if (cc->token!=',')
|
if (cc->token!=',')
|
||||||
LexExcept(cc,"Expecting ',' at ");
|
LexExcept(cc,"Expecting ',' at ");
|
||||||
else {
|
else {
|
||||||
@ -1028,7 +1028,7 @@ U0 ParseAsmBlk(CCompCtrl *cc,I64 cmp_flags)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ParseAsmInst(cc,tmpo,argcnt);
|
ParseAsmInst(cc,tmpo,argcount);
|
||||||
} else if (cc->hash_entry->type & HTT_EXPORT_SYS_SYM) {
|
} else if (cc->hash_entry->type & HTT_EXPORT_SYS_SYM) {
|
||||||
if (Btr(&cc->hash_entry->type,HTf_UNRESOLVED)) {
|
if (Btr(&cc->hash_entry->type,HTf_UNRESOLVED)) {
|
||||||
if (cc->hash_entry->type & HTF_LOCAL) {
|
if (cc->hash_entry->type & HTF_LOCAL) {
|
||||||
@ -1087,7 +1087,7 @@ U0 ParseAsmBlk(CCompCtrl *cc,I64 cmp_flags)
|
|||||||
g_lb->type=CMT_ASM_LABEL;
|
g_lb->type=CMT_ASM_LABEL;
|
||||||
g_lb->flags|=CMF_DEFINED;
|
g_lb->flags|=CMF_DEFINED;
|
||||||
g_lb->rip=aotc->rip;
|
g_lb->rip=aotc->rip;
|
||||||
g_lb->use_cnt++; //Disable warning on unused labels.
|
g_lb->use_count++; //Disable warning on unused labels.
|
||||||
ICAdd(cc,IC_LABEL,g_lb,0);
|
ICAdd(cc,IC_LABEL,g_lb,0);
|
||||||
}
|
}
|
||||||
if (cc->token==TK_DBL_COLON) {
|
if (cc->token==TK_DBL_COLON) {
|
||||||
|
@ -100,16 +100,16 @@ U0 AsmHashLoad()
|
|||||||
LexExcept(cc,"Expecting opcode at ");
|
LexExcept(cc,"Expecting opcode at ");
|
||||||
MemSet(tmpo_max,0,size_max);
|
MemSet(tmpo_max,0,size_max);
|
||||||
tmpo_max->type=HTT_OPCODE;
|
tmpo_max->type=HTT_OPCODE;
|
||||||
tmpo_max->inst_entry_cnt=0;
|
tmpo_max->inst_entry_count=0;
|
||||||
tmpo_max->str=cc->cur_str;
|
tmpo_max->str=cc->cur_str;
|
||||||
cc->cur_str=0;
|
cc->cur_str=0;
|
||||||
Lex(cc); //Skip OPCODE
|
Lex(cc); //Skip OPCODE
|
||||||
while (cc->token && cc->token!=';' && cc->token!=':') {
|
while (cc->token && cc->token!=';' && cc->token!=':') {
|
||||||
tmpins=&tmpo_max->ins[tmpo_max->inst_entry_cnt];
|
tmpins=&tmpo_max->ins[tmpo_max->inst_entry_count];
|
||||||
tmpins->ins_entry_num=tmpo_max->inst_entry_cnt++;
|
tmpins->ins_entry_num=tmpo_max->inst_entry_count++;
|
||||||
tmpins->slash_val=SV_NONE; //Not zero!!
|
tmpins->slash_val=SV_NONE; //Not zero!!
|
||||||
while (cc->token==TK_I64) {
|
while (cc->token==TK_I64) {
|
||||||
tmpins->opcode[tmpins->opcode_cnt++]=cc->cur_i64;
|
tmpins->opcode[tmpins->opcode_count++]=cc->cur_i64;
|
||||||
Lex(cc);
|
Lex(cc);
|
||||||
}
|
}
|
||||||
if (cc->token==',')
|
if (cc->token==',')
|
||||||
@ -151,10 +151,10 @@ U0 AsmHashLoad()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
size=offset(CHashOpcode.ins)+sizeof(CInst)*tmpo_max->inst_entry_cnt;
|
size=offset(CHashOpcode.ins)+sizeof(CInst)*tmpo_max->inst_entry_count;
|
||||||
tmpo=MAlloc(size);
|
tmpo=MAlloc(size);
|
||||||
MemCpy(tmpo,tmpo_max,size);
|
MemCpy(tmpo,tmpo_max,size);
|
||||||
tmpo->use_cnt=0;
|
tmpo->use_count=0;
|
||||||
if (HashFind(tmpo->str,cmp.asm_hash,HTT_OPCODE))
|
if (HashFind(tmpo->str,cmp.asm_hash,HTT_OPCODE))
|
||||||
LexExcept(cc,"Duplicate OPCODE entry ");
|
LexExcept(cc,"Duplicate OPCODE entry ");
|
||||||
HashAdd(tmpo,cmp.asm_hash);
|
HashAdd(tmpo,cmp.asm_hash);
|
||||||
|
@ -130,11 +130,11 @@ I64 AsmLexExpression(CCompCtrl *cc)
|
|||||||
I64 res=0;
|
I64 res=0;
|
||||||
cc->asm_undef_hash=NULL;
|
cc->asm_undef_hash=NULL;
|
||||||
cc->flags&=~(CCF_UNRESOLVED+CCF_LOCAL);
|
cc->flags&=~(CCF_UNRESOLVED+CCF_LOCAL);
|
||||||
cc->abs_cnts=0;
|
cc->abs_counts=0;
|
||||||
if (!IsLexExpression2Bin(cc,&machine_code))
|
if (!IsLexExpression2Bin(cc,&machine_code))
|
||||||
LexSkipEol(cc);
|
LexSkipEol(cc);
|
||||||
else {
|
else {
|
||||||
if (cc->abs_cnts.externs)
|
if (cc->abs_counts.externs)
|
||||||
LexExcept(cc,"Extern Not Allowed at ");
|
LexExcept(cc,"Extern Not Allowed at ");
|
||||||
if (cc->flags & CCF_UNRESOLVED)
|
if (cc->flags & CCF_UNRESOLVED)
|
||||||
LexExcept(cc,"Undefined sym at ");
|
LexExcept(cc,"Undefined sym at ");
|
||||||
|
@ -106,7 +106,7 @@ U0 AOTGlobalsResolve(CCompCtrl *cc,CAOT *tmpaot)
|
|||||||
if (!(tmpex->type & HTF_IMPORT)) {
|
if (!(tmpex->type & HTF_IMPORT)) {
|
||||||
if (cc->htc.local_var_lst) {
|
if (cc->htc.local_var_lst) {
|
||||||
tmpex->type|=HTF_GOTO_LABEL;
|
tmpex->type|=HTF_GOTO_LABEL;
|
||||||
tmpex->use_cnt++;
|
tmpex->use_count++;
|
||||||
} else {
|
} else {
|
||||||
PrintErr("Undefined sym at line:%04d %s\n",
|
PrintErr("Undefined sym at line:%04d %s\n",
|
||||||
tmpu->line_num,tmpex->str);
|
tmpu->line_num,tmpex->str);
|
||||||
@ -135,7 +135,7 @@ U0 AOTGlobalsResolve(CCompCtrl *cc,CAOT *tmpaot)
|
|||||||
tmpex=cc->htc.glbl_hash_table->body[i];
|
tmpex=cc->htc.glbl_hash_table->body[i];
|
||||||
while (tmpex) {
|
while (tmpex) {
|
||||||
if (tmpex->type & (HTF_IMPORT|HTF_GOTO_LABEL)) {
|
if (tmpex->type & (HTF_IMPORT|HTF_GOTO_LABEL)) {
|
||||||
if (tmpex->use_cnt && (tmpie=tmpex->ie_lst)) {
|
if (tmpex->use_count && (tmpie=tmpex->ie_lst)) {
|
||||||
if (tmpex->type&HTF_GOTO_LABEL)
|
if (tmpex->type&HTF_GOTO_LABEL)
|
||||||
tmpie->flags|=IEF_GOTO_LABEL;
|
tmpie->flags|=IEF_GOTO_LABEL;
|
||||||
if (tmpex->import_name)
|
if (tmpex->import_name)
|
||||||
|
@ -306,7 +306,7 @@ U0 ICPreIncDec(CIntermediateCode *tmpi,I64 op,I64 rip)
|
|||||||
I64 r;
|
I64 r;
|
||||||
CHashClass *tmpc=tmpi->ic_class,*tmpc1=tmpc-1;
|
CHashClass *tmpc=tmpi->ic_class,*tmpc1=tmpc-1;
|
||||||
if (tmpi->ic_flags & ICF_BY_VAL) {
|
if (tmpi->ic_flags & ICF_BY_VAL) {
|
||||||
if (tmpc->ptr_stars_cnt && tmpc1->size!=1) {
|
if (tmpc->ptr_stars_count && tmpc1->size!=1) {
|
||||||
ICAddSubEctImm(tmpi,
|
ICAddSubEctImm(tmpi,
|
||||||
tmpi->arg1.type&MDG_MASK+tmpi->arg1_type_pointed_to,
|
tmpi->arg1.type&MDG_MASK+tmpi->arg1_type_pointed_to,
|
||||||
tmpi->arg1.reg,tmpi->arg1.disp,
|
tmpi->arg1.reg,tmpi->arg1.disp,
|
||||||
@ -328,7 +328,7 @@ U0 ICPreIncDec(CIntermediateCode *tmpi,I64 op,I64 rip)
|
|||||||
tmpi->arg1.type,tmpi->arg1.reg,tmpi->arg1.disp,rip);
|
tmpi->arg1.type,tmpi->arg1.reg,tmpi->arg1.disp,rip);
|
||||||
r=REG_RCX;
|
r=REG_RCX;
|
||||||
}
|
}
|
||||||
if (tmpc->ptr_stars_cnt &&
|
if (tmpc->ptr_stars_count &&
|
||||||
tmpc1->size!=1) {
|
tmpc1->size!=1) {
|
||||||
ICAddSubEctImm(tmpi,MDF_DISP+tmpi->arg1_type_pointed_to,r,0,
|
ICAddSubEctImm(tmpi,MDF_DISP+tmpi->arg1_type_pointed_to,r,0,
|
||||||
MDF_DISP+tmpi->arg1_type_pointed_to,r,0,
|
MDF_DISP+tmpi->arg1_type_pointed_to,r,0,
|
||||||
@ -351,7 +351,7 @@ U0 ICPostIncDec(CIntermediateCode *tmpi,I64 op,I64 rip)
|
|||||||
ICMov(tmpi,tmpi->res.type,tmpi->res.reg,tmpi->res.disp,
|
ICMov(tmpi,tmpi->res.type,tmpi->res.reg,tmpi->res.disp,
|
||||||
tmpi->arg1.type&MDG_MASK+tmpi->arg1_type_pointed_to,
|
tmpi->arg1.type&MDG_MASK+tmpi->arg1_type_pointed_to,
|
||||||
tmpi->arg1.reg,tmpi->arg1.disp,rip);
|
tmpi->arg1.reg,tmpi->arg1.disp,rip);
|
||||||
if (tmpc->ptr_stars_cnt && tmpc1->size!=1)
|
if (tmpc->ptr_stars_count && tmpc1->size!=1)
|
||||||
ICAddSubEctImm(tmpi,
|
ICAddSubEctImm(tmpi,
|
||||||
tmpi->arg1.type&MDG_MASK+tmpi->arg1_type_pointed_to,
|
tmpi->arg1.type&MDG_MASK+tmpi->arg1_type_pointed_to,
|
||||||
tmpi->arg1.reg,tmpi->arg1.disp,
|
tmpi->arg1.reg,tmpi->arg1.disp,
|
||||||
@ -373,7 +373,7 @@ U0 ICPostIncDec(CIntermediateCode *tmpi,I64 op,I64 rip)
|
|||||||
if (tmpi->res.type.mode)
|
if (tmpi->res.type.mode)
|
||||||
ICMov(tmpi,tmpi->res.type,tmpi->res.reg,tmpi->res.disp,
|
ICMov(tmpi,tmpi->res.type,tmpi->res.reg,tmpi->res.disp,
|
||||||
MDF_DISP+tmpi->arg1_type_pointed_to,r,0,rip);
|
MDF_DISP+tmpi->arg1_type_pointed_to,r,0,rip);
|
||||||
if (tmpc->ptr_stars_cnt && tmpc1->size!=1)
|
if (tmpc->ptr_stars_count && tmpc1->size!=1)
|
||||||
ICAddSubEctImm(tmpi,MDF_DISP+tmpi->arg1_type_pointed_to,r,0,
|
ICAddSubEctImm(tmpi,MDF_DISP+tmpi->arg1_type_pointed_to,r,0,
|
||||||
MDF_DISP+tmpi->arg1_type_pointed_to,r,0,tmpc1->size,op.u16[3],rip);
|
MDF_DISP+tmpi->arg1_type_pointed_to,r,0,tmpc1->size,op.u16[3],rip);
|
||||||
else
|
else
|
||||||
@ -595,7 +595,7 @@ U0 ICCompAndBranch(CIntermediateCode *tmpi,Bool has_res,I64 rip,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
rip+=tmpi->ic_cnt;
|
rip+=tmpi->ic_count;
|
||||||
lb=OptLabelFwd(tmpi->ic_data);
|
lb=OptLabelFwd(tmpi->ic_data);
|
||||||
short_jmp=ToBool(tmpi->ic_flags&ICF_SHORT_JMP);
|
short_jmp=ToBool(tmpi->ic_flags&ICF_SHORT_JMP);
|
||||||
if (!buf && lb->addr!=INVALID_PTR) {
|
if (!buf && lb->addr!=INVALID_PTR) {
|
||||||
@ -658,7 +658,7 @@ U0 ICTestAndBranch(CIntermediateCode *tmpi,I64 rip,I64 is,U8 *buf,I64 rip2)
|
|||||||
} else
|
} else
|
||||||
ICTest(tmpi,tmpi->arg1.reg);
|
ICTest(tmpi,tmpi->arg1.reg);
|
||||||
|
|
||||||
rip+=tmpi->ic_cnt;
|
rip+=tmpi->ic_count;
|
||||||
lb=OptLabelFwd(tmpi->ic_data);
|
lb=OptLabelFwd(tmpi->ic_data);
|
||||||
short_jmp=ToBool(tmpi->ic_flags&ICF_SHORT_JMP);
|
short_jmp=ToBool(tmpi->ic_flags&ICF_SHORT_JMP);
|
||||||
if (!buf && lb->addr!=INVALID_PTR) {
|
if (!buf && lb->addr!=INVALID_PTR) {
|
||||||
@ -691,7 +691,7 @@ U0 ICFlagBranch(CIntermediateCode *tmpi,I64 rip,I64 is,U8 *buf)
|
|||||||
Bool short_jmp;
|
Bool short_jmp;
|
||||||
CCodeMisc *lb;
|
CCodeMisc *lb;
|
||||||
|
|
||||||
rip+=tmpi->ic_cnt;
|
rip+=tmpi->ic_count;
|
||||||
lb=OptLabelFwd(tmpi->ic_data);
|
lb=OptLabelFwd(tmpi->ic_data);
|
||||||
short_jmp=ToBool(tmpi->ic_flags&ICF_SHORT_JMP);
|
short_jmp=ToBool(tmpi->ic_flags&ICF_SHORT_JMP);
|
||||||
if (!buf && lb->addr!=INVALID_PTR) {
|
if (!buf && lb->addr!=INVALID_PTR) {
|
||||||
|
@ -129,7 +129,7 @@ U0 ICAndBranch(CIntermediateCode *tmpi,I64 rip,I64 is,U8 *buf,I64 rip2)
|
|||||||
ICModr2(tmpi,i,,d1,rip2);
|
ICModr2(tmpi,i,,d1,rip2);
|
||||||
}
|
}
|
||||||
|
|
||||||
rip+=tmpi->ic_cnt;
|
rip+=tmpi->ic_count;
|
||||||
lb=OptLabelFwd(tmpi->ic_data);
|
lb=OptLabelFwd(tmpi->ic_data);
|
||||||
short_jmp=ToBool(tmpi->ic_flags&ICF_SHORT_JMP);
|
short_jmp=ToBool(tmpi->ic_flags&ICF_SHORT_JMP);
|
||||||
if (!buf && lb->addr!=INVALID_PTR) {
|
if (!buf && lb->addr!=INVALID_PTR) {
|
||||||
@ -310,7 +310,7 @@ U0 ICBrBitOps(CIntermediateCode *tmpi,I64 rip,
|
|||||||
ICModr2(tmpi,i,,arg2->disp,rip2);
|
ICModr2(tmpi,i,,arg2->disp,rip2);
|
||||||
}
|
}
|
||||||
|
|
||||||
rip+=tmpi->ic_cnt;
|
rip+=tmpi->ic_count;
|
||||||
lb=OptLabelFwd(tmpi->ic_data);
|
lb=OptLabelFwd(tmpi->ic_data);
|
||||||
short_jmp=ToBool(tmpi->ic_flags&ICF_SHORT_JMP);
|
short_jmp=ToBool(tmpi->ic_flags&ICF_SHORT_JMP);
|
||||||
if (!buf && lb->addr!=INVALID_PTR) {
|
if (!buf && lb->addr!=INVALID_PTR) {
|
||||||
@ -602,7 +602,7 @@ U0 ICXorEqu(CIntermediateCode *tmpi,I64 rip2)
|
|||||||
U0 ICSwitch(CIntermediateCode *tmpi,I64 rip,
|
U0 ICSwitch(CIntermediateCode *tmpi,I64 rip,
|
||||||
Bool nobound,CCompCtrl *cc,U8 *buf,I64 rip2)
|
Bool nobound,CCompCtrl *cc,U8 *buf,I64 rip2)
|
||||||
{
|
{
|
||||||
I64 i,j,cnt,min,max,begin,r;
|
I64 i,j,count,min,max,begin,r;
|
||||||
CCodeMisc *lb;
|
CCodeMisc *lb;
|
||||||
Bool short_jmp;
|
Bool short_jmp;
|
||||||
CAOTAbsAddr *tmpa;
|
CAOTAbsAddr *tmpa;
|
||||||
@ -645,7 +645,7 @@ U0 ICSwitch(CIntermediateCode *tmpi,I64 rip,
|
|||||||
ICU24(tmpi,i);
|
ICU24(tmpi,i);
|
||||||
}
|
}
|
||||||
|
|
||||||
rip+=tmpi->ic_cnt;
|
rip+=tmpi->ic_count;
|
||||||
lb=tmpi->ic_data(CCodeMisc *)->dft;
|
lb=tmpi->ic_data(CCodeMisc *)->dft;
|
||||||
short_jmp=ToBool(tmpi->ic_flags&ICF_SHORT_JMP);
|
short_jmp=ToBool(tmpi->ic_flags&ICF_SHORT_JMP);
|
||||||
if (!buf && lb->addr!=INVALID_PTR) {
|
if (!buf && lb->addr!=INVALID_PTR) {
|
||||||
@ -695,13 +695,13 @@ U0 ICSwitch(CIntermediateCode *tmpi,I64 rip,
|
|||||||
else
|
else
|
||||||
ICU8(tmpi,0x49);
|
ICU8(tmpi,0x49);
|
||||||
ICU24(tmpi,0x98BE0F+(r&7)<<16);
|
ICU24(tmpi,0x98BE0F+(r&7)<<16);
|
||||||
cnt=1;
|
count=1;
|
||||||
} else if (lb->flags&CMF_U8_JMP_TABLE) {
|
} else if (lb->flags&CMF_U8_JMP_TABLE) {
|
||||||
if (r<8)
|
if (r<8)
|
||||||
cnt=2;
|
count=2;
|
||||||
else {
|
else {
|
||||||
ICU8(tmpi,0x49);
|
ICU8(tmpi,0x49);
|
||||||
cnt=1;
|
count=1;
|
||||||
}
|
}
|
||||||
ICU24(tmpi,0x98B60F+(r&7)<<16);
|
ICU24(tmpi,0x98B60F+(r&7)<<16);
|
||||||
} else if (lb->flags&CMF_I16_JMP_TABLE) {
|
} else if (lb->flags&CMF_I16_JMP_TABLE) {
|
||||||
@ -710,21 +710,21 @@ U0 ICSwitch(CIntermediateCode *tmpi,I64 rip,
|
|||||||
else
|
else
|
||||||
ICU8(tmpi,0x4A);
|
ICU8(tmpi,0x4A);
|
||||||
ICU32(tmpi,0x451CBF0F+(r&7)<<27);
|
ICU32(tmpi,0x451CBF0F+(r&7)<<27);
|
||||||
cnt=0;
|
count=0;
|
||||||
} else if (lb->flags&CMF_U16_JMP_TABLE) {
|
} else if (lb->flags&CMF_U16_JMP_TABLE) {
|
||||||
if (r<8)
|
if (r<8)
|
||||||
cnt=1;
|
count=1;
|
||||||
else {
|
else {
|
||||||
ICU8(tmpi,0x4A);
|
ICU8(tmpi,0x4A);
|
||||||
cnt=0;
|
count=0;
|
||||||
}
|
}
|
||||||
ICU32(tmpi,0x451CB70F+(r&7)<<27);
|
ICU32(tmpi,0x451CB70F+(r&7)<<27);
|
||||||
} else {
|
} else {
|
||||||
if (r<8)
|
if (r<8)
|
||||||
cnt=2;
|
count=2;
|
||||||
else {
|
else {
|
||||||
ICU8(tmpi,0x42);
|
ICU8(tmpi,0x42);
|
||||||
cnt=1;
|
count=1;
|
||||||
}
|
}
|
||||||
ICU24(tmpi,0x851C8B+(r&7)<<19);
|
ICU24(tmpi,0x851C8B+(r&7)<<19);
|
||||||
}
|
}
|
||||||
@ -733,7 +733,7 @@ U0 ICSwitch(CIntermediateCode *tmpi,I64 rip,
|
|||||||
tmpa->next=cc->aotc->abss;
|
tmpa->next=cc->aotc->abss;
|
||||||
tmpa->type=AAT_ADD_U32;
|
tmpa->type=AAT_ADD_U32;
|
||||||
cc->aotc->abss=tmpa;
|
cc->aotc->abss=tmpa;
|
||||||
tmpa->rip=rip2+tmpi->ic_cnt;
|
tmpa->rip=rip2+tmpi->ic_count;
|
||||||
ICU32(tmpi,lb->addr+cc->aotc->rip);
|
ICU32(tmpi,lb->addr+cc->aotc->rip);
|
||||||
} else
|
} else
|
||||||
ICU32(tmpi,lb->addr+buf);
|
ICU32(tmpi,lb->addr+buf);
|
||||||
@ -746,14 +746,14 @@ U0 ICSwitch(CIntermediateCode *tmpi,I64 rip,
|
|||||||
tmpa->next=cc->aotc->abss;
|
tmpa->next=cc->aotc->abss;
|
||||||
tmpa->type=AAT_ADD_U32;
|
tmpa->type=AAT_ADD_U32;
|
||||||
cc->aotc->abss=tmpa;
|
cc->aotc->abss=tmpa;
|
||||||
tmpa->rip=rip2+tmpi->ic_cnt;
|
tmpa->rip=rip2+tmpi->ic_count;
|
||||||
ICU32(tmpi,begin+cc->aotc->rip);
|
ICU32(tmpi,begin+cc->aotc->rip);
|
||||||
} else
|
} else
|
||||||
ICU32(tmpi,begin+buf);
|
ICU32(tmpi,begin+buf);
|
||||||
} else
|
} else
|
||||||
cnt+=6;
|
count+=6;
|
||||||
ICU16(tmpi,0xE3FF); //JMP EBX
|
ICU16(tmpi,0xE3FF); //JMP EBX
|
||||||
for (i=0;i<cnt;i++) //Code must always shrink, not expand
|
for (i=0;i<count;i++) //Code must always shrink, not expand
|
||||||
ICU8(tmpi,OC_NOP);
|
ICU8(tmpi,OC_NOP);
|
||||||
tmpi->ic_flags&=~ICF_CODE_FINAL;
|
tmpi->ic_flags&=~ICF_CODE_FINAL;
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ U0 CompNoteFloatOp(CCompCtrl *cc,CIntermediateCode *tmpi,
|
|||||||
case CN_INST:
|
case CN_INST:
|
||||||
if (cc->last_float_op_ic!=tmpi) {
|
if (cc->last_float_op_ic!=tmpi) {
|
||||||
if (cc->dont_push_float) {
|
if (cc->dont_push_float) {
|
||||||
if (intermediate_code_table[tmpi->ic_code].arg_cnt==IS_2_ARG &&
|
if (intermediate_code_table[tmpi->ic_code].arg_count==IS_2_ARG &&
|
||||||
cc->last_float_op_ic->res.reg!=REG_R8)
|
cc->last_float_op_ic->res.reg!=REG_R8)
|
||||||
tmpi->ic_flags|=ICF_ALT_TEMPLATE;
|
tmpi->ic_flags|=ICF_ALT_TEMPLATE;
|
||||||
else
|
else
|
||||||
@ -29,7 +29,7 @@ U0 CompNoteFloatOp(CCompCtrl *cc,CIntermediateCode *tmpi,
|
|||||||
link=TRUE;
|
link=TRUE;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (intermediate_code_table[tmpi->ic_code].arg_cnt==IS_2_ARG &&
|
if (intermediate_code_table[tmpi->ic_code].arg_count==IS_2_ARG &&
|
||||||
cc->last_float_op_pos!=CN_A1)
|
cc->last_float_op_pos!=CN_A1)
|
||||||
tmpi->ic_flags|=ICF_ALT_TEMPLATE;
|
tmpi->ic_flags|=ICF_ALT_TEMPLATE;
|
||||||
else
|
else
|
||||||
@ -114,10 +114,10 @@ U0 ICCopyTemplate(CCompCtrl *cc,CIntermediateCode *tmpi,I64 op,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
MemCpy(&tmpi->ic_body[tmpi->ic_cnt],ptr,i);
|
MemCpy(&tmpi->ic_body[tmpi->ic_count],ptr,i);
|
||||||
if (!off_the_record)
|
if (!off_the_record)
|
||||||
CompNoteFloatOp(cc,tmpi,dont_pushable,dont_popable,pos);
|
CompNoteFloatOp(cc,tmpi,dont_pushable,dont_popable,pos);
|
||||||
tmpi->ic_cnt+=i;
|
tmpi->ic_count+=i;
|
||||||
}
|
}
|
||||||
|
|
||||||
U0 ICFCvt(CCompCtrl *cc,CIntermediateCode *tmpi,I64 r1,
|
U0 ICFCvt(CCompCtrl *cc,CIntermediateCode *tmpi,I64 r1,
|
||||||
@ -288,18 +288,18 @@ U0 ICFPow(CCompCtrl *cc,CIntermediateCode *tmpi,U8 *buf,I64 rip)
|
|||||||
if (buf) {
|
if (buf) {
|
||||||
tmpie=CAlloc(sizeof(CAOTImportExport));
|
tmpie=CAlloc(sizeof(CAOTImportExport));
|
||||||
tmpie->type=IET_IMM_I64;
|
tmpie->type=IET_IMM_I64;
|
||||||
tmpie->rip=rip+tmpi->ic_cnt-8;
|
tmpie->rip=rip+tmpi->ic_count-8;
|
||||||
tmpie->next=tmpex->ie_lst;
|
tmpie->next=tmpex->ie_lst;
|
||||||
tmpex->ie_lst=tmpie;
|
tmpex->ie_lst=tmpie;
|
||||||
}
|
}
|
||||||
ICU16(tmpi,0xD3FF);
|
ICU16(tmpi,0xD3FF);
|
||||||
} else {
|
} else {
|
||||||
ICU8(tmpi,0xE8);
|
ICU8(tmpi,0xE8);
|
||||||
ICU32(tmpi,-(rip+tmpi->ic_cnt+4));
|
ICU32(tmpi,-(rip+tmpi->ic_count+4));
|
||||||
if (buf) {
|
if (buf) {
|
||||||
tmpie=CAlloc(sizeof(CAOTImportExport));
|
tmpie=CAlloc(sizeof(CAOTImportExport));
|
||||||
tmpie->type=IET_REL_I32;
|
tmpie->type=IET_REL_I32;
|
||||||
tmpie->rip=rip+tmpi->ic_cnt-4;
|
tmpie->rip=rip+tmpi->ic_count-4;
|
||||||
tmpie->next=tmpex->ie_lst;
|
tmpie->next=tmpex->ie_lst;
|
||||||
tmpex->ie_lst=tmpie;
|
tmpex->ie_lst=tmpie;
|
||||||
}
|
}
|
||||||
@ -308,7 +308,7 @@ U0 ICFPow(CCompCtrl *cc,CIntermediateCode *tmpi,U8 *buf,I64 rip)
|
|||||||
if (tmpex->type&HTF_UNRESOLVED)
|
if (tmpex->type&HTF_UNRESOLVED)
|
||||||
throw('Compiler');
|
throw('Compiler');
|
||||||
else {
|
else {
|
||||||
i=tmpex->val-(rip+tmpi->ic_cnt+5);
|
i=tmpex->val-(rip+tmpi->ic_count+5);
|
||||||
if (!(I32_MIN<=i<=I32_MAX)) {
|
if (!(I32_MIN<=i<=I32_MAX)) {
|
||||||
throw('Compiler');
|
throw('Compiler');
|
||||||
// ICU16(tmpi,0xBB48);
|
// ICU16(tmpi,0xBB48);
|
||||||
@ -321,7 +321,7 @@ U0 ICFPow(CCompCtrl *cc,CIntermediateCode *tmpi,U8 *buf,I64 rip)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
i=tmpex->val-(rip+tmpi->ic_cnt+5);
|
i=tmpex->val-(rip+tmpi->ic_count+5);
|
||||||
if (!(I32_MIN<=i<=I32_MAX)) {
|
if (!(I32_MIN<=i<=I32_MAX)) {
|
||||||
ICU16(tmpi,0xBB48);
|
ICU16(tmpi,0xBB48);
|
||||||
ICU64(tmpi,tmpex->val);
|
ICU64(tmpi,tmpex->val);
|
||||||
|
@ -446,7 +446,7 @@ U0 ICFCmpAndBranch(CCompCtrl *cc,CIntermediateCode *tmpi,I64 rip,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
rip+=tmpi->ic_cnt;
|
rip+=tmpi->ic_count;
|
||||||
lb=OptLabelFwd(tmpi->ic_data);
|
lb=OptLabelFwd(tmpi->ic_data);
|
||||||
short_jmp=ToBool(tmpi->ic_flags&ICF_SHORT_JMP);
|
short_jmp=ToBool(tmpi->ic_flags&ICF_SHORT_JMP);
|
||||||
if (!buf && lb->addr!=INVALID_PTR) {
|
if (!buf && lb->addr!=INVALID_PTR) {
|
||||||
|
@ -16,44 +16,44 @@ sign or zero extended to 64-bits.
|
|||||||
|
|
||||||
U0 ICU8(CIntermediateCode *tmpi,U8 b)
|
U0 ICU8(CIntermediateCode *tmpi,U8 b)
|
||||||
{
|
{
|
||||||
tmpi->ic_body[tmpi->ic_cnt++]=b;
|
tmpi->ic_body[tmpi->ic_count++]=b;
|
||||||
}
|
}
|
||||||
|
|
||||||
U0 ICRex(CIntermediateCode *tmpi,U8 b)
|
U0 ICRex(CIntermediateCode *tmpi,U8 b)
|
||||||
{
|
{
|
||||||
if (b)
|
if (b)
|
||||||
tmpi->ic_body[tmpi->ic_cnt++]=b;
|
tmpi->ic_body[tmpi->ic_count++]=b;
|
||||||
}
|
}
|
||||||
|
|
||||||
U0 ICOpSizeRex(CIntermediateCode *tmpi,U8 b)
|
U0 ICOpSizeRex(CIntermediateCode *tmpi,U8 b)
|
||||||
{
|
{
|
||||||
tmpi->ic_body[tmpi->ic_cnt++]=OC_OP_SIZE_PREFIX;
|
tmpi->ic_body[tmpi->ic_count++]=OC_OP_SIZE_PREFIX;
|
||||||
if (b)
|
if (b)
|
||||||
tmpi->ic_body[tmpi->ic_cnt++]=b;
|
tmpi->ic_body[tmpi->ic_count++]=b;
|
||||||
}
|
}
|
||||||
|
|
||||||
U0 ICU16(CIntermediateCode *tmpi,U16 w)
|
U0 ICU16(CIntermediateCode *tmpi,U16 w)
|
||||||
{
|
{
|
||||||
*(&tmpi->ic_body[tmpi->ic_cnt])(U16)=w;
|
*(&tmpi->ic_body[tmpi->ic_count])(U16)=w;
|
||||||
tmpi->ic_cnt+=2;
|
tmpi->ic_count+=2;
|
||||||
}
|
}
|
||||||
|
|
||||||
U0 ICU24(CIntermediateCode *tmpi,U32 d)
|
U0 ICU24(CIntermediateCode *tmpi,U32 d)
|
||||||
{//Writes extra harmless overhanging byte.
|
{//Writes extra harmless overhanging byte.
|
||||||
*(&tmpi->ic_body[tmpi->ic_cnt])(U32)=d;
|
*(&tmpi->ic_body[tmpi->ic_count])(U32)=d;
|
||||||
tmpi->ic_cnt+=3;
|
tmpi->ic_count+=3;
|
||||||
}
|
}
|
||||||
|
|
||||||
U0 ICU32(CIntermediateCode *tmpi,U32 d)
|
U0 ICU32(CIntermediateCode *tmpi,U32 d)
|
||||||
{
|
{
|
||||||
*(&tmpi->ic_body[tmpi->ic_cnt])(U32)=d;
|
*(&tmpi->ic_body[tmpi->ic_count])(U32)=d;
|
||||||
tmpi->ic_cnt+=4;
|
tmpi->ic_count+=4;
|
||||||
}
|
}
|
||||||
|
|
||||||
U0 ICU64(CIntermediateCode *tmpi,U64 q)
|
U0 ICU64(CIntermediateCode *tmpi,U64 q)
|
||||||
{
|
{
|
||||||
*(&tmpi->ic_body[tmpi->ic_cnt])(U64)=q;
|
*(&tmpi->ic_body[tmpi->ic_count])(U64)=q;
|
||||||
tmpi->ic_cnt+=8;
|
tmpi->ic_count+=8;
|
||||||
}
|
}
|
||||||
|
|
||||||
U0 ICAddRSP(CIntermediateCode *tmpi,I64 i,Bool optimize=TRUE)
|
U0 ICAddRSP(CIntermediateCode *tmpi,I64 i,Bool optimize=TRUE)
|
||||||
@ -62,11 +62,11 @@ U0 ICAddRSP(CIntermediateCode *tmpi,I64 i,Bool optimize=TRUE)
|
|||||||
CIntermediateCode *tmpil1;
|
CIntermediateCode *tmpil1;
|
||||||
if (optimize) {
|
if (optimize) {
|
||||||
tmpil1=tmpi;
|
tmpil1=tmpi;
|
||||||
if (tmpi->ic_last_start<0 && !tmpi->ic_cnt &&
|
if (tmpi->ic_last_start<0 && !tmpi->ic_count &&
|
||||||
(tmpil1=OptLag1(tmpi)) && tmpil1->ic_last_start<0)
|
(tmpil1=OptLag1(tmpi)) && tmpil1->ic_last_start<0)
|
||||||
tmpil1=NULL;
|
tmpil1=NULL;
|
||||||
if (tmpil1) {
|
if (tmpil1) {
|
||||||
j=tmpil1->ic_cnt;
|
j=tmpil1->ic_count;
|
||||||
if (tmpil1->ic_last_start==j-4 && tmpil1->ic_body[j-3]==0x83 &&
|
if (tmpil1->ic_last_start==j-4 && tmpil1->ic_body[j-3]==0x83 &&
|
||||||
tmpil1->ic_body[j-4]==0x48) {
|
tmpil1->ic_body[j-4]==0x48) {
|
||||||
if (tmpil1->ic_body[j-2]==0xEC)
|
if (tmpil1->ic_body[j-2]==0xEC)
|
||||||
@ -87,7 +87,7 @@ U0 ICAddRSP(CIntermediateCode *tmpi,I64 i,Bool optimize=TRUE)
|
|||||||
j=0;
|
j=0;
|
||||||
if (j) {
|
if (j) {
|
||||||
if (tmpi==tmpil1) {
|
if (tmpi==tmpil1) {
|
||||||
tmpi->ic_cnt=tmpi->ic_last_start;
|
tmpi->ic_count=tmpi->ic_last_start;
|
||||||
i+=j;
|
i+=j;
|
||||||
} else if (!(tmpi->ic_flags&ICF_PREV_DELETED)) {
|
} else if (!(tmpi->ic_flags&ICF_PREV_DELETED)) {
|
||||||
tmpil1->ic_flags|=ICF_DEL_PREV_INS;
|
tmpil1->ic_flags|=ICF_DEL_PREV_INS;
|
||||||
@ -97,7 +97,7 @@ U0 ICAddRSP(CIntermediateCode *tmpi,I64 i,Bool optimize=TRUE)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
last_start=tmpi->ic_cnt;
|
last_start=tmpi->ic_count;
|
||||||
if (i>0) {
|
if (i>0) {
|
||||||
if (i<=I8_MAX)
|
if (i<=I8_MAX)
|
||||||
ICU32(tmpi,0xC48348+i<<24);
|
ICU32(tmpi,0xC48348+i<<24);
|
||||||
@ -116,7 +116,7 @@ U0 ICAddRSP(CIntermediateCode *tmpi,I64 i,Bool optimize=TRUE)
|
|||||||
} else
|
} else
|
||||||
throw('Compiler');
|
throw('Compiler');
|
||||||
}
|
}
|
||||||
if (optimize && tmpi->ic_cnt>last_start)
|
if (optimize && tmpi->ic_count>last_start)
|
||||||
tmpi->ic_last_start=last_start;
|
tmpi->ic_last_start=last_start;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -249,7 +249,7 @@ U0 ICModr2(CIntermediateCode *tmpi,I64 i,CICType t=0,I64 d,I64 rip=0)
|
|||||||
d-=4;
|
d-=4;
|
||||||
}
|
}
|
||||||
case MODR_RIP_REL:
|
case MODR_RIP_REL:
|
||||||
ICU32(tmpi,d-(rip+4+tmpi->ic_cnt));
|
ICU32(tmpi,d-(rip+4+tmpi->ic_count));
|
||||||
tmpi->ic_flags&=~ICF_CODE_FINAL;
|
tmpi->ic_flags&=~ICF_CODE_FINAL;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -445,8 +445,8 @@ I64 ICBuiltInFloatConst(F64 d)
|
|||||||
U0 ICMov(CIntermediateCode *tmpi,
|
U0 ICMov(CIntermediateCode *tmpi,
|
||||||
CICType t1,I64 r1,I64 d1,CICType t2,I64 r2,I64 d2,I64 rip)
|
CICType t1,I64 r1,I64 d1,CICType t2,I64 r2,I64 d2,I64 rip)
|
||||||
{
|
{
|
||||||
I64 i,cnt1,cnt2,b1_rex,b2_rex,b1,b2,b1_modr,b2_modr,
|
I64 i,count1,count2,b1_rex,b2_rex,b1,b2,b1_modr,b2_modr,
|
||||||
b1_r1,b1_r2,b2_r1,b2_r2,last_start=tmpi->ic_cnt;
|
b1_r1,b1_r2,b2_r1,b2_r2,last_start=tmpi->ic_count;
|
||||||
CIntermediateCode *tmpil1;
|
CIntermediateCode *tmpil1;
|
||||||
Bool old_lock=Btr(&tmpi->ic_flags,ICf_LOCK);
|
Bool old_lock=Btr(&tmpi->ic_flags,ICf_LOCK);
|
||||||
switch (Bsr(t1)) {
|
switch (Bsr(t1)) {
|
||||||
@ -582,21 +582,21 @@ move_done:
|
|||||||
tmpil1=NULL;
|
tmpil1=NULL;
|
||||||
if (tmpil1) {
|
if (tmpil1) {
|
||||||
if (tmpil1==tmpi)
|
if (tmpil1==tmpi)
|
||||||
cnt1=last_start-tmpil1->ic_last_start;
|
count1=last_start-tmpil1->ic_last_start;
|
||||||
else {
|
else {
|
||||||
if (!(tmpil1->ic_flags&ICF_CODE_FINAL))
|
if (!(tmpil1->ic_flags&ICF_CODE_FINAL))
|
||||||
tmpi->ic_flags&=~ICF_CODE_FINAL;
|
tmpi->ic_flags&=~ICF_CODE_FINAL;
|
||||||
if (last_start)
|
if (last_start)
|
||||||
cnt1=0;
|
count1=0;
|
||||||
else
|
else
|
||||||
cnt1=tmpil1->ic_cnt-tmpil1->ic_last_start;
|
count1=tmpil1->ic_count-tmpil1->ic_last_start;
|
||||||
}
|
}
|
||||||
cnt2=tmpi->ic_cnt-last_start;
|
count2=tmpi->ic_count-last_start;
|
||||||
if (cnt1 && cnt1==cnt2) {
|
if (count1 && count1==count2) {
|
||||||
b1_rex=tmpil1->ic_body[tmpil1->ic_last_start];
|
b1_rex=tmpil1->ic_body[tmpil1->ic_last_start];
|
||||||
b2_rex=tmpi->ic_body[last_start];
|
b2_rex=tmpi->ic_body[last_start];
|
||||||
if (b1_rex&0x48==0x48 && b2_rex&0x48==0x48) {
|
if (b1_rex&0x48==0x48 && b2_rex&0x48==0x48) {
|
||||||
for (i=1;i<cnt1;i++)
|
for (i=1;i<count1;i++)
|
||||||
if ((b1=tmpil1->ic_body[tmpil1->ic_last_start+i])==
|
if ((b1=tmpil1->ic_body[tmpil1->ic_last_start+i])==
|
||||||
(b2=tmpi->ic_body[last_start+i])) {
|
(b2=tmpi->ic_body[last_start+i])) {
|
||||||
if (i==1 && (b2==0x89 || b2==0x8B)) {
|
if (i==1 && (b2==0x89 || b2==0x8B)) {
|
||||||
@ -606,7 +606,7 @@ move_done:
|
|||||||
b2_modr=tmpi->ic_body[last_start+2];
|
b2_modr=tmpi->ic_body[last_start+2];
|
||||||
b2_r1=b2_modr&7 +Bt(&b2_rex,0)<<3;
|
b2_r1=b2_modr&7 +Bt(&b2_rex,0)<<3;
|
||||||
b2_r2=b2_modr>>3&7+Bt(&b2_rex,2)<<3;
|
b2_r2=b2_modr>>3&7+Bt(&b2_rex,2)<<3;
|
||||||
if (cnt1==3 && b2_modr&0xC0==0xC0) {
|
if (count1==3 && b2_modr&0xC0==0xC0) {
|
||||||
if (b2_r1==b2_r2)
|
if (b2_r1==b2_r2)
|
||||||
goto move_redundant;
|
goto move_redundant;
|
||||||
if (b1_modr&0xC0==0xC0) {
|
if (b1_modr&0xC0==0xC0) {
|
||||||
@ -628,7 +628,7 @@ move_done:
|
|||||||
b2_modr=tmpi->ic_body[last_start+2];
|
b2_modr=tmpi->ic_body[last_start+2];
|
||||||
b2_r1=b2_modr&7 +Bt(&b2_rex,0)<<3;
|
b2_r1=b2_modr&7 +Bt(&b2_rex,0)<<3;
|
||||||
b2_r2=b2_modr>>3&7+Bt(&b2_rex,2)<<3;
|
b2_r2=b2_modr>>3&7+Bt(&b2_rex,2)<<3;
|
||||||
if (cnt1==3 && b2_modr&0xC0==0xC0) {
|
if (count1==3 && b2_modr&0xC0==0xC0) {
|
||||||
if (b2_r1==b2_r2)
|
if (b2_r1==b2_r2)
|
||||||
goto move_redundant;
|
goto move_redundant;
|
||||||
if (b1==0x89 && b2==0x8B || b1==0x8B && b2==0x89) {
|
if (b1==0x89 && b2==0x8B || b1==0x8B && b2==0x89) {
|
||||||
@ -645,15 +645,15 @@ move_done:
|
|||||||
!(b1==0x89 && b2==0x8B || b1==0x8B && b2==0x89))
|
!(b1==0x89 && b2==0x8B || b1==0x8B && b2==0x89))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (i==cnt1) {
|
if (i==count1) {
|
||||||
move_redundant:
|
move_redundant:
|
||||||
tmpi->ic_cnt=last_start;
|
tmpi->ic_count=last_start;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (tmpi->ic_cnt>last_start>tmpi->ic_last_start)
|
if (tmpi->ic_count>last_start>tmpi->ic_last_start)
|
||||||
tmpi->ic_last_start=last_start;
|
tmpi->ic_last_start=last_start;
|
||||||
BEqu(&tmpi->ic_flags,ICf_LOCK,old_lock);
|
BEqu(&tmpi->ic_flags,ICf_LOCK,old_lock);
|
||||||
}
|
}
|
||||||
@ -679,7 +679,7 @@ U0 ICLea(CIntermediateCode *tmpi,CICType t1,I64 r1,I64 d1,
|
|||||||
tmpa->next=cc->aotc->abss;
|
tmpa->next=cc->aotc->abss;
|
||||||
tmpa->type=AAT_ADD_U32;
|
tmpa->type=AAT_ADD_U32;
|
||||||
cc->aotc->abss=tmpa;
|
cc->aotc->abss=tmpa;
|
||||||
tmpa->rip=rip+tmpi->ic_cnt-4;
|
tmpa->rip=rip+tmpi->ic_count-4;
|
||||||
}
|
}
|
||||||
tmpi->ic_flags&=~ICF_CODE_FINAL;
|
tmpi->ic_flags&=~ICF_CODE_FINAL;
|
||||||
break;
|
break;
|
||||||
|
@ -75,7 +75,7 @@ U0 LexWarn(CCompCtrl *cc,U8 *str=NULL)
|
|||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
LexPutPos(cc);
|
LexPutPos(cc);
|
||||||
cc->warning_cnt++;
|
cc->warning_count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
U0 LexExcept(CCompCtrl *cc,U8 *str=NULL)
|
U0 LexExcept(CCompCtrl *cc,U8 *str=NULL)
|
||||||
@ -88,7 +88,7 @@ U0 LexExcept(CCompCtrl *cc,U8 *str=NULL)
|
|||||||
if (!IsRaw)
|
if (!IsRaw)
|
||||||
ZenithErr("Task:%08X %s\n",Fs,str);
|
ZenithErr("Task:%08X %s\n",Fs,str);
|
||||||
LexPutPos(cc);
|
LexPutPos(cc);
|
||||||
cc->error_cnt++;
|
cc->error_count++;
|
||||||
FlushMessages;
|
FlushMessages;
|
||||||
if (!Bt(&sys_run_level,RLf_ZENITH_SERVER))
|
if (!Bt(&sys_run_level,RLf_ZENITH_SERVER))
|
||||||
Debug("Type \"Fix;\"");
|
Debug("Type \"Fix;\"");
|
||||||
@ -104,7 +104,7 @@ U0 UndefinedExtern()
|
|||||||
U0 UnusedExternWarning(CCompCtrl *cc,CHashClass *tmpc)
|
U0 UnusedExternWarning(CCompCtrl *cc,CHashClass *tmpc)
|
||||||
{
|
{
|
||||||
PrintWarn("Unused extern '%s'\n",tmpc->str);
|
PrintWarn("Unused extern '%s'\n",tmpc->str);
|
||||||
cc->warning_cnt++;
|
cc->warning_count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
U0 ParenWarning(CCompCtrl *cc)
|
U0 ParenWarning(CCompCtrl *cc)
|
||||||
@ -118,15 +118,15 @@ U0 ICClassPut(CHashClass *c)
|
|||||||
{
|
{
|
||||||
I64 i;
|
I64 i;
|
||||||
if (!c) return;
|
if (!c) return;
|
||||||
if (c->ptr_stars_cnt>4) {
|
if (c->ptr_stars_count>4) {
|
||||||
PrintErr("put_class ptrcnt=%d\n",c->ptr_stars_cnt);
|
PrintErr("put_class ptrcount=%d\n",c->ptr_stars_count);
|
||||||
while (TRUE)
|
while (TRUE)
|
||||||
//TODO:
|
//TODO:
|
||||||
Yield;
|
Yield;
|
||||||
}
|
}
|
||||||
for (i=0;i<c->ptr_stars_cnt;i++)
|
for (i=0;i<c->ptr_stars_count;i++)
|
||||||
'*';
|
'*';
|
||||||
c-=c->ptr_stars_cnt;
|
c-=c->ptr_stars_count;
|
||||||
if (c->str)
|
if (c->str)
|
||||||
"%s",c->str;
|
"%s",c->str;
|
||||||
else {
|
else {
|
||||||
|
@ -26,7 +26,7 @@ extern CHashClass *ParseClass(
|
|||||||
extern CHashFun *ParseFunJoin(
|
extern CHashFun *ParseFunJoin(
|
||||||
CCompCtrl *cc,CHashClass *tmp_return,U8 *name,I64 fsp_flags);
|
CCompCtrl *cc,CHashClass *tmp_return,U8 *name,I64 fsp_flags);
|
||||||
extern I64 ParseKeyWord(CCompCtrl *cc);
|
extern I64 ParseKeyWord(CCompCtrl *cc);
|
||||||
extern Bool ParseStatement(CCompCtrl *cc,I64 try_cnt=0,
|
extern Bool ParseStatement(CCompCtrl *cc,I64 try_count=0,
|
||||||
CCodeMisc *lb_break=NULL,I64 cmp_flags=CMPF_PRS_SEMICOLON);
|
CCodeMisc *lb_break=NULL,I64 cmp_flags=CMPF_PRS_SEMICOLON);
|
||||||
extern U0 ParseStreamBlk(CCompCtrl *cc);
|
extern U0 ParseStreamBlk(CCompCtrl *cc);
|
||||||
extern CHashClass *ParseType(CCompCtrl *cc,CHashClass **_tmpc1,
|
extern CHashClass *ParseType(CCompCtrl *cc,CHashClass **_tmpc1,
|
||||||
|
@ -59,7 +59,7 @@ I64 HashEntrySize2(CHashSrcSym *tmph)
|
|||||||
res+=MSize2(tmph(CHashGlobalVar *)->data_addr);
|
res+=MSize2(tmph(CHashGlobalVar *)->data_addr);
|
||||||
if (tmph(CHashGlobalVar *)->fun_ptr)
|
if (tmph(CHashGlobalVar *)->fun_ptr)
|
||||||
res+=HashEntrySize2(tmph(CHashGlobalVar *)->fun_ptr
|
res+=HashEntrySize2(tmph(CHashGlobalVar *)->fun_ptr
|
||||||
-tmph(CHashGlobalVar *)->fun_ptr->ptr_stars_cnt);
|
-tmph(CHashGlobalVar *)->fun_ptr->ptr_stars_count);
|
||||||
}
|
}
|
||||||
} else if (tmph->type & HTT_FILE)
|
} else if (tmph->type & HTT_FILE)
|
||||||
res+=MSize2(tmph(CHashGeneric *)->user_data0);
|
res+=MSize2(tmph(CHashGeneric *)->user_data0);
|
||||||
@ -118,7 +118,7 @@ U0 MapFileWrite(CHashTable *h,U8 *map_name,U8 drv_let)
|
|||||||
tmpb->data=MAlloc(size);
|
tmpb->data=MAlloc(size);
|
||||||
MemCpy(tmpb->data,dbg_info,size);
|
MemCpy(tmpb->data,dbg_info,size);
|
||||||
tmpb->num=doc->cur_bin_num++;
|
tmpb->num=doc->cur_bin_num++;
|
||||||
tmpb->use_cnt=1;
|
tmpb->use_count=1;
|
||||||
QueueInsert(tmpb,doc->bin_head.last);
|
QueueInsert(tmpb,doc->bin_head.last);
|
||||||
} else
|
} else
|
||||||
dbg_info=NULL;
|
dbg_info=NULL;
|
||||||
|
@ -102,8 +102,8 @@ CAOT *CompJoin(CCompCtrl *cc,I64 cmp_flags,U8 *map_name=NULL,U8 mapfile_drv_let=
|
|||||||
okay=FALSE;
|
okay=FALSE;
|
||||||
}
|
}
|
||||||
if (!okay) {
|
if (!okay) {
|
||||||
if (cc->error_cnt<1)
|
if (cc->error_count<1)
|
||||||
cc->error_cnt=1;
|
cc->error_count=1;
|
||||||
cc->aot=res->parent_aot;
|
cc->aot=res->parent_aot;
|
||||||
Free(res);
|
Free(res);
|
||||||
LinkedLstDel(aotc->bin);
|
LinkedLstDel(aotc->bin);
|
||||||
@ -155,7 +155,7 @@ CAOT *CompJoin(CCompCtrl *cc,I64 cmp_flags,U8 *map_name=NULL,U8 mapfile_drv_let=
|
|||||||
}
|
}
|
||||||
|
|
||||||
CAOT *CompBuf(U8 *buf,U8 *map_name=NULL,
|
CAOT *CompBuf(U8 *buf,U8 *map_name=NULL,
|
||||||
I64 *error_cnt=NULL, I64 *warning_cnt=NULL,U8 mapfile_drv_let=0)
|
I64 *error_count=NULL, I64 *warning_count=NULL,U8 mapfile_drv_let=0)
|
||||||
{
|
{
|
||||||
CCompCtrl *cc;
|
CCompCtrl *cc;
|
||||||
CAOT *res=NULL;
|
CAOT *res=NULL;
|
||||||
@ -163,8 +163,8 @@ CAOT *CompBuf(U8 *buf,U8 *map_name=NULL,
|
|||||||
cc->flags|=CCF_AOT_COMPILE;
|
cc->flags|=CCF_AOT_COMPILE;
|
||||||
QueueInsert(cc,Fs->last_cc);
|
QueueInsert(cc,Fs->last_cc);
|
||||||
res=CompJoin(cc,CMPF_LEX_FIRST,map_name,mapfile_drv_let);
|
res=CompJoin(cc,CMPF_LEX_FIRST,map_name,mapfile_drv_let);
|
||||||
if (error_cnt) *error_cnt=cc->error_cnt;
|
if (error_count) *error_count=cc->error_count;
|
||||||
if (warning_cnt) *warning_cnt=cc->warning_cnt;
|
if (warning_count) *warning_count=cc->warning_count;
|
||||||
QueueRemove(cc);
|
QueueRemove(cc);
|
||||||
if (res)
|
if (res)
|
||||||
CompCtrlDel(cc);
|
CompCtrlDel(cc);
|
||||||
@ -228,7 +228,7 @@ U0 CompFixUpJITAsm(CCompCtrl *cc,CAOT *tmpaot)
|
|||||||
if(!(g_lb=COCGoToLabelFind(cc,str)))
|
if(!(g_lb=COCGoToLabelFind(cc,str)))
|
||||||
"Unresolved Reference:%s\n",str;
|
"Unresolved Reference:%s\n",str;
|
||||||
else {
|
else {
|
||||||
g_lb->use_cnt++;
|
g_lb->use_count++;
|
||||||
g_lb=OptLabelFwd(g_lb);
|
g_lb=OptLabelFwd(g_lb);
|
||||||
i=g_lb->addr+tmpaot->buf;
|
i=g_lb->addr+tmpaot->buf;
|
||||||
}
|
}
|
||||||
@ -338,7 +338,7 @@ U0 CompFixUpAOTAsm(CCompCtrl *cc,CAOT *tmpaot)
|
|||||||
if(!(g_lb=COCGoToLabelFind(cc,tmpie->str)))
|
if(!(g_lb=COCGoToLabelFind(cc,tmpie->str)))
|
||||||
"Unresolved Reference:%s\n",tmpie->str;
|
"Unresolved Reference:%s\n",tmpie->str;
|
||||||
else {
|
else {
|
||||||
g_lb->use_cnt++;
|
g_lb->use_count++;
|
||||||
g_lb=OptLabelFwd(g_lb);
|
g_lb=OptLabelFwd(g_lb);
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
@ -417,11 +417,11 @@ U0 CompFixUpAOTAsm(CCompCtrl *cc,CAOT *tmpaot)
|
|||||||
}
|
}
|
||||||
|
|
||||||
I64 Comp(U8 *filename,U8 *map_name=NULL,U8 *out_name=NULL,U8 mapfile_drv_let=0)
|
I64 Comp(U8 *filename,U8 *map_name=NULL,U8 *out_name=NULL,U8 mapfile_drv_let=0)
|
||||||
{//AOT Compile HC or PRJ file a and output BIN file. Returns err_cnt.
|
{//AOT Compile HC or PRJ file a and output BIN file. Returns err_count.
|
||||||
U8 *ptr,*fbuf=NULL,*fbuf2=NULL,*fbuf3=NULL,
|
U8 *ptr,*fbuf=NULL,*fbuf2=NULL,*fbuf3=NULL,
|
||||||
*patch_table=MAlloc(0x20000);
|
*patch_table=MAlloc(0x20000);
|
||||||
CAOT *tmpaot;
|
CAOT *tmpaot;
|
||||||
I64 i,cnt,size=0,error_cnt=0,warning_cnt=0,aot_U8s=0;
|
I64 i,count,size=0,error_count=0,warning_count=0,aot_U8s=0;
|
||||||
CBinFile *bfh;
|
CBinFile *bfh;
|
||||||
CAOTImportExport *tmpie,*tmpie1;
|
CAOTImportExport *tmpie,*tmpie1;
|
||||||
CAOTAbsAddr *tmpa,*tmpa1;
|
CAOTAbsAddr *tmpa,*tmpa1;
|
||||||
@ -433,20 +433,20 @@ I64 Comp(U8 *filename,U8 *map_name=NULL,U8 *out_name=NULL,U8 mapfile_drv_let=0)
|
|||||||
if (map_name)
|
if (map_name)
|
||||||
fbuf3=ExtDft(map_name,"MAP");
|
fbuf3=ExtDft(map_name,"MAP");
|
||||||
|
|
||||||
if (tmpaot=CompBuf(fbuf2,fbuf3,&error_cnt,&warning_cnt,mapfile_drv_let)) {
|
if (tmpaot=CompBuf(fbuf2,fbuf3,&error_count,&warning_count,mapfile_drv_let)) {
|
||||||
aot_U8s=tmpaot->aot_U8s;
|
aot_U8s=tmpaot->aot_U8s;
|
||||||
ptr=patch_table;
|
ptr=patch_table;
|
||||||
//See $LK,"Load",A="MN:Load"$()
|
//See $LK,"Load",A="MN:Load"$()
|
||||||
cnt=0;
|
count=0;
|
||||||
tmpa=tmpaot->abss;
|
tmpa=tmpaot->abss;
|
||||||
while (tmpa) {
|
while (tmpa) {
|
||||||
if (!(tmpa->type&IEF_IMM_NOT_REL))
|
if (!(tmpa->type&IEF_IMM_NOT_REL))
|
||||||
cnt++;
|
count++;
|
||||||
tmpa=tmpa->next;
|
tmpa=tmpa->next;
|
||||||
}
|
}
|
||||||
if (cnt) {
|
if (count) {
|
||||||
*ptr++=IET_ABS_ADDR;
|
*ptr++=IET_ABS_ADDR;
|
||||||
*ptr(U32 *)++=cnt;
|
*ptr(U32 *)++=count;
|
||||||
*ptr++=0;
|
*ptr++=0;
|
||||||
tmpa=tmpaot->abss;
|
tmpa=tmpaot->abss;
|
||||||
while (tmpa) {
|
while (tmpa) {
|
||||||
@ -460,15 +460,15 @@ I64 Comp(U8 *filename,U8 *map_name=NULL,U8 *out_name=NULL,U8 mapfile_drv_let=0)
|
|||||||
tmphg=tmpaot->heap_glbls;
|
tmphg=tmpaot->heap_glbls;
|
||||||
while (tmphg) {
|
while (tmphg) {
|
||||||
tmphg1=tmphg->next;
|
tmphg1=tmphg->next;
|
||||||
cnt=0;
|
count=0;
|
||||||
tmphgr=tmphg->references;
|
tmphgr=tmphg->references;
|
||||||
while (tmphgr) {
|
while (tmphgr) {
|
||||||
cnt++;
|
count++;
|
||||||
tmphgr=tmphgr->next;
|
tmphgr=tmphgr->next;
|
||||||
}
|
}
|
||||||
if (cnt) {
|
if (count) {
|
||||||
*ptr++=IET_DATA_HEAP;
|
*ptr++=IET_DATA_HEAP;
|
||||||
*ptr(U32 *)++=cnt;
|
*ptr(U32 *)++=count;
|
||||||
if (tmphg->str) {
|
if (tmphg->str) {
|
||||||
i=StrLen(tmphg->str);
|
i=StrLen(tmphg->str);
|
||||||
MemCpy(ptr,tmphg->str,i+1);
|
MemCpy(ptr,tmphg->str,i+1);
|
||||||
@ -564,8 +564,8 @@ I64 Comp(U8 *filename,U8 *map_name=NULL,U8 *out_name=NULL,U8 mapfile_drv_let=0)
|
|||||||
Free(fbuf2);
|
Free(fbuf2);
|
||||||
Free(fbuf3);
|
Free(fbuf3);
|
||||||
Print("Errs:%d Warns:%d Code:%X Size:%X\n",
|
Print("Errs:%d Warns:%d Code:%X Size:%X\n",
|
||||||
error_cnt,warning_cnt,aot_U8s,size);
|
error_count,warning_count,aot_U8s,size);
|
||||||
return error_cnt;
|
return error_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
I64 ExePutS(U8 *buf,U8 *filename=NULL,
|
I64 ExePutS(U8 *buf,U8 *filename=NULL,
|
||||||
|
Binary file not shown.
File diff suppressed because one or more lines are too long
@ -3,7 +3,7 @@
|
|||||||
#define IS_0_ARG 0
|
#define IS_0_ARG 0
|
||||||
#define IS_1_ARG 1
|
#define IS_1_ARG 1
|
||||||
#define IS_2_ARG 2
|
#define IS_2_ARG 2
|
||||||
#define IS_V_ARG 3 //Variable Arg Cnt
|
#define IS_V_ARG 3 //Variable Arg Count
|
||||||
|
|
||||||
#define IST_NULL 0
|
#define IST_NULL 0
|
||||||
#define IST_DEREF 1
|
#define IST_DEREF 1
|
||||||
@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
class CIntermediateStruct
|
class CIntermediateStruct
|
||||||
{
|
{
|
||||||
U8 arg_cnt,res_cnt,type;
|
U8 arg_count,res_count,type;
|
||||||
Bool fpop,not_const,pad[3];
|
Bool fpop,not_const,pad[3];
|
||||||
U8 *name;
|
U8 *name;
|
||||||
};
|
};
|
||||||
|
@ -67,10 +67,10 @@ extern I64 Comp(U8 *filename,
|
|||||||
U8 *map_name=NULL,U8 *out_name=NULL,U8 mapfile_drv_let=0);
|
U8 *map_name=NULL,U8 *out_name=NULL,U8 mapfile_drv_let=0);
|
||||||
|
|
||||||
#help_index "Debugging/Unassemble"
|
#help_index "Debugging/Unassemble"
|
||||||
public extern U8 *U(U8 *rip,I64 cnt=20,I64 seg_size=64);
|
public extern U8 *U(U8 *rip,I64 count=20,I64 seg_size=64);
|
||||||
public extern U0 Ui(U8 *buf,U8 **_rip,I64 seg_size=64,
|
public extern U0 Ui(U8 *buf,U8 **_rip,I64 seg_size=64,
|
||||||
I64 *_jmp_dst=NULL,Bool just_ins=FALSE);
|
I64 *_jmp_dst=NULL,Bool just_ins=FALSE);
|
||||||
public extern I64 Un(U8 *rip,I64 cnt=0x80,I64 seg_size=64);
|
public extern I64 Un(U8 *rip,I64 count=0x80,I64 seg_size=64);
|
||||||
extern CUAsmGlobals uasm;
|
extern CUAsmGlobals uasm;
|
||||||
|
|
||||||
#help_index "Hash/System"
|
#help_index "Hash/System"
|
||||||
|
@ -97,7 +97,7 @@ Bool LexDollar(CCompCtrl *cc,CDoc *doc,CDocEntry *doc_e)
|
|||||||
Free(cc->dollar_buf);
|
Free(cc->dollar_buf);
|
||||||
st=Doc2PlainText(doc,doc_e);
|
st=Doc2PlainText(doc,doc_e);
|
||||||
cc->dollar_buf=MStrPrint("$$%$$Q$$",st);
|
cc->dollar_buf=MStrPrint("$$%$$Q$$",st);
|
||||||
cc->dollar_cnt=2;
|
cc->dollar_count=2;
|
||||||
Free(st);
|
Free(st);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
} else
|
} else
|
||||||
@ -425,10 +425,10 @@ I64 LexInStr(CCompCtrl *cc,U8 *buf,I64 size,Bool *done)
|
|||||||
}
|
}
|
||||||
} else if (ch=='$$') {
|
} else if (ch=='$$') {
|
||||||
buf[i++]='$$';
|
buf[i++]='$$';
|
||||||
if (cc->dollar_cnt)
|
if (cc->dollar_count)
|
||||||
cc->dollar_cnt--;
|
cc->dollar_count--;
|
||||||
else if (LexGetChar(cc)!='$$') {
|
else if (LexGetChar(cc)!='$$') {
|
||||||
cc->dollar_cnt=1;
|
cc->dollar_count=1;
|
||||||
cc->flags|=CCF_USE_LAST_U16;
|
cc->flags|=CCF_USE_LAST_U16;
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
@ -799,7 +799,7 @@ lex_float_start:
|
|||||||
MemCpy(buf2,buf,j);
|
MemCpy(buf2,buf,j);
|
||||||
}
|
}
|
||||||
tmph(CHashDefineStr *)->data=buf2;
|
tmph(CHashDefineStr *)->data=buf2;
|
||||||
tmph(CHashDefineStr *)->cnt=-1;
|
tmph(CHashDefineStr *)->count=-1;
|
||||||
HashAdd(tmph,cc->htc.define_hash_table);
|
HashAdd(tmph,cc->htc.define_hash_table);
|
||||||
}
|
}
|
||||||
cc->flags&=~CCF_NO_DEFINES;
|
cc->flags&=~CCF_NO_DEFINES;
|
||||||
|
@ -72,7 +72,7 @@ CMemberLst *MemberFind(U8 *needle_str,CHashClass *haystack_class)
|
|||||||
tmpm=haystack_class->member_lst_and_root;
|
tmpm=haystack_class->member_lst_and_root;
|
||||||
while (tmpm) {
|
while (tmpm) {
|
||||||
if (!(i=StrCmp(tmpm->str,needle_str))) {
|
if (!(i=StrCmp(tmpm->str,needle_str))) {
|
||||||
tmpm->use_cnt++;
|
tmpm->use_count++;
|
||||||
return tmpm;
|
return tmpm;
|
||||||
}
|
}
|
||||||
if (i<=0)
|
if (i<=0)
|
||||||
@ -119,7 +119,7 @@ U0 MemberAdd(CCompCtrl *cc,CMemberLst *tmpm,CHashClass *tmpc,I64 mode)
|
|||||||
|
|
||||||
if (mode==PRS1B_LOCAL_VAR) {
|
if (mode==PRS1B_LOCAL_VAR) {
|
||||||
tmpm->member_class_base=
|
tmpm->member_class_base=
|
||||||
tmpm->member_class-tmpm->member_class->ptr_stars_cnt;
|
tmpm->member_class-tmpm->member_class->ptr_stars_count;
|
||||||
if (Bt(&cc->opts,OPTf_WARN_DUP_TYPES) &&
|
if (Bt(&cc->opts,OPTf_WARN_DUP_TYPES) &&
|
||||||
MemberClassBaseFind(tmpm->member_class_base,tmpc))
|
MemberClassBaseFind(tmpm->member_class_base,tmpc))
|
||||||
LexWarn(cc,"Duplicate type at ");
|
LexWarn(cc,"Duplicate type at ");
|
||||||
@ -154,9 +154,9 @@ CMemberLst *MemberLstNew(I64 _reg)
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
Bool MemberLstCmp(CMemberLst *tmpm1,CMemberLst *tmpm2,I64 cnt=I64_MAX)
|
Bool MemberLstCmp(CMemberLst *tmpm1,CMemberLst *tmpm2,I64 count=I64_MAX)
|
||||||
{
|
{
|
||||||
while (tmpm1 && tmpm2 && cnt--) {
|
while (tmpm1 && tmpm2 && count--) {
|
||||||
if (StrCmp(tmpm1->str,tmpm2->str) ||
|
if (StrCmp(tmpm1->str,tmpm2->str) ||
|
||||||
tmpm1->member_class!=tmpm2->member_class ||
|
tmpm1->member_class!=tmpm2->member_class ||
|
||||||
tmpm1->member_class_base!=tmpm2->member_class_base)
|
tmpm1->member_class_base!=tmpm2->member_class_base)
|
||||||
@ -174,7 +174,7 @@ Bool MemberLstCmp(CMemberLst *tmpm1,CMemberLst *tmpm2,I64 cnt=I64_MAX)
|
|||||||
tmpm1=tmpm1->next;
|
tmpm1=tmpm1->next;
|
||||||
tmpm2=tmpm2->next;
|
tmpm2=tmpm2->next;
|
||||||
}
|
}
|
||||||
if (cnt<0 || !tmpm1 && !tmpm2)
|
if (count<0 || !tmpm1 && !tmpm2)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
else
|
else
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -191,7 +191,7 @@ U0 MemberLstDel(CMemberLst *tmpm)
|
|||||||
if (tmpm->flags & MLF_STR_DFT_AVAILABLE)
|
if (tmpm->flags & MLF_STR_DFT_AVAILABLE)
|
||||||
Free(tmpm->dft_val);
|
Free(tmpm->dft_val);
|
||||||
if (tmpm->flags & MLF_FUN)
|
if (tmpm->flags & MLF_FUN)
|
||||||
HashDel(tmpm->fun_ptr-tmpm->fun_ptr->ptr_stars_cnt);
|
HashDel(tmpm->fun_ptr-tmpm->fun_ptr->ptr_stars_count);
|
||||||
tmp_meta=tmpm->meta;
|
tmp_meta=tmpm->meta;
|
||||||
while (tmp_meta) {
|
while (tmp_meta) {
|
||||||
tmp_meta1=tmp_meta->next;
|
tmp_meta1=tmp_meta->next;
|
||||||
@ -213,9 +213,9 @@ U0 ClassMemberLstDel(CHashClass *tmpc)
|
|||||||
tmpc->last_in_member_lst=&tmpc->member_lst_and_root;
|
tmpc->last_in_member_lst=&tmpc->member_lst_and_root;
|
||||||
tmpc->member_lst_and_root=NULL;
|
tmpc->member_lst_and_root=NULL;
|
||||||
tmpc->member_class_base_root=NULL;
|
tmpc->member_class_base_root=NULL;
|
||||||
tmpc->member_cnt=0;
|
tmpc->member_count=0;
|
||||||
if (tmpc->type&HTT_FUN)
|
if (tmpc->type&HTT_FUN)
|
||||||
tmpc(CHashFun *)->arg_cnt=0;
|
tmpc(CHashFun *)->arg_count=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
I64 MemberLstSize(CHashClass *tmpc)
|
I64 MemberLstSize(CHashClass *tmpc)
|
||||||
@ -230,7 +230,7 @@ I64 MemberLstSize(CHashClass *tmpc)
|
|||||||
if (tmpm->flags & MLF_STR_DFT_AVAILABLE)
|
if (tmpm->flags & MLF_STR_DFT_AVAILABLE)
|
||||||
res+=MSize2(tmpm->dft_val);
|
res+=MSize2(tmpm->dft_val);
|
||||||
if (tmpm->flags & MLF_FUN)
|
if (tmpm->flags & MLF_FUN)
|
||||||
res+=HashEntrySize2(tmpm->fun_ptr-tmpm->fun_ptr->ptr_stars_cnt);
|
res+=HashEntrySize2(tmpm->fun_ptr-tmpm->fun_ptr->ptr_stars_count);
|
||||||
tmp_meta=tmpm->meta;
|
tmp_meta=tmpm->meta;
|
||||||
while (tmp_meta) {
|
while (tmp_meta) {
|
||||||
res+=MSize2(tmp_meta->str);
|
res+=MSize2(tmp_meta->str);
|
||||||
|
@ -488,7 +488,7 @@ U0 OptFixSizeOf(CIntermediateCode *tmpi1,
|
|||||||
tmpi1->t.arg2_tree->ic_code=IC_IMM_I64;
|
tmpi1->t.arg2_tree->ic_code=IC_IMM_I64;
|
||||||
tmpi1->t.arg2_tree->ic_class=tmpcc;
|
tmpi1->t.arg2_tree->ic_class=tmpcc;
|
||||||
tmpi_push->ic_class=tmpcc;
|
tmpi_push->ic_class=tmpcc;
|
||||||
if (tmpcc->ptr_stars_cnt) {
|
if (tmpcc->ptr_stars_count) {
|
||||||
tmpcc--;
|
tmpcc--;
|
||||||
if (tmpcc->size==1)
|
if (tmpcc->size==1)
|
||||||
goto here;
|
goto here;
|
||||||
@ -517,7 +517,7 @@ I64 CompRawType(CHashClass *tmpc)
|
|||||||
I64 CompRawTypePointed(CHashClass *tmpc)
|
I64 CompRawTypePointed(CHashClass *tmpc)
|
||||||
{
|
{
|
||||||
if (tmpc) {
|
if (tmpc) {
|
||||||
if (tmpc->ptr_stars_cnt)
|
if (tmpc->ptr_stars_count)
|
||||||
tmpc--;
|
tmpc--;
|
||||||
tmpc=OptClassFwd(tmpc);
|
tmpc=OptClassFwd(tmpc);
|
||||||
return tmpc->raw_type;
|
return tmpc->raw_type;
|
||||||
|
@ -45,7 +45,7 @@ args.
|
|||||||
tmpi_push=tmpi;
|
tmpi_push=tmpi;
|
||||||
MemSet(&tmpi->arg1,0,3*sizeof(CICArg));
|
MemSet(&tmpi->arg1,0,3*sizeof(CICArg));
|
||||||
tmpi->arg1_type_pointed_to=0;
|
tmpi->arg1_type_pointed_to=0;
|
||||||
switch [intermediate_code_table[code].arg_cnt] {
|
switch [intermediate_code_table[code].arg_count] {
|
||||||
case IS_V_ARG:
|
case IS_V_ARG:
|
||||||
ps->ptr-=tmpi->ic_data>>2;
|
ps->ptr-=tmpi->ic_data>>2;
|
||||||
break;
|
break;
|
||||||
@ -96,7 +96,7 @@ args.
|
|||||||
OptSetNOP1(tmpi);
|
OptSetNOP1(tmpi);
|
||||||
} else {
|
} else {
|
||||||
if (tmpi->ic_data) {//was paren
|
if (tmpi->ic_data) {//was paren
|
||||||
if (!tmpi_push->ic_class->ptr_stars_cnt) {
|
if (!tmpi_push->ic_class->ptr_stars_count) {
|
||||||
if (tmpi_push->ic_class->raw_type==RT_F64)
|
if (tmpi_push->ic_class->raw_type==RT_F64)
|
||||||
tmpi_push->ic_class2=cmp.internal_types[RT_F64];
|
tmpi_push->ic_class2=cmp.internal_types[RT_F64];
|
||||||
else
|
else
|
||||||
@ -265,7 +265,7 @@ args.
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
end:
|
end:
|
||||||
if (!tmpi_push->ic_class->ptr_stars_cnt) {
|
if (!tmpi_push->ic_class->ptr_stars_count) {
|
||||||
if (tmpi_push->ic_class->raw_type==RT_F64)
|
if (tmpi_push->ic_class->raw_type==RT_F64)
|
||||||
tmpi_push->ic_class2=cmp.internal_types[RT_F64];
|
tmpi_push->ic_class2=cmp.internal_types[RT_F64];
|
||||||
else
|
else
|
||||||
@ -712,7 +712,7 @@ args.
|
|||||||
tmpi->ic_class=cmp.internal_types[RT_I64];
|
tmpi->ic_class=cmp.internal_types[RT_I64];
|
||||||
break;
|
break;
|
||||||
end:
|
end:
|
||||||
if (!tmpi_push->ic_class->ptr_stars_cnt) {
|
if (!tmpi_push->ic_class->ptr_stars_count) {
|
||||||
if (tmpi_push->ic_class->raw_type==RT_F64)
|
if (tmpi_push->ic_class->raw_type==RT_F64)
|
||||||
tmpi_push->ic_class2=cmp.internal_types[RT_F64];
|
tmpi_push->ic_class2=cmp.internal_types[RT_F64];
|
||||||
else if (is_unsigned)
|
else if (is_unsigned)
|
||||||
@ -808,7 +808,7 @@ args.
|
|||||||
break;
|
break;
|
||||||
end:
|
end:
|
||||||
tmpi->ic_flags&=~ICF_RES_TO_INT;
|
tmpi->ic_flags&=~ICF_RES_TO_INT;
|
||||||
if (!tmpi_push->ic_class->ptr_stars_cnt) {
|
if (!tmpi_push->ic_class->ptr_stars_count) {
|
||||||
if (tmpi_push->ic_class->raw_type==RT_F64)
|
if (tmpi_push->ic_class->raw_type==RT_F64)
|
||||||
tmpi_push->ic_class2=cmp.internal_types[RT_F64];
|
tmpi_push->ic_class2=cmp.internal_types[RT_F64];
|
||||||
else if (is_unsigned)
|
else if (is_unsigned)
|
||||||
@ -1256,7 +1256,7 @@ args.
|
|||||||
ICPut(cc,tmpi);
|
ICPut(cc,tmpi);
|
||||||
LexExcept(cc,"Compiler Optimization Error at ");
|
LexExcept(cc,"Compiler Optimization Error at ");
|
||||||
}
|
}
|
||||||
if (intermediate_code_table[code].arg_cnt==IS_2_ARG) {
|
if (intermediate_code_table[code].arg_count==IS_2_ARG) {
|
||||||
if (tmpi_push->ic_precedence&~ASSOC_MASK==PREC_ASSIGN)
|
if (tmpi_push->ic_precedence&~ASSOC_MASK==PREC_ASSIGN)
|
||||||
OptFixSizeOf(tmpi2,tmpi_push,tmpi1->ic_class-1);
|
OptFixSizeOf(tmpi2,tmpi_push,tmpi1->ic_class-1);
|
||||||
else {
|
else {
|
||||||
@ -1264,7 +1264,7 @@ args.
|
|||||||
OptFixSizeOf(tmpi2,tmpi_push,tmpi1->ic_class);
|
OptFixSizeOf(tmpi2,tmpi_push,tmpi1->ic_class);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (intermediate_code_table[tmpi_push->ic_code].res_cnt) {
|
if (intermediate_code_table[tmpi_push->ic_code].res_count) {
|
||||||
ParsePush(ps,tmpi->ic_class2);
|
ParsePush(ps,tmpi->ic_class2);
|
||||||
ParsePush(ps,tmpi_push);
|
ParsePush(ps,tmpi_push);
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ U0 OptPass3(CCompCtrl *cc,COptReg *reg_offsets)
|
|||||||
CCodeMisc *lb;
|
CCodeMisc *lb;
|
||||||
CIntermediateCode *tmpi,*tmpi1,*tmpi2,*tmpi_next,
|
CIntermediateCode *tmpi,*tmpi1,*tmpi2,*tmpi_next,
|
||||||
*tmpil1,*tmpil2;
|
*tmpil1,*tmpil2;
|
||||||
I64 code,i,j,l,member_cnt,used_reg_mask=0;
|
I64 code,i,j,l,member_count,used_reg_mask=0;
|
||||||
CMemberLst *tmpm;
|
CMemberLst *tmpm;
|
||||||
COptMemberVar *mv=NULL;
|
COptMemberVar *mv=NULL;
|
||||||
CAOT *tmpaot;
|
CAOT *tmpaot;
|
||||||
@ -18,11 +18,11 @@ U0 OptPass3(CCompCtrl *cc,COptReg *reg_offsets)
|
|||||||
reg_offsets[i].m=NULL;
|
reg_offsets[i].m=NULL;
|
||||||
}
|
}
|
||||||
if (cc->htc.fun) {
|
if (cc->htc.fun) {
|
||||||
member_cnt=cc->htc.fun->member_cnt;
|
member_count=cc->htc.fun->member_count;
|
||||||
if (Bt(&cc->htc.fun->flags,Ff_DOT_DOT_DOT))
|
if (Bt(&cc->htc.fun->flags,Ff_DOT_DOT_DOT))
|
||||||
member_cnt+=2;
|
member_count+=2;
|
||||||
mv=CAlloc(member_cnt*sizeof(COptMemberVar));
|
mv=CAlloc(member_count*sizeof(COptMemberVar));
|
||||||
member_cnt=0;
|
member_count=0;
|
||||||
tmpm=cc->htc.fun->member_lst_and_root;
|
tmpm=cc->htc.fun->member_lst_and_root;
|
||||||
while (tmpm) {
|
while (tmpm) {
|
||||||
tmpc=OptClassFwd(tmpm->member_class);
|
tmpc=OptClassFwd(tmpm->member_class);
|
||||||
@ -36,10 +36,10 @@ U0 OptPass3(CCompCtrl *cc,COptReg *reg_offsets)
|
|||||||
} else if (tmpc->raw_type!=RT_F64 && tmpm->reg!=REG_NONE ||
|
} else if (tmpc->raw_type!=RT_F64 && tmpm->reg!=REG_NONE ||
|
||||||
tmpm->reg==REG_ALLOC) {
|
tmpm->reg==REG_ALLOC) {
|
||||||
if (tmpm->reg==REG_ALLOC)
|
if (tmpm->reg==REG_ALLOC)
|
||||||
mv[member_cnt].score=I64_MAX/2; //big but not too big
|
mv[member_count].score=I64_MAX/2; //big but not too big
|
||||||
mv[member_cnt].offset_start=tmpm->offset;
|
mv[member_count].offset_start=tmpm->offset;
|
||||||
mv[member_cnt].offset_end=tmpm->offset+MaxI64(1,tmpm->size);
|
mv[member_count].offset_end=tmpm->offset+MaxI64(1,tmpm->size);
|
||||||
mv[member_cnt++].m=tmpm;
|
mv[member_count++].m=tmpm;
|
||||||
} else if (tmpm->reg==REG_ALLOC)
|
} else if (tmpm->reg==REG_ALLOC)
|
||||||
PrintWarn("Can't reg var\n $$LK,\"FL:%s,%d\"$$'%s' in '%s'\n",
|
PrintWarn("Can't reg var\n $$LK,\"FL:%s,%d\"$$'%s' in '%s'\n",
|
||||||
cc->lex_include_stk->full_name,
|
cc->lex_include_stk->full_name,
|
||||||
@ -47,7 +47,7 @@ U0 OptPass3(CCompCtrl *cc,COptReg *reg_offsets)
|
|||||||
tmpm=tmpm->next;
|
tmpm=tmpm->next;
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
member_cnt=0;
|
member_count=0;
|
||||||
|
|
||||||
tmpi=cc->coc.coc_head.next;
|
tmpi=cc->coc.coc_head.next;
|
||||||
while (code=tmpi->ic_code) {
|
while (code=tmpi->ic_code) {
|
||||||
@ -61,7 +61,7 @@ U0 OptPass3(CCompCtrl *cc,COptReg *reg_offsets)
|
|||||||
} else
|
} else
|
||||||
tmpil1=tmpil2=&cmp.ic_nop;
|
tmpil1=tmpil2=&cmp.ic_nop;
|
||||||
tmpc=tmpi->ic_class;
|
tmpc=tmpi->ic_class;
|
||||||
switch [intermediate_code_table[code].arg_cnt] {
|
switch [intermediate_code_table[code].arg_count] {
|
||||||
case IS_V_ARG:
|
case IS_V_ARG:
|
||||||
ps->ptr-=tmpi->ic_data>>3;
|
ps->ptr-=tmpi->ic_data>>3;
|
||||||
break;
|
break;
|
||||||
@ -90,7 +90,7 @@ U0 OptPass3(CCompCtrl *cc,COptReg *reg_offsets)
|
|||||||
case IS_0_ARG: //nobound switch
|
case IS_0_ARG: //nobound switch
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (intermediate_code_table[code].res_cnt) {
|
if (intermediate_code_table[code].res_count) {
|
||||||
tmpi->res.type=MDF_STK+CompRawType(tmpc);
|
tmpi->res.type=MDF_STK+CompRawType(tmpc);
|
||||||
tmpi->ic_flags|=ICF_RES_WAS_STK;
|
tmpi->ic_flags|=ICF_RES_WAS_STK;
|
||||||
ParsePush(ps,tmpi);
|
ParsePush(ps,tmpi);
|
||||||
@ -127,7 +127,7 @@ U0 OptPass3(CCompCtrl *cc,COptReg *reg_offsets)
|
|||||||
tmpi->ic_code=IC_MOV;
|
tmpi->ic_code=IC_MOV;
|
||||||
OptFree(tmpi1);
|
OptFree(tmpi1);
|
||||||
if (tmpi->arg1.reg==REG_RBP)
|
if (tmpi->arg1.reg==REG_RBP)
|
||||||
for (i=0;i<member_cnt;i++)
|
for (i=0;i<member_count;i++)
|
||||||
if (mv[i].offset_start==tmpi->arg1.disp) {
|
if (mv[i].offset_start==tmpi->arg1.disp) {
|
||||||
mv[i].lea_balance--;
|
mv[i].lea_balance--;
|
||||||
mv[i].score++;
|
mv[i].score++;
|
||||||
@ -155,7 +155,7 @@ U0 OptPass3(CCompCtrl *cc,COptReg *reg_offsets)
|
|||||||
case IC_DEREF_MM:
|
case IC_DEREF_MM:
|
||||||
if (tmpi1->ic_code==IC_LEA && tmpi1->arg1.type&MDF_DISP &&
|
if (tmpi1->ic_code==IC_LEA && tmpi1->arg1.type&MDF_DISP &&
|
||||||
tmpi1->arg1.reg==REG_RBP)
|
tmpi1->arg1.reg==REG_RBP)
|
||||||
for (i=0;i<member_cnt;i++)
|
for (i=0;i<member_count;i++)
|
||||||
if (mv[i].offset_start==tmpi1->arg1.disp) {
|
if (mv[i].offset_start==tmpi1->arg1.disp) {
|
||||||
mv[i].lea_balance--;
|
mv[i].lea_balance--;
|
||||||
mv[i].score++;
|
mv[i].score++;
|
||||||
@ -190,7 +190,7 @@ U0 OptPass3(CCompCtrl *cc,COptReg *reg_offsets)
|
|||||||
tmpi->arg1.reg=REG_RBP;
|
tmpi->arg1.reg=REG_RBP;
|
||||||
tmpi->arg1.type=MDF_DISP+tmpi->arg1.type.raw_type;
|
tmpi->arg1.type=MDF_DISP+tmpi->arg1.type.raw_type;
|
||||||
tmpi->arg1.disp=tmpi->ic_data;
|
tmpi->arg1.disp=tmpi->ic_data;
|
||||||
for (i=0;i<member_cnt;i++)
|
for (i=0;i<member_count;i++)
|
||||||
if (mv[i].offset_start<=tmpi->ic_data<mv[i].offset_end) {
|
if (mv[i].offset_start<=tmpi->ic_data<mv[i].offset_end) {
|
||||||
mv[i].lea_balance++;
|
mv[i].lea_balance++;
|
||||||
mv[i].score++;
|
mv[i].score++;
|
||||||
@ -237,7 +237,7 @@ U0 OptPass3(CCompCtrl *cc,COptReg *reg_offsets)
|
|||||||
case IC_XOR_EQU:
|
case IC_XOR_EQU:
|
||||||
if (tmpi1->ic_code==IC_LEA && tmpi1->arg1.type&MDF_DISP &&
|
if (tmpi1->ic_code==IC_LEA && tmpi1->arg1.type&MDF_DISP &&
|
||||||
tmpi1->arg1.reg==REG_RBP)
|
tmpi1->arg1.reg==REG_RBP)
|
||||||
for (i=0;i<member_cnt;i++)
|
for (i=0;i<member_count;i++)
|
||||||
if (mv[i].offset_start==tmpi1->arg1.disp) {
|
if (mv[i].offset_start==tmpi1->arg1.disp) {
|
||||||
mv[i].lea_balance--;
|
mv[i].lea_balance--;
|
||||||
mv[i].score++;
|
mv[i].score++;
|
||||||
@ -269,7 +269,7 @@ U0 OptPass3(CCompCtrl *cc,COptReg *reg_offsets)
|
|||||||
case IC_NOBOUND_SWITCH:
|
case IC_NOBOUND_SWITCH:
|
||||||
case IC_SWITCH:
|
case IC_SWITCH:
|
||||||
lb=OptLabelFwd(tmpi->ic_data(CCodeMisc *)->dft);
|
lb=OptLabelFwd(tmpi->ic_data(CCodeMisc *)->dft);
|
||||||
lb->use_cnt++;
|
lb->use_count++;
|
||||||
break;
|
break;
|
||||||
case IC_ASM:
|
case IC_ASM:
|
||||||
tmpaot=tmpi->ic_data;
|
tmpaot=tmpi->ic_data;
|
||||||
@ -278,7 +278,7 @@ U0 OptPass3(CCompCtrl *cc,COptReg *reg_offsets)
|
|||||||
if (IET_REL_I0<=tmpie->type<=IET_IMM_I64 &&
|
if (IET_REL_I0<=tmpie->type<=IET_IMM_I64 &&
|
||||||
tmpie->str && tmpie->flags&IEF_GOTO_LABEL &&
|
tmpie->str && tmpie->flags&IEF_GOTO_LABEL &&
|
||||||
(lb=COCGoToLabelFind(cc,tmpie->str)))
|
(lb=COCGoToLabelFind(cc,tmpie->str)))
|
||||||
lb->use_cnt++; //Prevent deadcode elimination.
|
lb->use_count++; //Prevent deadcode elimination.
|
||||||
tmpie=tmpie->next;
|
tmpie=tmpie->next;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -361,7 +361,7 @@ U0 OptPass3(CCompCtrl *cc,COptReg *reg_offsets)
|
|||||||
case IC_BR_MM_NOT_ZERO:
|
case IC_BR_MM_NOT_ZERO:
|
||||||
if (tmpi1->ic_code==IC_LEA && tmpi1->arg1.type&MDF_DISP &&
|
if (tmpi1->ic_code==IC_LEA && tmpi1->arg1.type&MDF_DISP &&
|
||||||
tmpi1->arg1.reg==REG_RBP)
|
tmpi1->arg1.reg==REG_RBP)
|
||||||
for (i=0;i<member_cnt;i++)
|
for (i=0;i<member_count;i++)
|
||||||
if (mv[i].offset_start==tmpi1->arg1.disp) {
|
if (mv[i].offset_start==tmpi1->arg1.disp) {
|
||||||
mv[i].lea_balance--;
|
mv[i].lea_balance--;
|
||||||
mv[i].score++;
|
mv[i].score++;
|
||||||
@ -394,7 +394,7 @@ here1:
|
|||||||
lb=tmpi->ic_data;
|
lb=tmpi->ic_data;
|
||||||
else
|
else
|
||||||
lb=OptLabelFwd(tmpi->ic_data);
|
lb=OptLabelFwd(tmpi->ic_data);
|
||||||
lb->use_cnt++;
|
lb->use_count++;
|
||||||
break;
|
break;
|
||||||
case IC_NOP1:
|
case IC_NOP1:
|
||||||
tmpi=OptFree(tmpi);
|
tmpi=OptFree(tmpi);
|
||||||
@ -535,11 +535,11 @@ R12 and R13 as non-pointer register variables, such as index variables i,j,k.
|
|||||||
~(REGG_LOCAL_VARS|REGG_LOCAL_NON_PTR_VARS)|used_reg_mask;
|
~(REGG_LOCAL_VARS|REGG_LOCAL_NON_PTR_VARS)|used_reg_mask;
|
||||||
if (!Bt(&cc->opts,OPTf_NO_REG_VAR) &&
|
if (!Bt(&cc->opts,OPTf_NO_REG_VAR) &&
|
||||||
!(cc->flags & CCF_NO_REG_OPT)) {
|
!(cc->flags & CCF_NO_REG_OPT)) {
|
||||||
QSort(mv,member_cnt,sizeof(COptMemberVar),&OptMVCompare);
|
QSort(mv,member_count,sizeof(COptMemberVar),&OptMVCompare);
|
||||||
while (member_cnt && !mv[member_cnt-1].score)
|
while (member_count && !mv[member_count-1].score)
|
||||||
member_cnt--;
|
member_count--;
|
||||||
j=0;
|
j=0;
|
||||||
for (i=0;i<member_cnt;i++) {
|
for (i=0;i<member_count;i++) {
|
||||||
if (!mv[i].lea_balance && mv[i].offset_start) {//addr operator cancels
|
if (!mv[i].lea_balance && mv[i].offset_start) {//addr operator cancels
|
||||||
mv[j].m=mv[i].m;
|
mv[j].m=mv[i].m;
|
||||||
mv[j].offset_start=mv[i].offset_start;
|
mv[j].offset_start=mv[i].offset_start;
|
||||||
@ -559,7 +559,7 @@ R12 and R13 as non-pointer register variables, such as index variables i,j,k.
|
|||||||
for (i=0;i<j && l<cmp.num_non_ptr_vars;i++) {
|
for (i=0;i<j && l<cmp.num_non_ptr_vars;i++) {
|
||||||
tmpm=mv[i].m;
|
tmpm=mv[i].m;
|
||||||
tmpc=OptClassFwd(tmpm->member_class);
|
tmpc=OptClassFwd(tmpm->member_class);
|
||||||
if (!tmpc->ptr_stars_cnt && !tmpm->dim.next) {
|
if (!tmpc->ptr_stars_count && !tmpm->dim.next) {
|
||||||
while (l<cmp.num_non_ptr_vars &&
|
while (l<cmp.num_non_ptr_vars &&
|
||||||
Bts(&cc->htc.fun->used_reg_mask,cmp.non_ptr_vars_map[l]))
|
Bts(&cc->htc.fun->used_reg_mask,cmp.non_ptr_vars_map[l]))
|
||||||
l++;
|
l++;
|
||||||
|
@ -151,8 +151,8 @@ U0 OptPass4(CCompCtrl *cc,COptReg *reg_offsets,I64 *_type)
|
|||||||
if (dead_code&&code!=IC_LABEL) {
|
if (dead_code&&code!=IC_LABEL) {
|
||||||
if (code==IC_JMP||code==IC_SUB_CALL) {
|
if (code==IC_JMP||code==IC_SUB_CALL) {
|
||||||
lb=OptLabelFwd(tmpi->ic_data);
|
lb=OptLabelFwd(tmpi->ic_data);
|
||||||
if (lb->use_cnt>0)
|
if (lb->use_count>0)
|
||||||
lb->use_cnt--;
|
lb->use_count--;
|
||||||
}
|
}
|
||||||
tmpi=OptFree(tmpi);
|
tmpi=OptFree(tmpi);
|
||||||
} else {
|
} else {
|
||||||
@ -166,7 +166,7 @@ U0 OptPass4(CCompCtrl *cc,COptReg *reg_offsets,I64 *_type)
|
|||||||
tmpil2=tmpil3=&cmp.ic_nop;
|
tmpil2=tmpil3=&cmp.ic_nop;
|
||||||
} else
|
} else
|
||||||
tmpil1=tmpil2=tmpil3=&cmp.ic_nop;
|
tmpil1=tmpil2=tmpil3=&cmp.ic_nop;
|
||||||
switch [intermediate_code_table[code].arg_cnt] {
|
switch [intermediate_code_table[code].arg_count] {
|
||||||
case IS_V_ARG:
|
case IS_V_ARG:
|
||||||
ps->ptr-=tmpi->ic_data>>3;
|
ps->ptr-=tmpi->ic_data>>3;
|
||||||
break;
|
break;
|
||||||
@ -527,7 +527,7 @@ p4_sib:
|
|||||||
break;
|
break;
|
||||||
case IC_LABEL:
|
case IC_LABEL:
|
||||||
lb=tmpi->ic_data;
|
lb=tmpi->ic_data;
|
||||||
if (lb->use_cnt)
|
if (lb->use_count)
|
||||||
dead_code=FALSE;
|
dead_code=FALSE;
|
||||||
break;
|
break;
|
||||||
case IC_JMP:
|
case IC_JMP:
|
||||||
@ -549,7 +549,7 @@ p4_sib:
|
|||||||
tmpi->arg1.disp=0;
|
tmpi->arg1.disp=0;
|
||||||
tmpil1->res.type=MDF_REG+tmpil1->res.type.raw_type;
|
tmpil1->res.type=MDF_REG+tmpil1->res.type.raw_type;
|
||||||
tmpil1->res.disp=0;
|
tmpil1->res.disp=0;
|
||||||
if (intermediate_code_table[tmpi->ic_code].arg_cnt==IS_2_ARG) {
|
if (intermediate_code_table[tmpi->ic_code].arg_count==IS_2_ARG) {
|
||||||
tmpi->arg1.reg=REG_R8;
|
tmpi->arg1.reg=REG_R8;
|
||||||
tmpil1->res.reg=REG_R8;
|
tmpil1->res.reg=REG_R8;
|
||||||
} else {
|
} else {
|
||||||
@ -676,7 +676,7 @@ p4_sib:
|
|||||||
if (tmpi) {
|
if (tmpi) {
|
||||||
while (OptIC4(tmpi));
|
while (OptIC4(tmpi));
|
||||||
code=tmpi->ic_code;
|
code=tmpi->ic_code;
|
||||||
if (intermediate_code_table[code].res_cnt)
|
if (intermediate_code_table[code].res_count)
|
||||||
ParsePush(ps,tmpi);
|
ParsePush(ps,tmpi);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@ U0 OptPass5(CCompCtrl *cc)
|
|||||||
ICPut(cc,tmpi);
|
ICPut(cc,tmpi);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (intermediate_code_table[code].arg_cnt==IS_V_ARG)
|
if (intermediate_code_table[code].arg_count==IS_V_ARG)
|
||||||
ps->ptr-=tmpi->ic_data>>3;
|
ps->ptr-=tmpi->ic_data>>3;
|
||||||
if (code==IC_PUSH_REGS) {
|
if (code==IC_PUSH_REGS) {
|
||||||
for (i=0;i<REG_REGS_NUM;i++)
|
for (i=0;i<REG_REGS_NUM;i++)
|
||||||
|
@ -59,7 +59,7 @@ U0 OptPass6Lag(CCompCtrl *cc,CPrsStk *ps,CIntermediateCode *tmpi,
|
|||||||
ps->ptr--;
|
ps->ptr--;
|
||||||
stk_ptr=ParsePop(ps);
|
stk_ptr=ParsePop(ps);
|
||||||
}
|
}
|
||||||
if (intermediate_code_table[code].arg_cnt==IS_V_ARG)
|
if (intermediate_code_table[code].arg_count==IS_V_ARG)
|
||||||
stk_ptr-=tmpi->ic_data>>3;
|
stk_ptr-=tmpi->ic_data>>3;
|
||||||
if (tmpi->arg2.type&MDF_STK) {
|
if (tmpi->arg2.type&MDF_STK) {
|
||||||
stk_ptr--;
|
stk_ptr--;
|
||||||
@ -147,7 +147,7 @@ U0 OptPass6(CCompCtrl *cc)
|
|||||||
tmpi->arg1.disp=0;
|
tmpi->arg1.disp=0;
|
||||||
tmpil2->res.type=MDF_REG+tmpil2->res.type.raw_type;
|
tmpil2->res.type=MDF_REG+tmpil2->res.type.raw_type;
|
||||||
tmpil2->res.disp=0;
|
tmpil2->res.disp=0;
|
||||||
if (intermediate_code_table[tmpi->ic_code].arg_cnt==IS_2_ARG) {
|
if (intermediate_code_table[tmpi->ic_code].arg_count==IS_2_ARG) {
|
||||||
tmpi->arg1.reg=REG_R8;
|
tmpi->arg1.reg=REG_R8;
|
||||||
tmpil2->res.reg=REG_R8;
|
tmpil2->res.reg=REG_R8;
|
||||||
} else {
|
} else {
|
||||||
|
@ -7,7 +7,7 @@ size is now known
|
|||||||
cc->pass==10 is final pass, code is placed into buf.
|
cc->pass==10 is final pass, code is placed into buf.
|
||||||
*/
|
*/
|
||||||
CIntermediateCode *tmpi,*tmpi_next;
|
CIntermediateCode *tmpi,*tmpi_next;
|
||||||
I64 i,cnt,num_lines=cc->max_line+1-cc->min_line,rip=0,rip2;
|
I64 i,count,num_lines=cc->max_line+1-cc->min_line,rip=0,rip2;
|
||||||
U8 *ptr,saved_arg1_arg2_r[3*sizeof(CICArg)];
|
U8 *ptr,saved_arg1_arg2_r[3*sizeof(CICArg)];
|
||||||
CCodeMisc *lb;
|
CCodeMisc *lb;
|
||||||
CAOT *tmpaot;
|
CAOT *tmpaot;
|
||||||
@ -42,7 +42,7 @@ cc->pass==10 is final pass, code is placed into buf.
|
|||||||
cc->last_float_op_ic=NULL;
|
cc->last_float_op_ic=NULL;
|
||||||
tmpi=&cc->coc.coc_head;
|
tmpi=&cc->coc.coc_head;
|
||||||
tmpi->ic_last_start=-1;
|
tmpi->ic_last_start=-1;
|
||||||
tmpi->ic_cnt=0;
|
tmpi->ic_count=0;
|
||||||
tmpi=tmpi->next;
|
tmpi=tmpi->next;
|
||||||
while (tmpi->ic_code) {
|
while (tmpi->ic_code) {
|
||||||
tmpi_next=tmpi->next;
|
tmpi_next=tmpi->next;
|
||||||
@ -60,7 +60,7 @@ cc->pass==10 is final pass, code is placed into buf.
|
|||||||
if (cc->pass==7)
|
if (cc->pass==7)
|
||||||
cc->dont_push_float=Btr(&tmpi->ic_flags,ICf_DONT_PUSH_FLOAT0);
|
cc->dont_push_float=Btr(&tmpi->ic_flags,ICf_DONT_PUSH_FLOAT0);
|
||||||
MemCpy(saved_arg1_arg2_r,&tmpi->arg1,3*sizeof(CICArg));
|
MemCpy(saved_arg1_arg2_r,&tmpi->arg1,3*sizeof(CICArg));
|
||||||
tmpi->ic_cnt=0;
|
tmpi->ic_count=0;
|
||||||
tmpi->ic_last_start=-1;
|
tmpi->ic_last_start=-1;
|
||||||
if (tmpi->arg2.type.mode) {
|
if (tmpi->arg2.type.mode) {
|
||||||
if (tmpi->ic_flags & ICF_ARG2_TO_F64) {
|
if (tmpi->ic_flags & ICF_ARG2_TO_F64) {
|
||||||
@ -105,7 +105,7 @@ cc->pass==10 is final pass, code is placed into buf.
|
|||||||
tmpa->next=aotc->abss;
|
tmpa->next=aotc->abss;
|
||||||
tmpa->type=AAT_ADD_U64;
|
tmpa->type=AAT_ADD_U64;
|
||||||
aotc->abss=tmpa;
|
aotc->abss=tmpa;
|
||||||
tmpa->rip=rip2+tmpi->ic_cnt-8;
|
tmpa->rip=rip2+tmpi->ic_count-8;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case IC_HEAP_GLBL:
|
case IC_HEAP_GLBL:
|
||||||
@ -118,7 +118,7 @@ cc->pass==10 is final pass, code is placed into buf.
|
|||||||
tmphgr=CAlloc(sizeof(CAOTHeapGlobalRef));
|
tmphgr=CAlloc(sizeof(CAOTHeapGlobalRef));
|
||||||
tmphgr->next=tmphg->references;
|
tmphgr->next=tmphg->references;
|
||||||
tmphg->references=tmphgr;
|
tmphg->references=tmphgr;
|
||||||
tmphgr->rip=rip2+tmpi->ic_cnt-8;
|
tmphgr->rip=rip2+tmpi->ic_count-8;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case IC_ADDR_IMPORT:
|
case IC_ADDR_IMPORT:
|
||||||
@ -128,7 +128,7 @@ cc->pass==10 is final pass, code is placed into buf.
|
|||||||
tmpg=tmpi->ic_data;
|
tmpg=tmpi->ic_data;
|
||||||
tmpie=CAlloc(sizeof(CAOTImportExport));
|
tmpie=CAlloc(sizeof(CAOTImportExport));
|
||||||
tmpie->type=IET_IMM_U32;
|
tmpie->type=IET_IMM_U32;
|
||||||
tmpie->rip=rip2+tmpi->ic_cnt-4;
|
tmpie->rip=rip2+tmpi->ic_count-4;
|
||||||
tmpie->next=tmpg->ie_lst;
|
tmpie->next=tmpg->ie_lst;
|
||||||
tmpg->ie_lst=tmpie;
|
tmpg->ie_lst=tmpie;
|
||||||
}
|
}
|
||||||
@ -136,13 +136,13 @@ cc->pass==10 is final pass, code is placed into buf.
|
|||||||
break;
|
break;
|
||||||
case IC_RIP:
|
case IC_RIP:
|
||||||
ICU16(tmpi,0xB848);
|
ICU16(tmpi,0xB848);
|
||||||
ICU64(tmpi,rip2+tmpi->ic_cnt-2);
|
ICU64(tmpi,rip2+tmpi->ic_count-2);
|
||||||
if (cc->flags&CCF_AOT_COMPILE && buf &&!(cc->flags&CCF_NO_ABSS)) {
|
if (cc->flags&CCF_AOT_COMPILE && buf &&!(cc->flags&CCF_NO_ABSS)) {
|
||||||
tmpa=CAlloc(sizeof(CAOTAbsAddr));
|
tmpa=CAlloc(sizeof(CAOTAbsAddr));
|
||||||
tmpa->next=aotc->abss;
|
tmpa->next=aotc->abss;
|
||||||
tmpa->type=AAT_ADD_U64;
|
tmpa->type=AAT_ADD_U64;
|
||||||
aotc->abss=tmpa;
|
aotc->abss=tmpa;
|
||||||
tmpa->rip=rip2+tmpi->ic_cnt-8;
|
tmpa->rip=rip2+tmpi->ic_count-8;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
end:
|
end:
|
||||||
@ -305,7 +305,7 @@ cc->pass==10 is final pass, code is placed into buf.
|
|||||||
break;
|
break;
|
||||||
case IC_ASM:
|
case IC_ASM:
|
||||||
tmpaot=tmpi->ic_data;
|
tmpaot=tmpi->ic_data;
|
||||||
tmpi->ic_cnt+=tmpaot->aot_U8s;
|
tmpi->ic_count+=tmpaot->aot_U8s;
|
||||||
if (buf) {
|
if (buf) {
|
||||||
MemCpy(buf+rip,tmpaot->buf,tmpaot->aot_U8s);
|
MemCpy(buf+rip,tmpaot->buf,tmpaot->aot_U8s);
|
||||||
Free(tmpaot->buf);
|
Free(tmpaot->buf);
|
||||||
@ -316,7 +316,7 @@ cc->pass==10 is final pass, code is placed into buf.
|
|||||||
CompFixUpAOTAsm(cc,tmpaot);
|
CompFixUpAOTAsm(cc,tmpaot);
|
||||||
else
|
else
|
||||||
CompFixUpJITAsm(cc,tmpaot);
|
CompFixUpJITAsm(cc,tmpaot);
|
||||||
cnt=tmpi->ic_cnt;
|
count=tmpi->ic_count;
|
||||||
goto op789A_skip_copy;
|
goto op789A_skip_copy;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -344,7 +344,7 @@ cc->pass==10 is final pass, code is placed into buf.
|
|||||||
break;
|
break;
|
||||||
case IC_CALL_INDIRECT2:
|
case IC_CALL_INDIRECT2:
|
||||||
ICU16(tmpi,0xBB48);
|
ICU16(tmpi,0xBB48);
|
||||||
if (cc->flags&CCF_AOT_COMPILE) i=rip2+tmpi->ic_cnt;
|
if (cc->flags&CCF_AOT_COMPILE) i=rip2+tmpi->ic_count;
|
||||||
ICU64(tmpi,tmpi->ic_data);
|
ICU64(tmpi,tmpi->ic_data);
|
||||||
ICU16(tmpi,0x13FF);
|
ICU16(tmpi,0x13FF);
|
||||||
if (buf && cc->flags&CCF_AOT_COMPILE&& !(cc->flags&CCF_NO_ABSS)) {
|
if (buf && cc->flags&CCF_AOT_COMPILE&& !(cc->flags&CCF_NO_ABSS)) {
|
||||||
@ -363,7 +363,7 @@ cc->pass==10 is final pass, code is placed into buf.
|
|||||||
tmpf=tmpi->ic_data;
|
tmpf=tmpi->ic_data;
|
||||||
tmpie=CAlloc(sizeof(CAOTImportExport));
|
tmpie=CAlloc(sizeof(CAOTImportExport));
|
||||||
tmpie->type=IET_IMM_I64;
|
tmpie->type=IET_IMM_I64;
|
||||||
tmpie->rip=rip2+tmpi->ic_cnt-8;
|
tmpie->rip=rip2+tmpi->ic_count-8;
|
||||||
tmpie->next=tmpf->ie_lst;
|
tmpie->next=tmpf->ie_lst;
|
||||||
tmpf->ie_lst=tmpie;
|
tmpf->ie_lst=tmpie;
|
||||||
}
|
}
|
||||||
@ -375,7 +375,7 @@ cc->pass==10 is final pass, code is placed into buf.
|
|||||||
tmpf=tmpi->ic_data;
|
tmpf=tmpi->ic_data;
|
||||||
tmpie=CAlloc(sizeof(CAOTImportExport));
|
tmpie=CAlloc(sizeof(CAOTImportExport));
|
||||||
tmpie->type=IET_REL_I32;
|
tmpie->type=IET_REL_I32;
|
||||||
tmpie->rip=rip2+tmpi->ic_cnt-4;
|
tmpie->rip=rip2+tmpi->ic_count-4;
|
||||||
tmpie->next=tmpf->ie_lst;
|
tmpie->next=tmpf->ie_lst;
|
||||||
tmpf->ie_lst=tmpie;
|
tmpf->ie_lst=tmpie;
|
||||||
}
|
}
|
||||||
@ -406,12 +406,12 @@ cc->pass==10 is final pass, code is placed into buf.
|
|||||||
if (Bt(&cc->htc.fun->flags,Ff_HASERRCODE))
|
if (Bt(&cc->htc.fun->flags,Ff_HASERRCODE))
|
||||||
ICAddRSP(tmpi,8);
|
ICAddRSP(tmpi,8);
|
||||||
ICU16(tmpi,0xCF48);
|
ICU16(tmpi,0xCF48);
|
||||||
} else if (cc->htc.fun && cc->htc.fun->arg_cnt &&
|
} else if (cc->htc.fun && cc->htc.fun->arg_count &&
|
||||||
(Bt(&cc->htc.fun->flags,Ff_RET1) ||
|
(Bt(&cc->htc.fun->flags,Ff_RET1) ||
|
||||||
Bt(&cc->htc.fun->flags,Ff_ARGPOP)) &&
|
Bt(&cc->htc.fun->flags,Ff_ARGPOP)) &&
|
||||||
!Bt(&cc->htc.fun->flags,Ff_NOARGPOP)) {
|
!Bt(&cc->htc.fun->flags,Ff_NOARGPOP)) {
|
||||||
ICU8(tmpi,0xC2);
|
ICU8(tmpi,0xC2);
|
||||||
ICU16(tmpi,cc->htc.fun->arg_cnt<<3);
|
ICU16(tmpi,cc->htc.fun->arg_count<<3);
|
||||||
} else
|
} else
|
||||||
ICU8(tmpi,0xC3);
|
ICU8(tmpi,0xC3);
|
||||||
break;
|
break;
|
||||||
@ -1063,14 +1063,14 @@ cc->pass==10 is final pass, code is placed into buf.
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cnt=tmpi->ic_cnt;
|
count=tmpi->ic_count;
|
||||||
if (tmpi->ic_flags&ICF_DEL_PREV_INS) {
|
if (tmpi->ic_flags&ICF_DEL_PREV_INS) {
|
||||||
if (cc->pass>8)
|
if (cc->pass>8)
|
||||||
cnt=tmpi->ic_last_start;
|
count=tmpi->ic_last_start;
|
||||||
tmpi->ic_flags&=~ICF_DEL_PREV_INS;
|
tmpi->ic_flags&=~ICF_DEL_PREV_INS;
|
||||||
}
|
}
|
||||||
if (cnt && buf)
|
if (count && buf)
|
||||||
MemCpy(buf+rip,tmpi->ic_body,cnt);
|
MemCpy(buf+rip,tmpi->ic_body,count);
|
||||||
op789A_skip_copy:
|
op789A_skip_copy:
|
||||||
if (dbg_info && cc->min_line<=tmpi->ic_line<=cc->max_line) {
|
if (dbg_info && cc->min_line<=tmpi->ic_line<=cc->max_line) {
|
||||||
i=tmpi->ic_line-cc->min_line;
|
i=tmpi->ic_line-cc->min_line;
|
||||||
@ -1078,18 +1078,18 @@ op789A_skip_copy:
|
|||||||
dbg_info->body[i]=rip2;
|
dbg_info->body[i]=rip2;
|
||||||
}
|
}
|
||||||
if (tmpi->ic_flags&ICF_PASS_TRACE &&
|
if (tmpi->ic_flags&ICF_PASS_TRACE &&
|
||||||
Bt(&cc->saved_pass_trace,cc->pass) && cnt) {
|
Bt(&cc->saved_pass_trace,cc->pass) && count) {
|
||||||
"$$RED$$";
|
"$$RED$$";
|
||||||
if (buf)
|
if (buf)
|
||||||
Un(buf+rip,cnt,64);
|
Un(buf+rip,count,64);
|
||||||
else
|
else
|
||||||
Un(tmpi->ic_body,cnt,64);
|
Un(tmpi->ic_body,count,64);
|
||||||
"$$FG$$";
|
"$$FG$$";
|
||||||
}
|
}
|
||||||
if (!(tmpi->ic_flags&(ICF_CODE_FINAL|ICF_DONT_RESTORE)))
|
if (!(tmpi->ic_flags&(ICF_CODE_FINAL|ICF_DONT_RESTORE)))
|
||||||
MemCpy(&tmpi->arg1,saved_arg1_arg2_r,3*sizeof(CICArg));
|
MemCpy(&tmpi->arg1,saved_arg1_arg2_r,3*sizeof(CICArg));
|
||||||
rip+=cnt;
|
rip+=count;
|
||||||
if (tmpi->ic_cnt>=IC_BODY_SIZE && tmpi->ic_code!=IC_ASM)
|
if (tmpi->ic_count>=IC_BODY_SIZE && tmpi->ic_code!=IC_ASM)
|
||||||
throw('Compiler');
|
throw('Compiler');
|
||||||
op789A_next:
|
op789A_next:
|
||||||
tmpi=tmpi_next;
|
tmpi=tmpi_next;
|
||||||
|
@ -18,15 +18,15 @@ CIntermediateCode *ParseAddOp(CCompCtrl *cc,I64 stk_op,CHashClass *tmpc)
|
|||||||
Bool div_sizeof=FALSE;
|
Bool div_sizeof=FALSE;
|
||||||
switch (stk_op.u16[0]) {
|
switch (stk_op.u16[0]) {
|
||||||
case IC_ADD:
|
case IC_ADD:
|
||||||
if (tmpc->ptr_stars_cnt && !tmpi->ic_class->ptr_stars_cnt &&
|
if (tmpc->ptr_stars_count && !tmpi->ic_class->ptr_stars_count &&
|
||||||
tmpi->ic_class->raw_type!=RT_F64) {
|
tmpi->ic_class->raw_type!=RT_F64) {
|
||||||
ICAdd(cc,IC_SIZEOF,1,cmp.internal_types[RT_I64]);
|
ICAdd(cc,IC_SIZEOF,1,cmp.internal_types[RT_I64]);
|
||||||
ICAdd(cc,IC_MUL,0,cmp.internal_types[RT_I64]);
|
ICAdd(cc,IC_MUL,0,cmp.internal_types[RT_I64]);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case IC_SUB:
|
case IC_SUB:
|
||||||
if (tmpc->ptr_stars_cnt && tmpi->ic_class->raw_type!=RT_F64) {
|
if (tmpc->ptr_stars_count && tmpi->ic_class->raw_type!=RT_F64) {
|
||||||
if (!tmpi->ic_class->ptr_stars_cnt) {
|
if (!tmpi->ic_class->ptr_stars_count) {
|
||||||
ICAdd(cc,IC_SIZEOF,1,cmp.internal_types[RT_I64]);
|
ICAdd(cc,IC_SIZEOF,1,cmp.internal_types[RT_I64]);
|
||||||
ICAdd(cc,IC_MUL,0,cmp.internal_types[RT_I64]);
|
ICAdd(cc,IC_MUL,0,cmp.internal_types[RT_I64]);
|
||||||
} else
|
} else
|
||||||
@ -39,7 +39,7 @@ CIntermediateCode *ParseAddOp(CCompCtrl *cc,I64 stk_op,CHashClass *tmpc)
|
|||||||
break;
|
break;
|
||||||
case IC_ADD_EQU:
|
case IC_ADD_EQU:
|
||||||
case IC_SUB_EQU:
|
case IC_SUB_EQU:
|
||||||
if (tmpc->ptr_stars_cnt) {
|
if (tmpc->ptr_stars_count) {
|
||||||
ICAdd(cc,IC_SIZEOF,1,cmp.internal_types[RT_I64]);
|
ICAdd(cc,IC_SIZEOF,1,cmp.internal_types[RT_I64]);
|
||||||
ICAdd(cc,IC_MUL,0,cmp.internal_types[RT_I64]);
|
ICAdd(cc,IC_MUL,0,cmp.internal_types[RT_I64]);
|
||||||
}
|
}
|
||||||
@ -148,10 +148,10 @@ pe_check_binary_ops2:
|
|||||||
} else {
|
} else {
|
||||||
tmpi=cc->coc.coc_head.last;
|
tmpi=cc->coc.coc_head.last;
|
||||||
tmpc=tmpi->ic_class;
|
tmpc=tmpi->ic_class;
|
||||||
if (stk_op.u16[0]==IC_DEREF && tmpc->ptr_stars_cnt)
|
if (stk_op.u16[0]==IC_DEREF && tmpc->ptr_stars_count)
|
||||||
tmpc--;
|
tmpc--;
|
||||||
else if (stk_op.u16[0]==IC_ADDR) {
|
else if (stk_op.u16[0]==IC_ADDR) {
|
||||||
cc->abs_cnts.c_addres++;
|
cc->abs_counts.c_addres++;
|
||||||
if (intermediate_code_table[tmpi->ic_code].type==IST_DEREF)
|
if (intermediate_code_table[tmpi->ic_code].type==IST_DEREF)
|
||||||
OptFree(tmpi);
|
OptFree(tmpi);
|
||||||
tmpc++;
|
tmpc++;
|
||||||
@ -173,7 +173,7 @@ pe_do_binary_op:
|
|||||||
case IC_ADD:
|
case IC_ADD:
|
||||||
case IC_SUB:
|
case IC_SUB:
|
||||||
tmpi=cc->coc.coc_head.last;
|
tmpi=cc->coc.coc_head.last;
|
||||||
if (!tmpi->ic_class->ptr_stars_cnt &&
|
if (!tmpi->ic_class->ptr_stars_count &&
|
||||||
tmpi->ic_class->raw_type!=RT_F64) {
|
tmpi->ic_class->raw_type!=RT_F64) {
|
||||||
ICAdd(cc,IC_SIZEOF,1,cmp.internal_types[RT_I64]);
|
ICAdd(cc,IC_SIZEOF,1,cmp.internal_types[RT_I64]);
|
||||||
ICAdd(cc,IC_MUL,0,cmp.internal_types[RT_I64]);
|
ICAdd(cc,IC_MUL,0,cmp.internal_types[RT_I64]);
|
||||||
@ -202,7 +202,7 @@ pe_do_binary_op:
|
|||||||
tmpi=cc->coc.coc_head.last;
|
tmpi=cc->coc.coc_head.last;
|
||||||
tmpc=OptClassFwd(tmpi->ic_class);
|
tmpc=OptClassFwd(tmpi->ic_class);
|
||||||
if (intermediate_code_table[tmpi->ic_code].type!=IST_DEREF ||
|
if (intermediate_code_table[tmpi->ic_code].type!=IST_DEREF ||
|
||||||
!tmpc->ptr_stars_cnt && !Bt(&tmpc->flags,Cf_INTERNAL_TYPE))
|
!tmpc->ptr_stars_count && !Bt(&tmpc->flags,Cf_INTERNAL_TYPE))
|
||||||
LexExcept(cc,"Invalid lval at ");
|
LexExcept(cc,"Invalid lval at ");
|
||||||
tmpi->ic_code=IC_NOP1; //Important for setting class (pretty sure)
|
tmpi->ic_code=IC_NOP1; //Important for setting class (pretty sure)
|
||||||
cur_op.u8[2]=PREC_ASSIGN|ASSOCF_RIGHT;
|
cur_op.u8[2]=PREC_ASSIGN|ASSOCF_RIGHT;
|
||||||
@ -310,7 +310,7 @@ U0 ParseSizeOf(CCompCtrl *cc)
|
|||||||
LexExcept(cc,"Invalid class at ");
|
LexExcept(cc,"Invalid class at ");
|
||||||
if (tmpm=cc->local_var_entry) {
|
if (tmpm=cc->local_var_entry) {
|
||||||
tmpc=tmpm->member_class;
|
tmpc=tmpm->member_class;
|
||||||
i=tmpc->size*tmpm->dim.total_cnt;
|
i=tmpc->size*tmpm->dim.total_count;
|
||||||
if (Lex(cc)=='.')
|
if (Lex(cc)=='.')
|
||||||
goto pu_sizeof_member;
|
goto pu_sizeof_member;
|
||||||
} else {
|
} else {
|
||||||
@ -335,11 +335,11 @@ pu_sizeof_member:
|
|||||||
if (Lex(cc)!=TK_IDENT || !(tmpm=MemberFind(cc->cur_str,tmpc)))
|
if (Lex(cc)!=TK_IDENT || !(tmpm=MemberFind(cc->cur_str,tmpc)))
|
||||||
LexExcept(cc,"Invalid member at ");
|
LexExcept(cc,"Invalid member at ");
|
||||||
else if (cc->local_var_entry)
|
else if (cc->local_var_entry)
|
||||||
cc->local_var_entry->use_cnt--;
|
cc->local_var_entry->use_count--;
|
||||||
tmpc=tmpm->member_class;
|
tmpc=tmpm->member_class;
|
||||||
//Probably others like this:
|
//Probably others like this:
|
||||||
#assert offset(CHashClass.size)==offset(CHashGlobalVar.size)
|
#assert offset(CHashClass.size)==offset(CHashGlobalVar.size)
|
||||||
i=tmpc->size*tmpm->dim.total_cnt;
|
i=tmpc->size*tmpm->dim.total_count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -373,7 +373,7 @@ U0 ParseOffsetOf(CCompCtrl *cc)
|
|||||||
if (Lex(cc)!=TK_IDENT || !(tmpm=MemberFind(cc->cur_str,tmpc)))
|
if (Lex(cc)!=TK_IDENT || !(tmpm=MemberFind(cc->cur_str,tmpc)))
|
||||||
LexExcept(cc,"Invalid member at ");
|
LexExcept(cc,"Invalid member at ");
|
||||||
else if (cc->local_var_entry)
|
else if (cc->local_var_entry)
|
||||||
cc->local_var_entry->use_cnt--;
|
cc->local_var_entry->use_count--;
|
||||||
i+=tmpm->offset;
|
i+=tmpm->offset;
|
||||||
tmpc=tmpm->member_class;
|
tmpc=tmpm->member_class;
|
||||||
} while (Lex(cc)=='.');
|
} while (Lex(cc)=='.');
|
||||||
@ -382,7 +382,7 @@ U0 ParseOffsetOf(CCompCtrl *cc)
|
|||||||
|
|
||||||
I64 ParseFunCall(CCompCtrl *cc,CPrsStk *ps,Bool indirect,CHashFun *tmpf)
|
I64 ParseFunCall(CCompCtrl *cc,CPrsStk *ps,Bool indirect,CHashFun *tmpf)
|
||||||
{
|
{
|
||||||
I64 i,argc_cnt,dft_val;
|
I64 i,argc_count,dft_val;
|
||||||
Bool is_first_arg=TRUE,needs_right_paren,is_print,is_putchars,
|
Bool is_first_arg=TRUE,needs_right_paren,is_print,is_putchars,
|
||||||
is_template_fun;
|
is_template_fun;
|
||||||
CHashClass *tmpc2,*last_class=NULL;
|
CHashClass *tmpc2,*last_class=NULL;
|
||||||
@ -427,9 +427,9 @@ I64 ParseFunCall(CCompCtrl *cc,CPrsStk *ps,Bool indirect,CHashFun *tmpf)
|
|||||||
COCPush(cc);
|
COCPush(cc);
|
||||||
tmpcbh=cc->coc.coc_next;
|
tmpcbh=cc->coc.coc_next;
|
||||||
cc->coc.coc_next=NULL;
|
cc->coc.coc_next=NULL;
|
||||||
i=tmpf->arg_cnt;
|
i=tmpf->arg_count;
|
||||||
tmpm=tmpf->member_lst_and_root;
|
tmpm=tmpf->member_lst_and_root;
|
||||||
argc_cnt=0;
|
argc_count=0;
|
||||||
if (cc->token=='(') {
|
if (cc->token=='(') {
|
||||||
Lex(cc);
|
Lex(cc);
|
||||||
needs_right_paren=TRUE;
|
needs_right_paren=TRUE;
|
||||||
@ -456,7 +456,7 @@ I64 ParseFunCall(CCompCtrl *cc,CPrsStk *ps,Bool indirect,CHashFun *tmpf)
|
|||||||
(cc->token==')' || cc->token==',' || !needs_right_paren)) {
|
(cc->token==')' || cc->token==',' || !needs_right_paren)) {
|
||||||
dft_val=tmpm->dft_val;
|
dft_val=tmpm->dft_val;
|
||||||
if (tmpm->flags & MLF_LASTCLASS && last_class)
|
if (tmpm->flags & MLF_LASTCLASS && last_class)
|
||||||
dft_val=(last_class-last_class->ptr_stars_cnt)->str;
|
dft_val=(last_class-last_class->ptr_stars_count)->str;
|
||||||
if (tmpm->flags & (MLF_STR_DFT_AVAILABLE|MLF_LASTCLASS) &&
|
if (tmpm->flags & (MLF_STR_DFT_AVAILABLE|MLF_LASTCLASS) &&
|
||||||
cc->flags&CCF_AOT_COMPILE) {
|
cc->flags&CCF_AOT_COMPILE) {
|
||||||
cm=COCMiscNew(cc,CMT_STR_CONST);
|
cm=COCMiscNew(cc,CMT_STR_CONST);
|
||||||
@ -506,7 +506,7 @@ I64 ParseFunCall(CCompCtrl *cc,CPrsStk *ps,Bool indirect,CHashFun *tmpf)
|
|||||||
throw('Compiler');
|
throw('Compiler');
|
||||||
COCPush(cc);
|
COCPush(cc);
|
||||||
is_first_arg=FALSE;
|
is_first_arg=FALSE;
|
||||||
argc_cnt++;
|
argc_count++;
|
||||||
} while (cc->token==',');
|
} while (cc->token==',');
|
||||||
}
|
}
|
||||||
} else if (needs_right_paren) {
|
} else if (needs_right_paren) {
|
||||||
@ -523,11 +523,11 @@ I64 ParseFunCall(CCompCtrl *cc,CPrsStk *ps,Bool indirect,CHashFun *tmpf)
|
|||||||
throw('Compiler');
|
throw('Compiler');
|
||||||
COCPush(cc);
|
COCPush(cc);
|
||||||
is_first_arg=FALSE;
|
is_first_arg=FALSE;
|
||||||
argc_cnt++;
|
argc_count++;
|
||||||
} while (cc->token==',');
|
} while (cc->token==',');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tmpi->ic_data=argc_cnt++; //++ so add_esp latter works
|
tmpi->ic_data=argc_count++; //++ so add_esp latter works
|
||||||
}
|
}
|
||||||
if (needs_right_paren) {
|
if (needs_right_paren) {
|
||||||
if (cc->token==')')
|
if (cc->token==')')
|
||||||
@ -557,9 +557,9 @@ I64 ParseFunCall(CCompCtrl *cc,CPrsStk *ps,Bool indirect,CHashFun *tmpf)
|
|||||||
else {
|
else {
|
||||||
if (indirect)
|
if (indirect)
|
||||||
ICAdd(cc,IC_CALL_INDIRECT,
|
ICAdd(cc,IC_CALL_INDIRECT,
|
||||||
(argc_cnt+tmpf->arg_cnt)<<3,tmpf->return_class);
|
(argc_count+tmpf->arg_count)<<3,tmpf->return_class);
|
||||||
else if (Bt(&tmpf->flags,Cf_EXTERN)) {
|
else if (Bt(&tmpf->flags,Cf_EXTERN)) {
|
||||||
cc->abs_cnts.externs++;
|
cc->abs_counts.externs++;
|
||||||
if (cc->flags&CCF_AOT_COMPILE) {
|
if (cc->flags&CCF_AOT_COMPILE) {
|
||||||
if (tmpf->type&HTF_IMPORT)
|
if (tmpf->type&HTF_IMPORT)
|
||||||
ICAdd(cc,IC_CALL_IMPORT,tmpf,tmpf->return_class);
|
ICAdd(cc,IC_CALL_IMPORT,tmpf,tmpf->return_class);
|
||||||
@ -572,14 +572,14 @@ I64 ParseFunCall(CCompCtrl *cc,CPrsStk *ps,Bool indirect,CHashFun *tmpf)
|
|||||||
if ((Bt(&tmpf->flags,Ff_RET1) || Bt(&tmpf->flags,Ff_ARGPOP)) &&
|
if ((Bt(&tmpf->flags,Ff_RET1) || Bt(&tmpf->flags,Ff_ARGPOP)) &&
|
||||||
!Bt(&tmpf->flags,Ff_NOARGPOP)) {
|
!Bt(&tmpf->flags,Ff_NOARGPOP)) {
|
||||||
if (indirect) {
|
if (indirect) {
|
||||||
ICAdd(cc,IC_ADD_RSP1,(argc_cnt+tmpf->arg_cnt)<<3,tmpf->return_class);
|
ICAdd(cc,IC_ADD_RSP1,(argc_count+tmpf->arg_count)<<3,tmpf->return_class);
|
||||||
ICAdd(cc,IC_ADD_RSP,8,tmpf->return_class);
|
ICAdd(cc,IC_ADD_RSP,8,tmpf->return_class);
|
||||||
} else
|
} else
|
||||||
ICAdd(cc,IC_ADD_RSP1,(argc_cnt+tmpf->arg_cnt)<<3,tmpf->return_class);
|
ICAdd(cc,IC_ADD_RSP1,(argc_count+tmpf->arg_count)<<3,tmpf->return_class);
|
||||||
} else {
|
} else {
|
||||||
if (indirect)
|
if (indirect)
|
||||||
argc_cnt++;
|
argc_count++;
|
||||||
ICAdd(cc,IC_ADD_RSP,(argc_cnt+tmpf->arg_cnt)<<3,tmpf->return_class);
|
ICAdd(cc,IC_ADD_RSP,(argc_count+tmpf->arg_count)<<3,tmpf->return_class);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!is_template_fun)
|
if (!is_template_fun)
|
||||||
@ -635,7 +635,7 @@ I64 ParseUnaryTerm(CCompCtrl *cc,CPrsStk *ps,CMemberLst **_local_var,
|
|||||||
}
|
}
|
||||||
LexExcept(cc,"Can't take addr of extern fun");
|
LexExcept(cc,"Can't take addr of extern fun");
|
||||||
}
|
}
|
||||||
cc->abs_cnts.externs++;
|
cc->abs_counts.externs++;
|
||||||
ICAdd(cc,IC_IMM_I64,
|
ICAdd(cc,IC_IMM_I64,
|
||||||
&tmpf->exe_addr,cmp.internal_types[RT_PTR]);
|
&tmpf->exe_addr,cmp.internal_types[RT_PTR]);
|
||||||
ICAdd(cc,IC_DEREF,0,cmp.internal_types[RT_PTR]);
|
ICAdd(cc,IC_DEREF,0,cmp.internal_types[RT_PTR]);
|
||||||
@ -644,12 +644,12 @@ I64 ParseUnaryTerm(CCompCtrl *cc,CPrsStk *ps,CMemberLst **_local_var,
|
|||||||
ICAdd(cc,IC_ABS_ADDR,
|
ICAdd(cc,IC_ABS_ADDR,
|
||||||
tmpf->exe_addr,cmp.internal_types[RT_PTR]);
|
tmpf->exe_addr,cmp.internal_types[RT_PTR]);
|
||||||
if (cc->flags&CCF_ASM_EXPRESSIONS)
|
if (cc->flags&CCF_ASM_EXPRESSIONS)
|
||||||
cc->abs_cnts.abs_addres++;
|
cc->abs_counts.abs_addres++;
|
||||||
} else
|
} else
|
||||||
ICAdd(cc,IC_IMM_I64,
|
ICAdd(cc,IC_IMM_I64,
|
||||||
tmpf->exe_addr,cmp.internal_types[RT_PTR]);
|
tmpf->exe_addr,cmp.internal_types[RT_PTR]);
|
||||||
}
|
}
|
||||||
cc->abs_cnts.c_addres++;
|
cc->abs_counts.c_addres++;
|
||||||
Lex(cc);
|
Lex(cc);
|
||||||
return PE_MAYBE_MODIFIERS;
|
return PE_MAYBE_MODIFIERS;
|
||||||
}
|
}
|
||||||
@ -657,7 +657,7 @@ I64 ParseUnaryTerm(CCompCtrl *cc,CPrsStk *ps,CMemberLst **_local_var,
|
|||||||
tmpex=tmpc;
|
tmpex=tmpc;
|
||||||
if (cc->flags&CCF_ASM_EXPRESSIONS &&
|
if (cc->flags&CCF_ASM_EXPRESSIONS &&
|
||||||
!(cc->flags&CCF_AOT_COMPILE) && tmpex->type&HTF_IMM) {
|
!(cc->flags&CCF_AOT_COMPILE) && tmpex->type&HTF_IMM) {
|
||||||
cc->abs_cnts.c_addres++;
|
cc->abs_counts.c_addres++;
|
||||||
ICAdd(cc,IC_IMM_I64,
|
ICAdd(cc,IC_IMM_I64,
|
||||||
tmpex->val,cmp.internal_types[RT_PTR]);
|
tmpex->val,cmp.internal_types[RT_PTR]);
|
||||||
Lex(cc);
|
Lex(cc);
|
||||||
@ -706,7 +706,7 @@ I64 ParseUnaryTerm(CCompCtrl *cc,CPrsStk *ps,CMemberLst **_local_var,
|
|||||||
break;
|
break;
|
||||||
case '$$':
|
case '$$':
|
||||||
if (cc->flags & CCF_ASM_EXPRESSIONS) {
|
if (cc->flags & CCF_ASM_EXPRESSIONS) {
|
||||||
cc->abs_cnts.abs_addres++;
|
cc->abs_counts.abs_addres++;
|
||||||
if (cc->flags&CCF_AOT_COMPILE)
|
if (cc->flags&CCF_AOT_COMPILE)
|
||||||
ICAdd(cc,IC_ABS_ADDR,cc->aotc->rip,cmp.internal_types[RT_PTR]);
|
ICAdd(cc,IC_ABS_ADDR,cc->aotc->rip,cmp.internal_types[RT_PTR]);
|
||||||
else
|
else
|
||||||
@ -767,7 +767,7 @@ I64 ParseUnaryTerm(CCompCtrl *cc,CPrsStk *ps,CMemberLst **_local_var,
|
|||||||
if (tmpm->flags & MLF_FUN && !(cc->flags&CCF_ASM_EXPRESSIONS)) {
|
if (tmpm->flags & MLF_FUN && !(cc->flags&CCF_ASM_EXPRESSIONS)) {
|
||||||
ParsePopDeref(ps);
|
ParsePopDeref(ps);
|
||||||
cc->flags|=CCF_FUN_EXP;
|
cc->flags|=CCF_FUN_EXP;
|
||||||
ParsePush2(ps,tmpm->fun_ptr-tmpm->fun_ptr->ptr_stars_cnt);
|
ParsePush2(ps,tmpm->fun_ptr-tmpm->fun_ptr->ptr_stars_count);
|
||||||
}
|
}
|
||||||
if (tmpm->dim.next) {
|
if (tmpm->dim.next) {
|
||||||
*_tmpad=tmpm->dim.next;
|
*_tmpad=tmpm->dim.next;
|
||||||
@ -833,7 +833,7 @@ pu_export_sys_sym:
|
|||||||
if (PREC_TERM>*max_prec)
|
if (PREC_TERM>*max_prec)
|
||||||
*max_prec=PREC_TERM;
|
*max_prec=PREC_TERM;
|
||||||
if (!(tmpex->type & (HTF_IMM|HTF_IMPORT)))
|
if (!(tmpex->type & (HTF_IMM|HTF_IMPORT)))
|
||||||
cc->abs_cnts.abs_addres++;
|
cc->abs_counts.abs_addres++;
|
||||||
if (tmpex->type & HTF_UNRESOLVED) {
|
if (tmpex->type & HTF_UNRESOLVED) {
|
||||||
if (!(cc->flags&CCF_ASM_EXPRESSIONS))
|
if (!(cc->flags&CCF_ASM_EXPRESSIONS))
|
||||||
LexExcept(cc,"Illegal fwd ref at ");
|
LexExcept(cc,"Illegal fwd ref at ");
|
||||||
@ -853,7 +853,7 @@ pu_export_sys_sym:
|
|||||||
ICAdd(cc,IC_ABS_ADDR,tmpex->val,cmp.internal_types[RT_PTR]);
|
ICAdd(cc,IC_ABS_ADDR,tmpex->val,cmp.internal_types[RT_PTR]);
|
||||||
else {
|
else {
|
||||||
if (tmpex->type&HTF_IMM)
|
if (tmpex->type&HTF_IMM)
|
||||||
cc->abs_cnts.c_addres++;
|
cc->abs_counts.c_addres++;
|
||||||
ICAdd(cc,IC_IMM_I64,tmpex->val,cmp.internal_types[RT_PTR]);
|
ICAdd(cc,IC_IMM_I64,tmpex->val,cmp.internal_types[RT_PTR]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -889,7 +889,7 @@ pu_export_sys_sym:
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (tmpg->flags & GVF_EXTERN) {
|
if (tmpg->flags & GVF_EXTERN) {
|
||||||
cc->abs_cnts.externs++;
|
cc->abs_counts.externs++;
|
||||||
ICAdd(cc,IC_IMM_I64,&tmpg->data_addr,tmpc);
|
ICAdd(cc,IC_IMM_I64,&tmpg->data_addr,tmpc);
|
||||||
ICAdd(cc,IC_DEREF,0,tmpc);
|
ICAdd(cc,IC_DEREF,0,tmpc);
|
||||||
} else
|
} else
|
||||||
@ -899,7 +899,7 @@ pu_export_sys_sym:
|
|||||||
if (tmpg->flags & GVF_FUN) {
|
if (tmpg->flags & GVF_FUN) {
|
||||||
ParsePopDeref(ps);
|
ParsePopDeref(ps);
|
||||||
cc->flags|=CCF_FUN_EXP;
|
cc->flags|=CCF_FUN_EXP;
|
||||||
ParsePush2(ps,tmpg->fun_ptr-tmpg->fun_ptr->ptr_stars_cnt);
|
ParsePush2(ps,tmpg->fun_ptr-tmpg->fun_ptr->ptr_stars_count);
|
||||||
}
|
}
|
||||||
return PE_UNARY_MODIFIERS;
|
return PE_UNARY_MODIFIERS;
|
||||||
case HTt_CLASS:
|
case HTt_CLASS:
|
||||||
@ -987,7 +987,7 @@ I64 ParseUnaryModifier(CCompCtrl *cc,CPrsStk *ps,CMemberLst **_local_var,
|
|||||||
if (!*unary_post_prec)
|
if (!*unary_post_prec)
|
||||||
*unary_post_prec=PREC_TERM;
|
*unary_post_prec=PREC_TERM;
|
||||||
tmpc=cc->coc.coc_head.last->ic_class;
|
tmpc=cc->coc.coc_head.last->ic_class;
|
||||||
if ((!tmpc->ptr_stars_cnt || cc->flags & CCF_ARRAY) && cc->token=='.')
|
if ((!tmpc->ptr_stars_count || cc->flags & CCF_ARRAY) && cc->token=='.')
|
||||||
LexExcept(cc,"Must be address, not value ");
|
LexExcept(cc,"Must be address, not value ");
|
||||||
if (!(cc->flags & CCF_RAX))
|
if (!(cc->flags & CCF_RAX))
|
||||||
tmpc--;
|
tmpc--;
|
||||||
@ -997,7 +997,7 @@ I64 ParseUnaryModifier(CCompCtrl *cc,CPrsStk *ps,CMemberLst **_local_var,
|
|||||||
!(tmpm=MemberFind(cc->cur_str,tmpc)))
|
!(tmpm=MemberFind(cc->cur_str,tmpc)))
|
||||||
LexExcept(cc,"Invalid member at ");
|
LexExcept(cc,"Invalid member at ");
|
||||||
else if (cc->local_var_entry)
|
else if (cc->local_var_entry)
|
||||||
cc->local_var_entry->use_cnt--;
|
cc->local_var_entry->use_count--;
|
||||||
Lex(cc); //skip member name
|
Lex(cc); //skip member name
|
||||||
tmpc1=tmpm->member_class+1;
|
tmpc1=tmpm->member_class+1;
|
||||||
ICAdd(cc,IC_IMM_I64,tmpm->offset,tmpc1);
|
ICAdd(cc,IC_IMM_I64,tmpm->offset,tmpc1);
|
||||||
@ -1008,7 +1008,7 @@ I64 ParseUnaryModifier(CCompCtrl *cc,CPrsStk *ps,CMemberLst **_local_var,
|
|||||||
}
|
}
|
||||||
if(tmpm->flags & MLF_FUN) {
|
if(tmpm->flags & MLF_FUN) {
|
||||||
ParsePopDeref(ps);
|
ParsePopDeref(ps);
|
||||||
ParsePush2(ps,tmpm->fun_ptr-tmpm->fun_ptr->ptr_stars_cnt);
|
ParsePush2(ps,tmpm->fun_ptr-tmpm->fun_ptr->ptr_stars_count);
|
||||||
cc->flags|=CCF_FUN_EXP;
|
cc->flags|=CCF_FUN_EXP;
|
||||||
}
|
}
|
||||||
ICAdd(cc,IC_ADD,0,tmpc1);
|
ICAdd(cc,IC_ADD,0,tmpc1);
|
||||||
@ -1057,17 +1057,17 @@ I64 ParseUnaryModifier(CCompCtrl *cc,CPrsStk *ps,CMemberLst **_local_var,
|
|||||||
*unary_post_prec=PREC_TERM;
|
*unary_post_prec=PREC_TERM;
|
||||||
Lex(cc);
|
Lex(cc);
|
||||||
tmpc=OptClassFwd(cc->coc.coc_head.last->ic_class);
|
tmpc=OptClassFwd(cc->coc.coc_head.last->ic_class);
|
||||||
if (!tmpc->ptr_stars_cnt)
|
if (!tmpc->ptr_stars_count)
|
||||||
LexExcept(cc,"Not array or ptr ");
|
LexExcept(cc,"Not array or ptr ");
|
||||||
if (!(cc->flags & (CCF_ARRAY | CCF_RAX))) {
|
if (!(cc->flags & (CCF_ARRAY | CCF_RAX))) {
|
||||||
tmpc=OptClassFwd(tmpc-1);
|
tmpc=OptClassFwd(tmpc-1);
|
||||||
if (!tmpc->ptr_stars_cnt)
|
if (!tmpc->ptr_stars_count)
|
||||||
LexExcept(cc,"Not array or ptr ");
|
LexExcept(cc,"Not array or ptr ");
|
||||||
ICAdd(cc,IC_DEREF+PREC_UNARY_PRE<<16,0,tmpc);
|
ICAdd(cc,IC_DEREF+PREC_UNARY_PRE<<16,0,tmpc);
|
||||||
}
|
}
|
||||||
tmpc1=tmpc-1;
|
tmpc1=tmpc-1;
|
||||||
if (tmpad1=*_tmpad) {
|
if (tmpad1=*_tmpad) {
|
||||||
ICAdd(cc,IC_IMM_I64,tmpad1->total_cnt*tmpc1->size,tmpc);
|
ICAdd(cc,IC_IMM_I64,tmpad1->total_count*tmpc1->size,tmpc);
|
||||||
if (*_tmpad=tmpad1->next) {
|
if (*_tmpad=tmpad1->next) {
|
||||||
old_flags=cc->flags;
|
old_flags=cc->flags;
|
||||||
if (!ParseExpression(cc,NULL,FALSE,ps))
|
if (!ParseExpression(cc,NULL,FALSE,ps))
|
||||||
|
@ -51,7 +51,7 @@ for one * and two fwd for two **.
|
|||||||
tmpc->type=HTT_CLASS;
|
tmpc->type=HTT_CLASS;
|
||||||
tmpc->raw_type=RT_PTR;
|
tmpc->raw_type=RT_PTR;
|
||||||
tmpc->size=sizeof(U8 *);
|
tmpc->size=sizeof(U8 *);
|
||||||
tmpc->ptr_stars_cnt=i;
|
tmpc->ptr_stars_count=i;
|
||||||
tmpc++;
|
tmpc++;
|
||||||
}
|
}
|
||||||
res->last_in_member_lst=&res->member_lst_and_root;
|
res->last_in_member_lst=&res->member_lst_and_root;
|
||||||
@ -68,7 +68,7 @@ CHashFun *ParseFunNew()
|
|||||||
tmpf->type=HTT_FUN;
|
tmpf->type=HTT_FUN;
|
||||||
tmpf->raw_type=RT_PTR;
|
tmpf->raw_type=RT_PTR;
|
||||||
tmpf->size=sizeof(U8 *);
|
tmpf->size=sizeof(U8 *);
|
||||||
tmpf->ptr_stars_cnt=i;
|
tmpf->ptr_stars_count=i;
|
||||||
tmpf++;
|
tmpf++;
|
||||||
}
|
}
|
||||||
res->last_in_member_lst=&res->member_lst_and_root;
|
res->last_in_member_lst=&res->member_lst_and_root;
|
||||||
@ -88,7 +88,7 @@ CIntermediateCode *ICAdd(CCompCtrl *cc,
|
|||||||
Bts(&cc->flags,CCf_PASS_TRACE_PRESENT);
|
Bts(&cc->flags,CCf_PASS_TRACE_PRESENT);
|
||||||
flags|=ICF_PASS_TRACE;
|
flags|=ICF_PASS_TRACE;
|
||||||
}
|
}
|
||||||
if (cc->lock_cnt)
|
if (cc->lock_count)
|
||||||
flags|=ICF_LOCK;
|
flags|=ICF_LOCK;
|
||||||
tmpi->ic_flags=flags;
|
tmpi->ic_flags=flags;
|
||||||
tmpi->ic_line=cc->last_line_num;
|
tmpi->ic_line=cc->last_line_num;
|
||||||
@ -197,7 +197,7 @@ U0 COCDel(CCompCtrl *cc,CCodeCtrl *coc)
|
|||||||
if (!(cm->flags&CMF_DEFINED)) {
|
if (!(cm->flags&CMF_DEFINED)) {
|
||||||
undef=cm->str;
|
undef=cm->str;
|
||||||
cm->str=NULL;
|
cm->str=NULL;
|
||||||
} else if (!cm->use_cnt) {
|
} else if (!cm->use_count) {
|
||||||
PrintWarn("Unused label %s\n",cm->str);
|
PrintWarn("Unused label %s\n",cm->str);
|
||||||
LexWarn(cc,"Unused label at ");
|
LexWarn(cc,"Unused label at ");
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@ CHashClass *ParseClass(CCompCtrl *cc,I64 keyword,I64 fsp_flags,Bool is_extern)
|
|||||||
if (tmpc) {
|
if (tmpc) {
|
||||||
if (!Bt(&tmpc->flags,Cf_EXTERN))
|
if (!Bt(&tmpc->flags,Cf_EXTERN))
|
||||||
tmpc=NULL;
|
tmpc=NULL;
|
||||||
else if (tmpc->use_cnt<3)
|
else if (tmpc->use_count<3)
|
||||||
UnusedExternWarning(cc,tmpc);
|
UnusedExternWarning(cc,tmpc);
|
||||||
}
|
}
|
||||||
if (tmpc) {
|
if (tmpc) {
|
||||||
@ -36,7 +36,7 @@ CHashClass *ParseClass(CCompCtrl *cc,I64 keyword,I64 fsp_flags,Bool is_extern)
|
|||||||
LBtr(&tmpc->flags,Cf_EXTERN);
|
LBtr(&tmpc->flags,Cf_EXTERN);
|
||||||
if (fsp_flags&FSF_PUBLIC)
|
if (fsp_flags&FSF_PUBLIC)
|
||||||
tmpc->type|=HTF_PUBLIC;
|
tmpc->type|=HTF_PUBLIC;
|
||||||
tmpc->use_cnt=0;
|
tmpc->use_count=0;
|
||||||
if (cc->last_U16=='\n')
|
if (cc->last_U16=='\n')
|
||||||
HashSrcFileSet(cc,tmpc,-1);
|
HashSrcFileSet(cc,tmpc,-1);
|
||||||
else
|
else
|
||||||
@ -66,7 +66,7 @@ CHashFun *ParseFunJoin(CCompCtrl *cc,CHashClass *tmp_return,
|
|||||||
CAOTCtrl *aotc=cc->aotc;
|
CAOTCtrl *aotc=cc->aotc;
|
||||||
CHashClass *header_return;
|
CHashClass *header_return;
|
||||||
CHashFun *tmpf;
|
CHashFun *tmpf;
|
||||||
I64 header_arg_cnt;
|
I64 header_arg_count;
|
||||||
if (name) {//if not fun_ptr
|
if (name) {//if not fun_ptr
|
||||||
if (cc->flags&CCF_AOT_COMPILE) {
|
if (cc->flags&CCF_AOT_COMPILE) {
|
||||||
if ((tmpf=HashFind(name,cc->htc.glbl_hash_table,HTT_FUN)) &&
|
if ((tmpf=HashFind(name,cc->htc.glbl_hash_table,HTT_FUN)) &&
|
||||||
@ -76,7 +76,7 @@ CHashFun *ParseFunJoin(CCompCtrl *cc,CHashClass *tmp_return,
|
|||||||
if ((tmpf=HashSingleTableFind(name,cc->htc.glbl_hash_table,HTT_FUN)) &&
|
if ((tmpf=HashSingleTableFind(name,cc->htc.glbl_hash_table,HTT_FUN)) &&
|
||||||
!Bt(&tmpf->flags,Cf_EXTERN))
|
!Bt(&tmpf->flags,Cf_EXTERN))
|
||||||
tmpf=NULL;
|
tmpf=NULL;
|
||||||
if (tmpf && tmpf->use_cnt<3)
|
if (tmpf && tmpf->use_count<3)
|
||||||
UnusedExternWarning(cc,tmpf);
|
UnusedExternWarning(cc,tmpf);
|
||||||
} else
|
} else
|
||||||
tmpf=NULL;
|
tmpf=NULL;
|
||||||
@ -87,7 +87,7 @@ CHashFun *ParseFunJoin(CCompCtrl *cc,CHashClass *tmp_return,
|
|||||||
Free(tmpf->idx);
|
Free(tmpf->idx);
|
||||||
tmpf->idx=NULL;
|
tmpf->idx=NULL;
|
||||||
Free(name);
|
Free(name);
|
||||||
header_arg_cnt=tmpf->arg_cnt;
|
header_arg_count=tmpf->arg_count;
|
||||||
header_lst=tmpf->member_lst_and_root;
|
header_lst=tmpf->member_lst_and_root;
|
||||||
header_return=tmpf->return_class;
|
header_return=tmpf->return_class;
|
||||||
tmpf->member_lst_and_root=NULL;
|
tmpf->member_lst_and_root=NULL;
|
||||||
@ -109,11 +109,11 @@ CHashFun *ParseFunJoin(CCompCtrl *cc,CHashClass *tmp_return,
|
|||||||
}
|
}
|
||||||
BEqu(&tmpf->type,HTf_PUBLIC,fsp_flags&FSF_PUBLIC);
|
BEqu(&tmpf->type,HTf_PUBLIC,fsp_flags&FSF_PUBLIC);
|
||||||
tmpf->return_class=tmp_return;
|
tmpf->return_class=tmp_return;
|
||||||
tmpf->use_cnt=0;
|
tmpf->use_count=0;
|
||||||
HashSrcFileSet(cc,tmpf);
|
HashSrcFileSet(cc,tmpf);
|
||||||
ParseVarLst(cc,tmpf,PRS0_NULL|PRS1_FUN_ARG);
|
ParseVarLst(cc,tmpf,PRS0_NULL|PRS1_FUN_ARG);
|
||||||
tmpf->arg_cnt=tmpf->member_cnt;
|
tmpf->arg_count=tmpf->member_count;
|
||||||
if (0<tmpf->arg_cnt<<3<=I16_MAX && !Bt(&tmpf->flags,Ff_DOT_DOT_DOT))
|
if (0<tmpf->arg_count<<3<=I16_MAX && !Bt(&tmpf->flags,Ff_DOT_DOT_DOT))
|
||||||
LBts(&tmpf->flags,Ff_RET1);
|
LBts(&tmpf->flags,Ff_RET1);
|
||||||
tmpm=tmpf->member_lst_and_root;
|
tmpm=tmpf->member_lst_and_root;
|
||||||
while (tmpm) {
|
while (tmpm) {
|
||||||
@ -125,11 +125,11 @@ CHashFun *ParseFunJoin(CCompCtrl *cc,CHashClass *tmp_return,
|
|||||||
if (GetOption(OPTf_WARN_HEADER_MISMATCH)) {
|
if (GetOption(OPTf_WARN_HEADER_MISMATCH)) {
|
||||||
if (tmpf->return_class!=header_return) {
|
if (tmpf->return_class!=header_return) {
|
||||||
PrintWarn("Fun Header return mismatch '%s'\n",tmpf->str);
|
PrintWarn("Fun Header return mismatch '%s'\n",tmpf->str);
|
||||||
cc->warning_cnt++;
|
cc->warning_count++;
|
||||||
}
|
}
|
||||||
if (!MemberLstCmp(tmpf->member_lst_and_root,header_lst,header_arg_cnt)) {
|
if (!MemberLstCmp(tmpf->member_lst_and_root,header_lst,header_arg_count)) {
|
||||||
PrintWarn("Fun header args mismatch '%s'\n",tmpf->str);
|
PrintWarn("Fun header args mismatch '%s'\n",tmpf->str);
|
||||||
cc->warning_cnt++;
|
cc->warning_count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
MemberLstDel(header_lst);
|
MemberLstDel(header_lst);
|
||||||
@ -193,11 +193,11 @@ U0 ParseFun(CCompCtrl *cc,CHashClass *tmp_return,U8 *name,I64 fsp_flags)
|
|||||||
tmpm=cc->htc.fun->member_lst_and_root;
|
tmpm=cc->htc.fun->member_lst_and_root;
|
||||||
while (tmpm) {
|
while (tmpm) {
|
||||||
if (tmpm->flags & MLF_NO_UNUSED_WARN) {
|
if (tmpm->flags & MLF_NO_UNUSED_WARN) {
|
||||||
if (tmpm->use_cnt>1&&StrCmp(tmpm->str,"_anon_"))
|
if (tmpm->use_count>1&&StrCmp(tmpm->str,"_anon_"))
|
||||||
PrintWarn("Unneeded no_warn\n $$LK,\"FL:%s,%d\"$$'%s' in '%s'\n",
|
PrintWarn("Unneeded no_warn\n $$LK,\"FL:%s,%d\"$$'%s' in '%s'\n",
|
||||||
cc->lex_include_stk->full_name,cc->lex_include_stk->line_num,
|
cc->lex_include_stk->full_name,cc->lex_include_stk->line_num,
|
||||||
tmpm->str,cc->htc.fun->str);
|
tmpm->str,cc->htc.fun->str);
|
||||||
} else if (!tmpm->use_cnt && GetOption(OPTf_WARN_UNUSED_VAR))
|
} else if (!tmpm->use_count && GetOption(OPTf_WARN_UNUSED_VAR))
|
||||||
PrintWarn("Unused var\n $$LK,\"FL:%s,%d\"$$'%s' in '%s'\n",
|
PrintWarn("Unused var\n $$LK,\"FL:%s,%d\"$$'%s' in '%s'\n",
|
||||||
cc->lex_include_stk->full_name,cc->lex_include_stk->line_num,
|
cc->lex_include_stk->full_name,cc->lex_include_stk->line_num,
|
||||||
tmpm->str,cc->htc.fun->str);
|
tmpm->str,cc->htc.fun->str);
|
||||||
@ -226,7 +226,7 @@ U0 ParseGlobalVarLst(CCompCtrl *cc,I64 saved_mode,CHashClass *saved_tmpc,
|
|||||||
if (!st) return;
|
if (!st) return;
|
||||||
if (tmpad.next)
|
if (tmpad.next)
|
||||||
is_array=TRUE;
|
is_array=TRUE;
|
||||||
else if (tmpad.total_cnt<0) {
|
else if (tmpad.total_count<0) {
|
||||||
is_array=TRUE;
|
is_array=TRUE;
|
||||||
tmpc--;
|
tmpc--;
|
||||||
} else
|
} else
|
||||||
@ -282,11 +282,11 @@ U0 ParseGlobalVarLst(CCompCtrl *cc,I64 saved_mode,CHashClass *saved_tmpc,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (tmpad.total_cnt<0) {
|
if (tmpad.total_count<0) {
|
||||||
i=0;
|
i=0;
|
||||||
undef_array_size=TRUE;
|
undef_array_size=TRUE;
|
||||||
} else {
|
} else {
|
||||||
i=tmpad.total_cnt;
|
i=tmpad.total_count;
|
||||||
undef_array_size=FALSE;
|
undef_array_size=FALSE;
|
||||||
}
|
}
|
||||||
if (tmpf_fun_ptr)
|
if (tmpf_fun_ptr)
|
||||||
@ -390,8 +390,8 @@ U0 ParseGlobalVarLst(CCompCtrl *cc,I64 saved_mode,CHashClass *saved_tmpc,
|
|||||||
tmpg->var_class=tmpc;
|
tmpg->var_class=tmpc;
|
||||||
tmpg->str=st;
|
tmpg->str=st;
|
||||||
tmpg->size=j;
|
tmpg->size=j;
|
||||||
tmpg->dim.total_cnt=i;
|
tmpg->dim.total_count=i;
|
||||||
tmpg->use_cnt=0;
|
tmpg->use_count=0;
|
||||||
if (cc->last_U16=='\n')
|
if (cc->last_U16=='\n')
|
||||||
HashSrcFileSet(cc,tmpg,-1);
|
HashSrcFileSet(cc,tmpg,-1);
|
||||||
else
|
else
|
||||||
@ -416,7 +416,7 @@ U0 ParseGlobalVarLst(CCompCtrl *cc,I64 saved_mode,CHashClass *saved_tmpc,
|
|||||||
Lex(cc);
|
Lex(cc);
|
||||||
ParseGlobalInit(cc,tmpg,1);
|
ParseGlobalInit(cc,tmpg,1);
|
||||||
LexPopNoRestore(cc);
|
LexPopNoRestore(cc);
|
||||||
tmpg->size=tmpg->dim.total_cnt*tmpc->size;
|
tmpg->size=tmpg->dim.total_count*tmpc->size;
|
||||||
if (tmphg)
|
if (tmphg)
|
||||||
tmphg->size=tmpg->size;
|
tmphg->size=tmpg->size;
|
||||||
if (cc->flags&CCF_AOT_COMPILE)
|
if (cc->flags&CCF_AOT_COMPILE)
|
||||||
@ -436,9 +436,9 @@ U0 ParseGlobalVarLst(CCompCtrl *cc,I64 saved_mode,CHashClass *saved_tmpc,
|
|||||||
LexPopNoRestore(cc);
|
LexPopNoRestore(cc);
|
||||||
}
|
}
|
||||||
if (has_alias) {
|
if (has_alias) {
|
||||||
if (tmpex(CHashGlobalVar *)->use_cnt<2) {
|
if (tmpex(CHashGlobalVar *)->use_count<2) {
|
||||||
PrintWarn("Unused extern '%s'\n",tmpex(CHashGlobalVar *)->str);
|
PrintWarn("Unused extern '%s'\n",tmpex(CHashGlobalVar *)->str);
|
||||||
cc->warning_cnt++;
|
cc->warning_count++;
|
||||||
}
|
}
|
||||||
tmpex(CHashGlobalVar *)->flags|=GVF_ALIAS;
|
tmpex(CHashGlobalVar *)->flags|=GVF_ALIAS;
|
||||||
tmpex(CHashGlobalVar *)->data_addr=tmpg->data_addr;
|
tmpex(CHashGlobalVar *)->data_addr=tmpg->data_addr;
|
||||||
@ -456,7 +456,7 @@ U0 ParseGlobalVarLst(CCompCtrl *cc,I64 saved_mode,CHashClass *saved_tmpc,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
U0 ParseIf(CCompCtrl *cc,I64 try_cnt,CCodeMisc *lb_break)
|
U0 ParseIf(CCompCtrl *cc,I64 try_count,CCodeMisc *lb_break)
|
||||||
{
|
{
|
||||||
CCodeMisc *lb,*lb1;
|
CCodeMisc *lb,*lb1;
|
||||||
I64 k;
|
I64 k;
|
||||||
@ -470,20 +470,20 @@ U0 ParseIf(CCompCtrl *cc,I64 try_cnt,CCodeMisc *lb_break)
|
|||||||
Lex(cc);
|
Lex(cc);
|
||||||
lb=COCMiscNew(cc,CMT_LABEL);
|
lb=COCMiscNew(cc,CMT_LABEL);
|
||||||
ICAdd(cc,IC_BR_ZERO,lb,0);
|
ICAdd(cc,IC_BR_ZERO,lb,0);
|
||||||
ParseStatement(cc,try_cnt,lb_break);
|
ParseStatement(cc,try_count,lb_break);
|
||||||
k=ParseKeyWord(cc);
|
k=ParseKeyWord(cc);
|
||||||
if (k==KW_ELSE) {
|
if (k==KW_ELSE) {
|
||||||
Lex(cc);
|
Lex(cc);
|
||||||
lb1=COCMiscNew(cc,CMT_LABEL);
|
lb1=COCMiscNew(cc,CMT_LABEL);
|
||||||
ICAdd(cc,IC_JMP,lb1,0);
|
ICAdd(cc,IC_JMP,lb1,0);
|
||||||
ICAdd(cc,IC_LABEL,lb,0);
|
ICAdd(cc,IC_LABEL,lb,0);
|
||||||
ParseStatement(cc,try_cnt,lb_break);
|
ParseStatement(cc,try_count,lb_break);
|
||||||
ICAdd(cc,IC_LABEL,lb1,0);
|
ICAdd(cc,IC_LABEL,lb1,0);
|
||||||
} else
|
} else
|
||||||
ICAdd(cc,IC_LABEL,lb,0);
|
ICAdd(cc,IC_LABEL,lb,0);
|
||||||
}
|
}
|
||||||
|
|
||||||
U0 ParseWhile(CCompCtrl *cc,I64 try_cnt)
|
U0 ParseWhile(CCompCtrl *cc,I64 try_count)
|
||||||
{
|
{
|
||||||
CCodeMisc *lb,*lb_done;
|
CCodeMisc *lb,*lb_done;
|
||||||
if (cc->token!='(')
|
if (cc->token!='(')
|
||||||
@ -498,18 +498,18 @@ U0 ParseWhile(CCompCtrl *cc,I64 try_cnt)
|
|||||||
Lex(cc);
|
Lex(cc);
|
||||||
lb_done=COCMiscNew(cc,CMT_LABEL);
|
lb_done=COCMiscNew(cc,CMT_LABEL);
|
||||||
ICAdd(cc,IC_BR_ZERO,lb_done,0);
|
ICAdd(cc,IC_BR_ZERO,lb_done,0);
|
||||||
ParseStatement(cc,try_cnt,lb_done);
|
ParseStatement(cc,try_count,lb_done);
|
||||||
ICAdd(cc,IC_JMP,lb,0);
|
ICAdd(cc,IC_JMP,lb,0);
|
||||||
ICAdd(cc,IC_LABEL,lb_done,0);
|
ICAdd(cc,IC_LABEL,lb_done,0);
|
||||||
}
|
}
|
||||||
|
|
||||||
U0 ParseDoWhile(CCompCtrl *cc,I64 try_cnt)
|
U0 ParseDoWhile(CCompCtrl *cc,I64 try_count)
|
||||||
{
|
{
|
||||||
CCodeMisc *lb,*lb_done;
|
CCodeMisc *lb,*lb_done;
|
||||||
lb=COCMiscNew(cc,CMT_LABEL);
|
lb=COCMiscNew(cc,CMT_LABEL);
|
||||||
lb_done=COCMiscNew(cc,CMT_LABEL);
|
lb_done=COCMiscNew(cc,CMT_LABEL);
|
||||||
ICAdd(cc,IC_LABEL,lb,0);
|
ICAdd(cc,IC_LABEL,lb,0);
|
||||||
ParseStatement(cc,try_cnt,lb_done);
|
ParseStatement(cc,try_count,lb_done);
|
||||||
if (ParseKeyWord(cc)!=KW_WHILE)
|
if (ParseKeyWord(cc)!=KW_WHILE)
|
||||||
LexExcept(cc,"Missing 'while' at");
|
LexExcept(cc,"Missing 'while' at");
|
||||||
if (Lex(cc)!='(')
|
if (Lex(cc)!='(')
|
||||||
@ -526,7 +526,7 @@ U0 ParseDoWhile(CCompCtrl *cc,I64 try_cnt)
|
|||||||
Lex(cc);
|
Lex(cc);
|
||||||
}
|
}
|
||||||
|
|
||||||
U0 ParseFor(CCompCtrl *cc,I64 try_cnt)
|
U0 ParseFor(CCompCtrl *cc,I64 try_count)
|
||||||
{
|
{
|
||||||
CCodeCtrl *tmpcbh;
|
CCodeCtrl *tmpcbh;
|
||||||
CCodeMisc *lb,*lb_done;
|
CCodeMisc *lb,*lb_done;
|
||||||
@ -534,7 +534,7 @@ U0 ParseFor(CCompCtrl *cc,I64 try_cnt)
|
|||||||
if (cc->token!='(')
|
if (cc->token!='(')
|
||||||
LexExcept(cc,"Expecting '(' at ");
|
LexExcept(cc,"Expecting '(' at ");
|
||||||
Lex(cc);
|
Lex(cc);
|
||||||
ParseStatement(cc,try_cnt);
|
ParseStatement(cc,try_count);
|
||||||
|
|
||||||
lb=COCMiscNew(cc,CMT_LABEL);
|
lb=COCMiscNew(cc,CMT_LABEL);
|
||||||
ICAdd(cc,IC_LABEL,lb,0);
|
ICAdd(cc,IC_LABEL,lb,0);
|
||||||
@ -549,7 +549,7 @@ U0 ParseFor(CCompCtrl *cc,I64 try_cnt)
|
|||||||
COCPush(cc);
|
COCPush(cc);
|
||||||
COCInit(cc);
|
COCInit(cc);
|
||||||
if (cc->token!=')')
|
if (cc->token!=')')
|
||||||
ParseStatement(cc,try_cnt,NULL,0);
|
ParseStatement(cc,try_count,NULL,0);
|
||||||
COCPush(cc);
|
COCPush(cc);
|
||||||
tmpcbh=COCPopNoFree(cc);
|
tmpcbh=COCPopNoFree(cc);
|
||||||
COCPop(cc);
|
COCPop(cc);
|
||||||
@ -557,7 +557,7 @@ U0 ParseFor(CCompCtrl *cc,I64 try_cnt)
|
|||||||
LexExcept(cc,"Missing ')' at ");
|
LexExcept(cc,"Missing ')' at ");
|
||||||
Lex(cc);
|
Lex(cc);
|
||||||
|
|
||||||
ParseStatement(cc,try_cnt,lb_done);
|
ParseStatement(cc,try_count,lb_done);
|
||||||
COCAppend(cc,tmpcbh);
|
COCAppend(cc,tmpcbh);
|
||||||
ICAdd(cc,IC_JMP,lb,0);
|
ICAdd(cc,IC_JMP,lb,0);
|
||||||
ICAdd(cc,IC_LABEL,lb_done,0);
|
ICAdd(cc,IC_LABEL,lb_done,0);
|
||||||
@ -575,7 +575,7 @@ class CSwitchCase {
|
|||||||
CSubSwitch *ss;
|
CSubSwitch *ss;
|
||||||
};
|
};
|
||||||
|
|
||||||
U0 ParseSwitch(CCompCtrl *cc,I64 try_cnt)
|
U0 ParseSwitch(CCompCtrl *cc,I64 try_count)
|
||||||
{
|
{
|
||||||
CSwitchCase *header=NULL,*tmps,*tmps1; //Leaks on except
|
CSwitchCase *header=NULL,*tmps,*tmps1; //Leaks on except
|
||||||
CSubSwitch head,*tmpss; //Leaks on except
|
CSubSwitch head,*tmpss; //Leaks on except
|
||||||
@ -594,12 +594,12 @@ U0 ParseSwitch(CCompCtrl *cc,I64 try_cnt)
|
|||||||
QueueInit(&head);
|
QueueInit(&head);
|
||||||
|
|
||||||
head.last->lb_break=COCMiscNew(cc,CMT_LABEL);
|
head.last->lb_break=COCMiscNew(cc,CMT_LABEL);
|
||||||
head.last->lb_break->use_cnt++;
|
head.last->lb_break->use_count++;
|
||||||
lb_dft=COCMiscNew(cc,CMT_LABEL);
|
lb_dft=COCMiscNew(cc,CMT_LABEL);
|
||||||
lb_dft->use_cnt++;
|
lb_dft->use_count++;
|
||||||
mc_jt=COCMiscNew(cc,CMT_JMP_TABLE);
|
mc_jt=COCMiscNew(cc,CMT_JMP_TABLE);
|
||||||
mc_jt->begin=COCMiscNew(cc,CMT_LABEL);
|
mc_jt->begin=COCMiscNew(cc,CMT_LABEL);
|
||||||
mc_jt->begin->use_cnt++;
|
mc_jt->begin->use_count++;
|
||||||
if (!ParseExpression(cc,NULL,FALSE))
|
if (!ParseExpression(cc,NULL,FALSE))
|
||||||
throw('Compiler');
|
throw('Compiler');
|
||||||
tmpi_sub=ICAdd(cc,IC_IMM_I64,0,cmp.internal_types[RT_I64]);
|
tmpi_sub=ICAdd(cc,IC_IMM_I64,0,cmp.internal_types[RT_I64]);
|
||||||
@ -632,7 +632,7 @@ sw_cont:
|
|||||||
tmpss=MAlloc(sizeof(CSubSwitch));
|
tmpss=MAlloc(sizeof(CSubSwitch));
|
||||||
QueueInsert(tmpss,head.last);
|
QueueInsert(tmpss,head.last);
|
||||||
head.last->lb_break=COCMiscNew(cc,CMT_LABEL);
|
head.last->lb_break=COCMiscNew(cc,CMT_LABEL);
|
||||||
head.last->lb_break->use_cnt++;
|
head.last->lb_break->use_count++;
|
||||||
lb_fwd_case=COCMiscNew(cc,CMT_LABEL);
|
lb_fwd_case=COCMiscNew(cc,CMT_LABEL);
|
||||||
tmpi_jmp=ICAdd(cc,IC_JMP,lb_fwd_case,0);
|
tmpi_jmp=ICAdd(cc,IC_JMP,lb_fwd_case,0);
|
||||||
|
|
||||||
@ -656,7 +656,7 @@ sw_cont:
|
|||||||
}
|
}
|
||||||
goto sw_cont;
|
goto sw_cont;
|
||||||
default:
|
default:
|
||||||
ParseStatement(cc,try_cnt);
|
ParseStatement(cc,try_count);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -668,7 +668,7 @@ sw_cont:
|
|||||||
Lex(cc);
|
Lex(cc);
|
||||||
lb_entry=COCMiscNew(cc,CMT_LABEL);
|
lb_entry=COCMiscNew(cc,CMT_LABEL);
|
||||||
ICAdd(cc,IC_LABEL,lb_entry,0);
|
ICAdd(cc,IC_LABEL,lb_entry,0);
|
||||||
lb_entry->use_cnt++;
|
lb_entry->use_count++;
|
||||||
if (head.next!=&head) {
|
if (head.next!=&head) {
|
||||||
tmpss=head.next;
|
tmpss=head.next;
|
||||||
while (tmpss!=&head) {
|
while (tmpss!=&head) {
|
||||||
@ -739,7 +739,7 @@ sw_cont:
|
|||||||
dft_found=TRUE;
|
dft_found=TRUE;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ParseStatement(cc,try_cnt,head.last->lb_break);
|
ParseStatement(cc,try_count,head.last->lb_break);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sw_sub_end:
|
sw_sub_end:
|
||||||
@ -839,7 +839,7 @@ U0 ParseStreamBlk(CCompCtrl *cc)
|
|||||||
Lex(cc); //Skip '}'
|
Lex(cc); //Skip '}'
|
||||||
}
|
}
|
||||||
|
|
||||||
U0 ParseTryBlk(CCompCtrl *cc,I64 try_cnt)
|
U0 ParseTryBlk(CCompCtrl *cc,I64 try_count)
|
||||||
{
|
{
|
||||||
CCodeMisc *lb_catch,*lb_done,*lb_untry;
|
CCodeMisc *lb_catch,*lb_done,*lb_untry;
|
||||||
CHashClass *tmpc=cmp.internal_types[RT_PTR];
|
CHashClass *tmpc=cmp.internal_types[RT_PTR];
|
||||||
@ -859,7 +859,7 @@ U0 ParseTryBlk(CCompCtrl *cc,I64 try_cnt)
|
|||||||
ICAdd(cc,IC_GET_LABEL,lb_untry,tmpc,ICF_PUSH_RES);
|
ICAdd(cc,IC_GET_LABEL,lb_untry,tmpc,ICF_PUSH_RES);
|
||||||
ICAdd(cc,IC_GET_LABEL,lb_catch,tmpc,ICF_PUSH_RES);
|
ICAdd(cc,IC_GET_LABEL,lb_catch,tmpc,ICF_PUSH_RES);
|
||||||
if (Bt(&tmp_try->flags,Cf_EXTERN)) {
|
if (Bt(&tmp_try->flags,Cf_EXTERN)) {
|
||||||
cc->abs_cnts.externs++;
|
cc->abs_counts.externs++;
|
||||||
if (cc->flags&CCF_AOT_COMPILE)
|
if (cc->flags&CCF_AOT_COMPILE)
|
||||||
ICAdd(cc,IC_CALL_IMPORT,tmp_try,tmpc);
|
ICAdd(cc,IC_CALL_IMPORT,tmp_try,tmpc);
|
||||||
else
|
else
|
||||||
@ -874,12 +874,12 @@ U0 ParseTryBlk(CCompCtrl *cc,I64 try_cnt)
|
|||||||
ICAdd(cc,IC_CALL_END,0,tmpc);
|
ICAdd(cc,IC_CALL_END,0,tmpc);
|
||||||
ICAdd(cc,IC_END_EXP,0,0,ICF_RES_NOT_USED);
|
ICAdd(cc,IC_END_EXP,0,0,ICF_RES_NOT_USED);
|
||||||
|
|
||||||
ParseStatement(cc,try_cnt+1);
|
ParseStatement(cc,try_count+1);
|
||||||
|
|
||||||
ICAdd(cc,IC_LABEL,lb_untry,0);
|
ICAdd(cc,IC_LABEL,lb_untry,0);
|
||||||
ICAdd(cc,IC_CALL_START,0,0);
|
ICAdd(cc,IC_CALL_START,0,0);
|
||||||
if (Bt(&tmp_untry->flags,Cf_EXTERN)) {
|
if (Bt(&tmp_untry->flags,Cf_EXTERN)) {
|
||||||
cc->abs_cnts.externs++;
|
cc->abs_counts.externs++;
|
||||||
if (cc->flags&CCF_AOT_COMPILE)
|
if (cc->flags&CCF_AOT_COMPILE)
|
||||||
ICAdd(cc,IC_CALL_IMPORT,tmp_untry,tmpc);
|
ICAdd(cc,IC_CALL_IMPORT,tmp_untry,tmpc);
|
||||||
else
|
else
|
||||||
@ -896,12 +896,12 @@ U0 ParseTryBlk(CCompCtrl *cc,I64 try_cnt)
|
|||||||
|
|
||||||
Lex(cc);
|
Lex(cc);
|
||||||
ICAdd(cc,IC_LABEL,lb_catch,0);
|
ICAdd(cc,IC_LABEL,lb_catch,0);
|
||||||
ParseStatement(cc,try_cnt+1);
|
ParseStatement(cc,try_count+1);
|
||||||
ICAdd(cc,IC_RET,0,tmpc);
|
ICAdd(cc,IC_RET,0,tmpc);
|
||||||
ICAdd(cc,IC_LABEL,lb_done,0);
|
ICAdd(cc,IC_LABEL,lb_done,0);
|
||||||
}
|
}
|
||||||
|
|
||||||
Bool ParseStatement(CCompCtrl *cc,I64 try_cnt=0,
|
Bool ParseStatement(CCompCtrl *cc,I64 try_count=0,
|
||||||
CCodeMisc *lb_break=NULL,I64 cmp_flags=CMPF_PRS_SEMICOLON)
|
CCodeMisc *lb_break=NULL,I64 cmp_flags=CMPF_PRS_SEMICOLON)
|
||||||
{
|
{
|
||||||
I64 i,fsp_flags=0;
|
I64 i,fsp_flags=0;
|
||||||
@ -923,7 +923,7 @@ Bool ParseStatement(CCompCtrl *cc,I64 try_cnt=0,
|
|||||||
if (cc->token=='{') {
|
if (cc->token=='{') {
|
||||||
Lex(cc);
|
Lex(cc);
|
||||||
while (cc->token!='}' && cc->token!=TK_EOF)
|
while (cc->token!='}' && cc->token!=TK_EOF)
|
||||||
ParseStatement(cc,try_cnt,lb_break);
|
ParseStatement(cc,try_count,lb_break);
|
||||||
if (cc->lex_include_stk==cc->fun_lex_file)
|
if (cc->lex_include_stk==cc->fun_lex_file)
|
||||||
cc->max_line=cc->lex_include_stk->line_num;
|
cc->max_line=cc->lex_include_stk->line_num;
|
||||||
if (Lex(cc)!=',') goto sm_done;
|
if (Lex(cc)!=',') goto sm_done;
|
||||||
@ -963,27 +963,27 @@ Bool ParseStatement(CCompCtrl *cc,I64 try_cnt=0,
|
|||||||
start:
|
start:
|
||||||
Lex(cc);
|
Lex(cc);
|
||||||
case KW_LOCK:
|
case KW_LOCK:
|
||||||
cc->lock_cnt++;
|
cc->lock_count++;
|
||||||
ParseStatement(cc,try_cnt);
|
ParseStatement(cc,try_count);
|
||||||
cc->lock_cnt--;
|
cc->lock_count--;
|
||||||
break;
|
break;
|
||||||
case KW_TRY:
|
case KW_TRY:
|
||||||
ParseTryBlk(cc,try_cnt);
|
ParseTryBlk(cc,try_count);
|
||||||
break;
|
break;
|
||||||
case KW_IF:
|
case KW_IF:
|
||||||
ParseIf(cc,try_cnt,lb_break);
|
ParseIf(cc,try_count,lb_break);
|
||||||
break;
|
break;
|
||||||
case KW_FOR:
|
case KW_FOR:
|
||||||
ParseFor(cc,try_cnt);
|
ParseFor(cc,try_count);
|
||||||
break;
|
break;
|
||||||
case KW_WHILE:
|
case KW_WHILE:
|
||||||
ParseWhile(cc,try_cnt);
|
ParseWhile(cc,try_count);
|
||||||
break;
|
break;
|
||||||
case KW_DO:
|
case KW_DO:
|
||||||
ParseDoWhile(cc,try_cnt);
|
ParseDoWhile(cc,try_count);
|
||||||
break;
|
break;
|
||||||
case KW_SWITCH:
|
case KW_SWITCH:
|
||||||
ParseSwitch(cc,try_cnt);
|
ParseSwitch(cc,try_count);
|
||||||
break;
|
break;
|
||||||
end:
|
end:
|
||||||
end:
|
end:
|
||||||
@ -1089,12 +1089,12 @@ sm_import:
|
|||||||
case KW_RETURN:
|
case KW_RETURN:
|
||||||
if (!cc->htc.fun)
|
if (!cc->htc.fun)
|
||||||
LexExcept(cc,"Not in fun. Can't return a val ");
|
LexExcept(cc,"Not in fun. Can't return a val ");
|
||||||
if (try_cnt) {
|
if (try_count) {
|
||||||
tmp_untry=HashFind("SysUntry",
|
tmp_untry=HashFind("SysUntry",
|
||||||
cc->htc.hash_table_lst,HTT_FUN);
|
cc->htc.hash_table_lst,HTT_FUN);
|
||||||
for (i=0;i<try_cnt;i++) {
|
for (i=0;i<try_count;i++) {
|
||||||
if (Bt(&tmp_untry->flags,Cf_EXTERN)) {
|
if (Bt(&tmp_untry->flags,Cf_EXTERN)) {
|
||||||
cc->abs_cnts.externs++;
|
cc->abs_counts.externs++;
|
||||||
if (cc->flags&CCF_AOT_COMPILE)
|
if (cc->flags&CCF_AOT_COMPILE)
|
||||||
ICAdd(cc,IC_CALL_IMPORT,
|
ICAdd(cc,IC_CALL_IMPORT,
|
||||||
tmp_untry,cmp.internal_types[RT_PTR]);
|
tmp_untry,cmp.internal_types[RT_PTR]);
|
||||||
@ -1126,7 +1126,7 @@ sm_import:
|
|||||||
g_lb->str=cc->cur_str;
|
g_lb->str=cc->cur_str;
|
||||||
cc->cur_str=NULL;
|
cc->cur_str=NULL;
|
||||||
}
|
}
|
||||||
g_lb->use_cnt++;
|
g_lb->use_count++;
|
||||||
ICAdd(cc,IC_JMP,g_lb,0);
|
ICAdd(cc,IC_JMP,g_lb,0);
|
||||||
Lex(cc);
|
Lex(cc);
|
||||||
goto sm_semicolon;
|
goto sm_semicolon;
|
||||||
|
@ -29,7 +29,7 @@ U0 ParseVarInit(CCompCtrl *cc,U8 **_dst,CHashClass *tmpc,CArrayDim *tmpad,
|
|||||||
LexExcept(cc,"Missing '}' at ");
|
LexExcept(cc,"Missing '}' at ");
|
||||||
Lex(cc);
|
Lex(cc);
|
||||||
} else {
|
} else {
|
||||||
if (tmpc->ptr_stars_cnt==1 &&
|
if (tmpc->ptr_stars_count==1 &&
|
||||||
((tmpc-1)->raw_type==RT_I8 || (tmpc-1)->raw_type==RT_U8) &&
|
((tmpc-1)->raw_type==RT_I8 || (tmpc-1)->raw_type==RT_U8) &&
|
||||||
!tmpad && cc->token==TK_STR)
|
!tmpad && cc->token==TK_STR)
|
||||||
is_str=TRUE;
|
is_str=TRUE;
|
||||||
@ -123,20 +123,20 @@ class CVI2
|
|||||||
U0 ParseVarInit2(CCompCtrl *cc,U8 **_dst,CHashClass *tmpc,
|
U0 ParseVarInit2(CCompCtrl *cc,U8 **_dst,CHashClass *tmpc,
|
||||||
CArrayDim *tmpad,U8 *data_addr_rip,U8 **_base,Bool data_heap,I64 pass)
|
CArrayDim *tmpad,U8 *data_addr_rip,U8 **_base,Bool data_heap,I64 pass)
|
||||||
{
|
{
|
||||||
I64 i,j,cnt;
|
I64 i,j,count;
|
||||||
U8 *st,*_b;
|
U8 *st,*_b;
|
||||||
CVI2 head,*tmpvi,*tmpvi1;
|
CVI2 head,*tmpvi,*tmpvi1;
|
||||||
CArrayDim *tmpad1;
|
CArrayDim *tmpad1;
|
||||||
tmpc=OptClassFwd(tmpc);
|
tmpc=OptClassFwd(tmpc);
|
||||||
if (tmpad1=tmpad->next) {
|
if (tmpad1=tmpad->next) {
|
||||||
if (!tmpc->ptr_stars_cnt &&
|
if (!tmpc->ptr_stars_count &&
|
||||||
(tmpc->raw_type==RT_I8 || tmpc->raw_type==RT_U8) &&
|
(tmpc->raw_type==RT_I8 || tmpc->raw_type==RT_U8) &&
|
||||||
cc->token==TK_STR) {
|
cc->token==TK_STR) {
|
||||||
LexPopNoRestore(cc);
|
LexPopNoRestore(cc);
|
||||||
st=LexExtStr(cc,&i);
|
st=LexExtStr(cc,&i);
|
||||||
if (tmpad1->cnt<0) {//[]
|
if (tmpad1->count<0) {//[]
|
||||||
tmpad1->cnt=i;
|
tmpad1->count=i;
|
||||||
tmpad->total_cnt=i*tmpad1->total_cnt;
|
tmpad->total_count=i*tmpad1->total_count;
|
||||||
Free(*_base);
|
Free(*_base);
|
||||||
if (data_heap)
|
if (data_heap)
|
||||||
*_base=MAlloc(i);
|
*_base=MAlloc(i);
|
||||||
@ -145,8 +145,8 @@ U0 ParseVarInit2(CCompCtrl *cc,U8 **_dst,CHashClass *tmpc,
|
|||||||
MemCpy(*_base,st,i);
|
MemCpy(*_base,st,i);
|
||||||
*_dst=*_base+i;
|
*_dst=*_base+i;
|
||||||
} else {
|
} else {
|
||||||
MemCpy(*_dst,st,tmpad1->cnt);
|
MemCpy(*_dst,st,tmpad1->count);
|
||||||
*_dst+=tmpad1->cnt;
|
*_dst+=tmpad1->count;
|
||||||
}
|
}
|
||||||
Free(st);
|
Free(st);
|
||||||
LexPush(cc);
|
LexPush(cc);
|
||||||
@ -156,23 +156,23 @@ U0 ParseVarInit2(CCompCtrl *cc,U8 **_dst,CHashClass *tmpc,
|
|||||||
LexPush(cc);
|
LexPush(cc);
|
||||||
Lex(cc);
|
Lex(cc);
|
||||||
}
|
}
|
||||||
if (tmpad1->cnt<0) {//[]
|
if (tmpad1->count<0) {//[]
|
||||||
QueueInit(&head);
|
QueueInit(&head);
|
||||||
cnt=0;
|
count=0;
|
||||||
while (cc->token!='}') {
|
while (cc->token!='}') {
|
||||||
tmpvi=MAlloc(offset(CVI2.base)+tmpad1->total_cnt*tmpc->size);
|
tmpvi=MAlloc(offset(CVI2.base)+tmpad1->total_count*tmpc->size);
|
||||||
_b=&tmpvi->base;
|
_b=&tmpvi->base;
|
||||||
ParseVarInit2(cc,&_b,tmpc,tmpad1,data_addr_rip,_base,data_heap,pass);
|
ParseVarInit2(cc,&_b,tmpc,tmpad1,data_addr_rip,_base,data_heap,pass);
|
||||||
QueueInsert(tmpvi,head.last);
|
QueueInsert(tmpvi,head.last);
|
||||||
if (cc->token==',')
|
if (cc->token==',')
|
||||||
Lex(cc);
|
Lex(cc);
|
||||||
cnt++;
|
count++;
|
||||||
}
|
}
|
||||||
Lex(cc); //skip '}'
|
Lex(cc); //skip '}'
|
||||||
tmpad1->cnt=cnt;
|
tmpad1->count=count;
|
||||||
tmpad->total_cnt=cnt*tmpad1->total_cnt;
|
tmpad->total_count=count*tmpad1->total_count;
|
||||||
j=tmpad1->total_cnt*tmpc->size;
|
j=tmpad1->total_count*tmpc->size;
|
||||||
i=cnt*j;
|
i=count*j;
|
||||||
Free(*_base);
|
Free(*_base);
|
||||||
if (data_heap)
|
if (data_heap)
|
||||||
*_base=_b=MAlloc(i);
|
*_base=_b=MAlloc(i);
|
||||||
@ -188,9 +188,9 @@ U0 ParseVarInit2(CCompCtrl *cc,U8 **_dst,CHashClass *tmpc,
|
|||||||
}
|
}
|
||||||
*_dst=_b;
|
*_dst=_b;
|
||||||
} else {
|
} else {
|
||||||
for (i=0;i<tmpad1->cnt;i++) {
|
for (i=0;i<tmpad1->count;i++) {
|
||||||
ParseVarInit2(cc,_dst,tmpc,tmpad1,data_addr_rip,_base,data_heap,pass);
|
ParseVarInit2(cc,_dst,tmpc,tmpad1,data_addr_rip,_base,data_heap,pass);
|
||||||
if (tmpad1->cnt>1 && cc->token==',')
|
if (tmpad1->count>1 && cc->token==',')
|
||||||
Lex(cc);
|
Lex(cc);
|
||||||
}
|
}
|
||||||
if (cc->token=='}')
|
if (cc->token=='}')
|
||||||
@ -249,8 +249,8 @@ U0 ParseArrayDims(CCompCtrl *cc,I64 mode,CArrayDim *dim)
|
|||||||
CArrayDim *tmpad,*tmpad1;
|
CArrayDim *tmpad,*tmpad1;
|
||||||
I64 j;
|
I64 j;
|
||||||
dim->next=NULL;
|
dim->next=NULL;
|
||||||
dim->cnt=0;
|
dim->count=0;
|
||||||
dim->total_cnt=1;
|
dim->total_count=1;
|
||||||
tmpad1=&dim->next;
|
tmpad1=&dim->next;
|
||||||
if (cc->token=='[') {
|
if (cc->token=='[') {
|
||||||
if (mode.u8[1]==PRS1B_FUN_ARG)
|
if (mode.u8[1]==PRS1B_FUN_ARG)
|
||||||
@ -266,7 +266,7 @@ U0 ParseArrayDims(CCompCtrl *cc,I64 mode,CArrayDim *dim)
|
|||||||
tmpad->next=NULL;
|
tmpad->next=NULL;
|
||||||
tmpad1=&dim;
|
tmpad1=&dim;
|
||||||
do {
|
do {
|
||||||
tmpad1->total_cnt*=j;
|
tmpad1->total_count*=j;
|
||||||
if (!tmpad1->next) {
|
if (!tmpad1->next) {
|
||||||
tmpad1->next=tmpad;
|
tmpad1->next=tmpad;
|
||||||
break;
|
break;
|
||||||
@ -274,8 +274,8 @@ U0 ParseArrayDims(CCompCtrl *cc,I64 mode,CArrayDim *dim)
|
|||||||
tmpad1=tmpad1->next;
|
tmpad1=tmpad1->next;
|
||||||
} while (tmpad1);
|
} while (tmpad1);
|
||||||
tmpad1=tmpad;
|
tmpad1=tmpad;
|
||||||
tmpad->cnt=j;
|
tmpad->count=j;
|
||||||
tmpad->total_cnt=1;
|
tmpad->total_count=1;
|
||||||
if (cc->token!=']')
|
if (cc->token!=']')
|
||||||
LexExcept(cc,"Missing ']' at ");
|
LexExcept(cc,"Missing ']' at ");
|
||||||
} while (Lex(cc)=='[');
|
} while (Lex(cc)=='[');
|
||||||
@ -286,7 +286,7 @@ CHashClass *ParseType(CCompCtrl *cc,CHashClass **_tmpc1,
|
|||||||
I64 *_mode,CMemberLst *tmpm,U8 **_ident,CHashFun **_fun_ptr,
|
I64 *_mode,CMemberLst *tmpm,U8 **_ident,CHashFun **_fun_ptr,
|
||||||
CHashExport **_tmpex,CArrayDim *tmpad,I64 fsp_flags)
|
CHashExport **_tmpex,CArrayDim *tmpad,I64 fsp_flags)
|
||||||
{
|
{
|
||||||
I64 k,ptr_stars_cnt,mode=*_mode;
|
I64 k,ptr_stars_count,mode=*_mode;
|
||||||
CHashClass *tmpc1=*_tmpc1,*tmpc2;
|
CHashClass *tmpc1=*_tmpc1,*tmpc2;
|
||||||
CHashFun *fun_ptr=NULL;
|
CHashFun *fun_ptr=NULL;
|
||||||
CHashExport *tmpex=NULL;
|
CHashExport *tmpex=NULL;
|
||||||
@ -295,7 +295,7 @@ CHashClass *ParseType(CCompCtrl *cc,CHashClass **_tmpc1,
|
|||||||
if (!tmpc1 || !(tmpc1->type & (HTT_CLASS|HTT_INTERNAL_TYPE)))
|
if (!tmpc1 || !(tmpc1->type & (HTT_CLASS|HTT_INTERNAL_TYPE)))
|
||||||
LexExcept(cc,"Invalid class at ");
|
LexExcept(cc,"Invalid class at ");
|
||||||
|
|
||||||
ptr_stars_cnt=0;
|
ptr_stars_count=0;
|
||||||
while (cc->token=='*') {
|
while (cc->token=='*') {
|
||||||
if (mode.u8[1]) {
|
if (mode.u8[1]) {
|
||||||
LexPopNoRestore(cc);
|
LexPopNoRestore(cc);
|
||||||
@ -303,7 +303,7 @@ CHashClass *ParseType(CCompCtrl *cc,CHashClass **_tmpc1,
|
|||||||
}
|
}
|
||||||
Lex(cc);
|
Lex(cc);
|
||||||
tmpc1++;
|
tmpc1++;
|
||||||
if (++ptr_stars_cnt>PTR_STARS_NUM)
|
if (++ptr_stars_count>PTR_STARS_NUM)
|
||||||
LexExcept(cc,"Too many *'s at ");
|
LexExcept(cc,"Too many *'s at ");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -321,13 +321,13 @@ CHashClass *ParseType(CCompCtrl *cc,CHashClass **_tmpc1,
|
|||||||
if (cc->token=='(') {
|
if (cc->token=='(') {
|
||||||
if (Lex(cc)!='*')
|
if (Lex(cc)!='*')
|
||||||
LexExcept(cc,"Expecting '*' at ");
|
LexExcept(cc,"Expecting '*' at ");
|
||||||
ptr_stars_cnt=1; //fun_ptr
|
ptr_stars_count=1; //fun_ptr
|
||||||
while (Lex(cc)=='*')
|
while (Lex(cc)=='*')
|
||||||
ptr_stars_cnt++; //fun_ptr
|
ptr_stars_count++; //fun_ptr
|
||||||
if (ptr_stars_cnt>PTR_STARS_NUM)
|
if (ptr_stars_count>PTR_STARS_NUM)
|
||||||
LexExcept(cc,"Too many *'s at ");
|
LexExcept(cc,"Too many *'s at ");
|
||||||
} else
|
} else
|
||||||
ptr_stars_cnt=-1; //fun_ptr
|
ptr_stars_count=-1; //fun_ptr
|
||||||
|
|
||||||
if (_ident) {
|
if (_ident) {
|
||||||
if (cc->token==TK_IDENT) {
|
if (cc->token==TK_IDENT) {
|
||||||
@ -347,19 +347,19 @@ CHashClass *ParseType(CCompCtrl *cc,CHashClass **_tmpc1,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ptr_stars_cnt>=0) { //fun_ptr
|
if (ptr_stars_count>=0) { //fun_ptr
|
||||||
if (cc->token!=')')
|
if (cc->token!=')')
|
||||||
LexExcept(cc,"Missing ')' at ");
|
LexExcept(cc,"Missing ')' at ");
|
||||||
if (Lex(cc)!='(')
|
if (Lex(cc)!='(')
|
||||||
LexExcept(cc,"Expecting '(' at ");
|
LexExcept(cc,"Expecting '(' at ");
|
||||||
fun_ptr=ParseFunJoin(cc,tmpc1,NULL,fsp_flags)+ptr_stars_cnt;
|
fun_ptr=ParseFunJoin(cc,tmpc1,NULL,fsp_flags)+ptr_stars_count;
|
||||||
tmpc1=cmp.internal_types[RT_PTR]+ptr_stars_cnt;
|
tmpc1=cmp.internal_types[RT_PTR]+ptr_stars_count;
|
||||||
}
|
}
|
||||||
ParseArrayDims(cc,mode,tmpad);
|
ParseArrayDims(cc,mode,tmpad);
|
||||||
|
|
||||||
tmpc2=OptClassFwd(tmpc1);
|
tmpc2=OptClassFwd(tmpc1);
|
||||||
if (tmpc2->ptr_stars_cnt) {
|
if (tmpc2->ptr_stars_count) {
|
||||||
tmpc2-=tmpc2->ptr_stars_cnt;
|
tmpc2-=tmpc2->ptr_stars_count;
|
||||||
if (tmpc2->type&HTT_INTERNAL_TYPE && !tmpc2->size)
|
if (tmpc2->type&HTT_INTERNAL_TYPE && !tmpc2->size)
|
||||||
LexWarn(cc,"use \"U8 *\" instead of \"U0 *\" at ");
|
LexWarn(cc,"use \"U8 *\" instead of \"U0 *\" at ");
|
||||||
}
|
}
|
||||||
@ -391,11 +391,11 @@ U0 ParseDotDotDot(CCompCtrl *cc,CHashFun *tmpf,I64 _reg)
|
|||||||
tmpm->flags=MLF_DOT_DOT_DOT;
|
tmpm->flags=MLF_DOT_DOT_DOT;
|
||||||
tmpm->member_class=cmp.internal_types[RT_I64];
|
tmpm->member_class=cmp.internal_types[RT_I64];
|
||||||
tmpm->str=StrNew("argv");
|
tmpm->str=StrNew("argv");
|
||||||
tmpm->dim.total_cnt=127; //arbitrary
|
tmpm->dim.total_count=127; //arbitrary
|
||||||
tmpm->dim.next=tmpad=MAlloc(sizeof(CArrayDim));
|
tmpm->dim.next=tmpad=MAlloc(sizeof(CArrayDim));
|
||||||
tmpad->next=NULL;
|
tmpad->next=NULL;
|
||||||
tmpad->cnt=127; //arbitrary
|
tmpad->count=127; //arbitrary
|
||||||
tmpad->total_cnt=1;
|
tmpad->total_count=1;
|
||||||
tmpm->offset=tmpf->size;
|
tmpm->offset=tmpf->size;
|
||||||
tmpm->size=8; //Close enough
|
tmpm->size=8; //Close enough
|
||||||
tmpf->size+=8;//Close enough
|
tmpf->size+=8;//Close enough
|
||||||
@ -526,10 +526,10 @@ pvl_restart3:
|
|||||||
MemberAdd(cc,tmpm,tmpc,mode.u8[1]);
|
MemberAdd(cc,tmpm,tmpc,mode.u8[1]);
|
||||||
else
|
else
|
||||||
MemberAdd(cc,tmpm,tmpc,PRS1B_NULL);
|
MemberAdd(cc,tmpm,tmpc,PRS1B_NULL);
|
||||||
tmpc->member_cnt++;
|
tmpc->member_count++;
|
||||||
|
|
||||||
tmpc2=tmpm->member_class;
|
tmpc2=tmpm->member_class;
|
||||||
i=tmpc2->size*tmpm->dim.total_cnt;
|
i=tmpc2->size*tmpm->dim.total_count;
|
||||||
switch (mode.u8[1]) {
|
switch (mode.u8[1]) {
|
||||||
case PRS1B_STATIC_LOCAL_VAR:
|
case PRS1B_STATIC_LOCAL_VAR:
|
||||||
if (i<0) {
|
if (i<0) {
|
||||||
@ -562,7 +562,7 @@ pvl_restart3:
|
|||||||
Lex(cc); //skip =
|
Lex(cc); //skip =
|
||||||
ParseStaticInit(cc,tmpm,1);
|
ParseStaticInit(cc,tmpm,1);
|
||||||
LexPopNoRestore(cc);
|
LexPopNoRestore(cc);
|
||||||
i=tmpc2->size*tmpm->dim.total_cnt;
|
i=tmpc2->size*tmpm->dim.total_count;
|
||||||
k=(i+7)&~7;
|
k=(i+7)&~7;
|
||||||
if (cc->flags&CCF_AOT_COMPILE) {
|
if (cc->flags&CCF_AOT_COMPILE) {
|
||||||
k>>=3;
|
k>>=3;
|
||||||
@ -581,7 +581,7 @@ pvl_restart3:
|
|||||||
for (k=0;k<i;k++)
|
for (k=0;k<i;k++)
|
||||||
AOTStoreCodeU8At(cc,tmpm->static_data_rip+k,
|
AOTStoreCodeU8At(cc,tmpm->static_data_rip+k,
|
||||||
tmpm->static_data[k]);
|
tmpm->static_data[k]);
|
||||||
tmpm->use_cnt=0;
|
tmpm->use_count=0;
|
||||||
cc->flags|=CCF_DONT_MAKE_RES;
|
cc->flags|=CCF_DONT_MAKE_RES;
|
||||||
}
|
}
|
||||||
if (cc->flags&CCF_AOT_COMPILE)
|
if (cc->flags&CCF_AOT_COMPILE)
|
||||||
@ -611,7 +611,7 @@ pvl_restart3:
|
|||||||
Lex(cc);
|
Lex(cc);
|
||||||
if (!ParseExpression(cc,NULL,TRUE))
|
if (!ParseExpression(cc,NULL,TRUE))
|
||||||
throw('Compiler');
|
throw('Compiler');
|
||||||
tmpm->use_cnt=0;
|
tmpm->use_count=0;
|
||||||
cc->flags|=CCF_DONT_MAKE_RES;
|
cc->flags|=CCF_DONT_MAKE_RES;
|
||||||
} else
|
} else
|
||||||
LexPopNoRestore(cc);
|
LexPopNoRestore(cc);
|
||||||
|
@ -1,17 +1,17 @@
|
|||||||
I64 InstEntriesCompare(CInst *tmpins1,CInst *tmpins2)
|
I64 InstEntriesCompare(CInst *tmpins1,CInst *tmpins2)
|
||||||
{
|
{
|
||||||
I64 i1,i2,j=0,res=0,oc_cnt1=tmpins1->opcode_cnt,oc_cnt2=tmpins2->opcode_cnt;
|
I64 i1,i2,j=0,res=0,oc_count1=tmpins1->opcode_count,oc_count2=tmpins2->opcode_count;
|
||||||
if (tmpins1->flags&IEF_STI_LIKE)
|
if (tmpins1->flags&IEF_STI_LIKE)
|
||||||
oc_cnt1--;
|
oc_count1--;
|
||||||
if (tmpins2->flags&IEF_STI_LIKE)
|
if (tmpins2->flags&IEF_STI_LIKE)
|
||||||
oc_cnt2--;
|
oc_count2--;
|
||||||
while (TRUE) {
|
while (TRUE) {
|
||||||
if (j<oc_cnt1 && j<oc_cnt2) {
|
if (j<oc_count1 && j<oc_count2) {
|
||||||
if (res=tmpins1->opcode[j]-tmpins2->opcode[j])
|
if (res=tmpins1->opcode[j]-tmpins2->opcode[j])
|
||||||
return res;
|
return res;
|
||||||
j++;
|
j++;
|
||||||
} else {
|
} else {
|
||||||
if (res=oc_cnt1-oc_cnt2)
|
if (res=oc_count1-oc_count2)
|
||||||
return res;
|
return res;
|
||||||
|
|
||||||
if (tmpins1->flags&IEF_STI_LIKE && tmpins2->flags&IEF_STI_LIKE)
|
if (tmpins1->flags&IEF_STI_LIKE && tmpins2->flags&IEF_STI_LIKE)
|
||||||
@ -65,7 +65,7 @@ U0 DumpUAsmTables()
|
|||||||
|
|
||||||
CInst *InstEntryFind(U8 *rip,I64 opsize,I64 seg_size)
|
CInst *InstEntryFind(U8 *rip,I64 opsize,I64 seg_size)
|
||||||
{//Binary Search
|
{//Binary Search
|
||||||
I64 i,j,n,m,k,arg1,arg2,o1,o2,oc_cnt;
|
I64 i,j,n,m,k,arg1,arg2,o1,o2,oc_count;
|
||||||
CInst *tmpins,**table;
|
CInst *tmpins,**table;
|
||||||
i=0;
|
i=0;
|
||||||
if (seg_size==64) {
|
if (seg_size==64) {
|
||||||
@ -84,12 +84,12 @@ CInst *InstEntryFind(U8 *rip,I64 opsize,I64 seg_size)
|
|||||||
while (TRUE) { //ief_compare_start
|
while (TRUE) { //ief_compare_start
|
||||||
arg1=tmpins->arg1;
|
arg1=tmpins->arg1;
|
||||||
arg2=tmpins->arg2;
|
arg2=tmpins->arg2;
|
||||||
oc_cnt=tmpins->opcode_cnt;
|
oc_count=tmpins->opcode_count;
|
||||||
if (tmpins->flags&IEF_STI_LIKE)
|
if (tmpins->flags&IEF_STI_LIKE)
|
||||||
oc_cnt--;
|
oc_count--;
|
||||||
if (n<oc_cnt) {
|
if (n<oc_count) {
|
||||||
o1=rip[n];
|
o1=rip[n];
|
||||||
if (n==tmpins->opcode_cnt-1 && tmpins->flags & IEF_PLUS_OPCODE)
|
if (n==tmpins->opcode_count-1 && tmpins->flags & IEF_PLUS_OPCODE)
|
||||||
o1&=-8;
|
o1&=-8;
|
||||||
o2=tmpins->opcode[n++];
|
o2=tmpins->opcode[n++];
|
||||||
if (m=o1-o2)
|
if (m=o1-o2)
|
||||||
@ -132,11 +132,11 @@ CInst *InstEntryFind(U8 *rip,I64 opsize,I64 seg_size)
|
|||||||
m=1;
|
m=1;
|
||||||
goto ief_compare_done;
|
goto ief_compare_done;
|
||||||
case SV_I_REG:
|
case SV_I_REG:
|
||||||
m=rip[n]>>3-tmpins->opcode[tmpins->opcode_cnt-1]>>3;
|
m=rip[n]>>3-tmpins->opcode[tmpins->opcode_count-1]>>3;
|
||||||
goto ief_compare_done;
|
goto ief_compare_done;
|
||||||
case SV_STI_LIKE:
|
case SV_STI_LIKE:
|
||||||
if (!(m=rip[n]>>3-tmpins->opcode[tmpins->opcode_cnt-1]>>3))
|
if (!(m=rip[n]>>3-tmpins->opcode[tmpins->opcode_count-1]>>3))
|
||||||
m=rip[n]-tmpins->opcode[tmpins->opcode_cnt-1];
|
m=rip[n]-tmpins->opcode[tmpins->opcode_count-1];
|
||||||
goto ief_compare_done;
|
goto ief_compare_done;
|
||||||
case SV_R_REG:
|
case SV_R_REG:
|
||||||
case SV_NONE:
|
case SV_NONE:
|
||||||
@ -209,7 +209,7 @@ U0 UAsmHashLoad()
|
|||||||
while (tmph) {
|
while (tmph) {
|
||||||
if (tmph->type==HTT_OPCODE && !(tmph->oc_flags&OCF_ALIAS)) {
|
if (tmph->type==HTT_OPCODE && !(tmph->oc_flags&OCF_ALIAS)) {
|
||||||
tmpins=&tmph->ins;
|
tmpins=&tmph->ins;
|
||||||
for (k=0;k<tmph->inst_entry_cnt;k++) {
|
for (k=0;k<tmph->inst_entry_count;k++) {
|
||||||
uasm.table_16_32_entries++;
|
uasm.table_16_32_entries++;
|
||||||
if (!(tmpins->flags&IEF_NOT_IN_64_BIT))
|
if (!(tmpins->flags&IEF_NOT_IN_64_BIT))
|
||||||
uasm.table_64_entries++;
|
uasm.table_64_entries++;
|
||||||
@ -228,7 +228,7 @@ U0 UAsmHashLoad()
|
|||||||
while (tmph) {
|
while (tmph) {
|
||||||
if (tmph->type==HTT_OPCODE && !(tmph->oc_flags&OCF_ALIAS)) {
|
if (tmph->type==HTT_OPCODE && !(tmph->oc_flags&OCF_ALIAS)) {
|
||||||
tmpins=&tmph->ins;
|
tmpins=&tmph->ins;
|
||||||
for (k=0;k<tmph->inst_entry_cnt;k++) {
|
for (k=0;k<tmph->inst_entry_count;k++) {
|
||||||
uasm.table_16_32[j1++]=tmpins;
|
uasm.table_16_32[j1++]=tmpins;
|
||||||
if (!(tmpins->flags&IEF_NOT_IN_64_BIT))
|
if (!(tmpins->flags&IEF_NOT_IN_64_BIT))
|
||||||
uasm.table_64[j2++]=tmpins;
|
uasm.table_64[j2++]=tmpins;
|
||||||
@ -341,7 +341,7 @@ U0 Ui(U8 *buf,U8 **_rip,I64 seg_size=64,I64 *_jmp_dst=NULL,Bool just_ins=FALSE)
|
|||||||
tmpins=tmpins2;
|
tmpins=tmpins2;
|
||||||
}
|
}
|
||||||
|
|
||||||
rip+=tmpins->opcode_cnt;
|
rip+=tmpins->opcode_count;
|
||||||
tmpo=tmpins(U8 *)-tmpins->ins_entry_num*sizeof(CInst)
|
tmpo=tmpins(U8 *)-tmpins->ins_entry_num*sizeof(CInst)
|
||||||
-offset(CHashOpcode.ins);
|
-offset(CHashOpcode.ins);
|
||||||
if (just_ins)
|
if (just_ins)
|
||||||
@ -367,7 +367,7 @@ U0 Ui(U8 *buf,U8 **_rip,I64 seg_size=64,I64 *_jmp_dst=NULL,Bool just_ins=FALSE)
|
|||||||
|
|
||||||
if (tmpins->flags & IEF_PLUS_OPCODE) {
|
if (tmpins->flags & IEF_PLUS_OPCODE) {
|
||||||
rip--;
|
rip--;
|
||||||
RM1=*rip++ - tmpins->opcode[tmpins->opcode_cnt-1]+REX_b;
|
RM1=*rip++ - tmpins->opcode[tmpins->opcode_count-1]+REX_b;
|
||||||
ptr=NULL;
|
ptr=NULL;
|
||||||
if (ARGT_R8<=arg1<=ARGT_R64) {
|
if (ARGT_R8<=arg1<=ARGT_R64) {
|
||||||
if (arg1_size==8) {
|
if (arg1_size==8) {
|
||||||
@ -582,7 +582,7 @@ U0 Ui(U8 *buf,U8 **_rip,I64 seg_size=64,I64 *_jmp_dst=NULL,Bool just_ins=FALSE)
|
|||||||
break;
|
break;
|
||||||
case ARGT_STI:
|
case ARGT_STI:
|
||||||
rip--;
|
rip--;
|
||||||
CatPrint(arg1_st,"%Z",*rip++ - tmpins->opcode[tmpins->opcode_cnt-1],
|
CatPrint(arg1_st,"%Z",*rip++ - tmpins->opcode[tmpins->opcode_count-1],
|
||||||
"ST_FSTK_REGS");
|
"ST_FSTK_REGS");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -621,7 +621,7 @@ U0 Ui(U8 *buf,U8 **_rip,I64 seg_size=64,I64 *_jmp_dst=NULL,Bool just_ins=FALSE)
|
|||||||
break;
|
break;
|
||||||
case ARGT_STI:
|
case ARGT_STI:
|
||||||
rip--;
|
rip--;
|
||||||
CatPrint(arg2_st,"%Z",*rip++ -tmpins->opcode[tmpins->opcode_cnt-1],
|
CatPrint(arg2_st,"%Z",*rip++ -tmpins->opcode[tmpins->opcode_count-1],
|
||||||
"ST_FSTK_REGS");
|
"ST_FSTK_REGS");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -650,14 +650,14 @@ U0 Ui(U8 *buf,U8 **_rip,I64 seg_size=64,I64 *_jmp_dst=NULL,Bool just_ins=FALSE)
|
|||||||
*_rip=rip;
|
*_rip=rip;
|
||||||
}
|
}
|
||||||
|
|
||||||
U8 *U(U8 *rip,I64 cnt=20,I64 seg_size=64)
|
U8 *U(U8 *rip,I64 count=20,I64 seg_size=64)
|
||||||
{//Unassembles a num of insts.
|
{//Unassembles a num of insts.
|
||||||
I64 i;
|
I64 i;
|
||||||
U8 buf[1024];
|
U8 buf[1024];
|
||||||
if (seg_size==16)
|
if (seg_size==16)
|
||||||
PrintWarn("16-bit unassembly is not well supported.\n");
|
PrintWarn("16-bit unassembly is not well supported.\n");
|
||||||
"$$HL,1$$";
|
"$$HL,1$$";
|
||||||
for (i=0;i<cnt;i++) {
|
for (i=0;i<count;i++) {
|
||||||
Ui(buf,&rip,seg_size);
|
Ui(buf,&rip,seg_size);
|
||||||
"%s",buf;
|
"%s",buf;
|
||||||
}
|
}
|
||||||
@ -665,10 +665,10 @@ U8 *U(U8 *rip,I64 cnt=20,I64 seg_size=64)
|
|||||||
return rip;
|
return rip;
|
||||||
}
|
}
|
||||||
|
|
||||||
I64 Un(U8 *rip,I64 cnt=0x80,I64 seg_size=64)
|
I64 Un(U8 *rip,I64 count=0x80,I64 seg_size=64)
|
||||||
{//Unassembles a num of bytes
|
{//Unassembles a num of bytes
|
||||||
I64 i=0;
|
I64 i=0;
|
||||||
U8 buf[1024],*end_rip=rip(I64)+cnt;
|
U8 buf[1024],*end_rip=rip(I64)+count;
|
||||||
if (seg_size==16)
|
if (seg_size==16)
|
||||||
PrintWarn("16-bit unassembly is not well supported.\n");
|
PrintWarn("16-bit unassembly is not well supported.\n");
|
||||||
"$$HL,1$$";
|
"$$HL,1$$";
|
||||||
|
@ -377,7 +377,7 @@ $FG,5$$TX+CX,"Test"$$FG$
|
|||||||
* $LK,"DriveMap",A="MN:DriveMap"$() in $LK,"MountFile",A="MN:MountFile"$().
|
* $LK,"DriveMap",A="MN:DriveMap"$() in $LK,"MountFile",A="MN:MountFile"$().
|
||||||
|
|
||||||
* Return ress for $LK,"GrBlot",A="MN:GrBlot"$, $LK,"GrRect",A="MN:GrRect"$, $LK,"GrPutChar",A="MN:GrPutChar"$?
|
* Return ress for $LK,"GrBlot",A="MN:GrBlot"$, $LK,"GrRect",A="MN:GrRect"$, $LK,"GrPutChar",A="MN:GrPutChar"$?
|
||||||
* Collision cnts for $LK,"GrBlot",A="MN:GrBlot"$, $LK,"GrRect",A="MN:GrRect"$, $LK,"GrPutChar",A="MN:GrPutChar"$?
|
* Collision counts for $LK,"GrBlot",A="MN:GrBlot"$, $LK,"GrRect",A="MN:GrRect"$, $LK,"GrPutChar",A="MN:GrPutChar"$?
|
||||||
|
|
||||||
* $LK,"GetStr",A="MN:GetStr"$() or $LK,"GetChar",A="MN:GetChar"$() in $LK,"OSInstall",A="FI:::/Misc/OSInstall.HC"$ didn't like focus change.
|
* $LK,"GetStr",A="MN:GetStr"$() or $LK,"GetChar",A="MN:GetChar"$() in $LK,"OSInstall",A="FI:::/Misc/OSInstall.HC"$ didn't like focus change.
|
||||||
|
|
||||||
|
@ -228,7 +228,7 @@ U0 MakeStaffDistro()
|
|||||||
Drive('C');
|
Drive('C');
|
||||||
}
|
}
|
||||||
|
|
||||||
I64 UpdateLineCnts()
|
I64 UpdateLineCounts()
|
||||||
{
|
{
|
||||||
I64 res;
|
I64 res;
|
||||||
|
|
||||||
@ -301,8 +301,8 @@ U0 TOSRegen2()
|
|||||||
WinMax;
|
WinMax;
|
||||||
DiskCheckAll;
|
DiskCheckAll;
|
||||||
|
|
||||||
TOSProgress("Update Line Cnts");
|
TOSProgress("Update Line Counts");
|
||||||
UpdateLineCnts;
|
UpdateLineCounts;
|
||||||
|
|
||||||
TOSProgress("Copy C to D");
|
TOSProgress("Copy C to D");
|
||||||
TOSCopyDrive('C','D');
|
TOSCopyDrive('C','D');
|
||||||
@ -362,7 +362,7 @@ U0 TOSRegen2()
|
|||||||
|
|
||||||
TOSProgress("Done");
|
TOSProgress("Done");
|
||||||
SettingsPop;
|
SettingsPop;
|
||||||
"F2(\"/Home\") Cnt\t:%d\n",slash_home;
|
"F2(\"/Home\") Count\t:%d\n",slash_home;
|
||||||
"Elapsed Time\t:%5.3fs\n",tS-progress4_t0;
|
"Elapsed Time\t:%5.3fs\n",tS-progress4_t0;
|
||||||
ProgressBarsRst("ZenithOS/TOSRegen");
|
ProgressBarsRst("ZenithOS/TOSRegen");
|
||||||
}
|
}
|
||||||
|
@ -99,16 +99,16 @@ public U0 DiskCheckAll()
|
|||||||
|
|
||||||
public CDoc *DC2Doc(CDC *dc,I64 dx=0,I64 dy=0,I64 *_total_score=NULL)
|
public CDoc *DC2Doc(CDC *dc,I64 dx=0,I64 dy=0,I64 *_total_score=NULL)
|
||||||
{//Use OCR to make a text DolDoc from CDC.
|
{//Use OCR to make a text DolDoc from CDC.
|
||||||
U8 byte_bit_cnts[256];
|
U8 byte_bit_counts[256];
|
||||||
I64 i,j,*ptr,row,col,ch,best_ch,score,best_score,
|
I64 i,j,*ptr,row,col,ch,best_ch,score,best_score,
|
||||||
cur_char_image,diff_image,total_score=0;
|
cur_char_image,diff_image,total_score=0;
|
||||||
CDoc *doc=DocNew;
|
CDoc *doc=DocNew;
|
||||||
|
|
||||||
MemSet(byte_bit_cnts,0,sizeof(byte_bit_cnts));
|
MemSet(byte_bit_counts,0,sizeof(byte_bit_counts));
|
||||||
for (i=0;i<256;i++)
|
for (i=0;i<256;i++)
|
||||||
for (j=0;j<7;j++)
|
for (j=0;j<7;j++)
|
||||||
if (Bt(&i,j))
|
if (Bt(&i,j))
|
||||||
byte_bit_cnts[i]++;
|
byte_bit_counts[i]++;
|
||||||
|
|
||||||
for (row=0;row<dc->height/FONT_HEIGHT;row++) {
|
for (row=0;row<dc->height/FONT_HEIGHT;row++) {
|
||||||
for (col=0;col<dc->width/FONT_WIDTH;col++) {
|
for (col=0;col<dc->width/FONT_WIDTH;col++) {
|
||||||
@ -126,7 +126,7 @@ public CDoc *DC2Doc(CDC *dc,I64 dx=0,I64 dy=0,I64 *_total_score=NULL)
|
|||||||
diff_image=*ptr++ ^ cur_char_image;
|
diff_image=*ptr++ ^ cur_char_image;
|
||||||
score=0;
|
score=0;
|
||||||
for (i=0;i<8;i++)
|
for (i=0;i<8;i++)
|
||||||
score+=byte_bit_cnts[diff_image.u8[i]];
|
score+=byte_bit_counts[diff_image.u8[i]];
|
||||||
if (score<best_score) {
|
if (score<best_score) {
|
||||||
best_score=score;
|
best_score=score;
|
||||||
best_ch=ch;
|
best_ch=ch;
|
||||||
|
@ -35,7 +35,7 @@ _BEEPS::
|
|||||||
//_extern binds a asm sym to a function.
|
//_extern binds a asm sym to a function.
|
||||||
//My convention is to put an underscore
|
//My convention is to put an underscore
|
||||||
//on C callable asm routines.
|
//on C callable asm routines.
|
||||||
_extern _BEEPS U0 Beeps(I64 cnt);
|
_extern _BEEPS U0 Beeps(I64 count);
|
||||||
|
|
||||||
I64 AsmAndC1()
|
I64 AsmAndC1()
|
||||||
{
|
{
|
||||||
@ -62,7 +62,7 @@ I64 AsmAndC1()
|
|||||||
PUSH RAX
|
PUSH RAX
|
||||||
CALL Snd
|
CALL Snd
|
||||||
|
|
||||||
MOV RCX,cnts.time_stamp_freq>>3 //JIT Const. Simple delay loop
|
MOV RCX,counts.time_stamp_freq>>3 //JIT Const. Simple delay loop
|
||||||
@@10: LOOP @@10
|
@@10: LOOP @@10
|
||||||
|
|
||||||
POP RCX
|
POP RCX
|
||||||
|
@ -6,7 +6,7 @@ it from the cmd line.
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
//This is to demo glbl var access.
|
//This is to demo glbl var access.
|
||||||
//Glbs defined elsewhere can accessed too, like cnts.jiffies.
|
//Glbs defined elsewhere can accessed too, like counts.jiffies.
|
||||||
I64 glbl_ona=Freq2Ona(400),glbl_ona_step=10,glbl_ona_base=Freq2Ona(100);
|
I64 glbl_ona=Freq2Ona(400),glbl_ona_step=10,glbl_ona_base=Freq2Ona(100);
|
||||||
|
|
||||||
asm {
|
asm {
|
||||||
@ -24,7 +24,7 @@ _BEEPS2::
|
|||||||
MOV RBP,RSP
|
MOV RBP,RSP
|
||||||
MOV RCX,U64 SF_ARG1[RBP] //$LK,"SF_ARG1",A="FF:::/Kernel/KernelA.HH,SF_ARG1"$
|
MOV RCX,U64 SF_ARG1[RBP] //$LK,"SF_ARG1",A="FF:::/Kernel/KernelA.HH,SF_ARG1"$
|
||||||
|
|
||||||
PUSH U64 [&cnts.jiffies]
|
PUSH U64 [&counts.jiffies]
|
||||||
|
|
||||||
@@05: PUSH RCX
|
@@05: PUSH RCX
|
||||||
//U0 $LK,"Beep",A="MN:Beep"$(I8 ona=62,Bool busy=FALSE)
|
//U0 $LK,"Beep",A="MN:Beep"$(I8 ona=62,Bool busy=FALSE)
|
||||||
@ -40,7 +40,7 @@ _BEEPS2::
|
|||||||
POP RSI
|
POP RSI
|
||||||
|
|
||||||
POP RAX
|
POP RAX
|
||||||
SUB RAX,U64 [&cnts.jiffies]
|
SUB RAX,U64 [&counts.jiffies]
|
||||||
NEG RAX
|
NEG RAX
|
||||||
CALL PUT_HEX_U64
|
CALL PUT_HEX_U64
|
||||||
MOV RAX,'\n'
|
MOV RAX,'\n'
|
||||||
@ -52,7 +52,7 @@ _BEEPS2::
|
|||||||
|
|
||||||
//My convention is to put an underscore
|
//My convention is to put an underscore
|
||||||
//on C callable asm routines.
|
//on C callable asm routines.
|
||||||
_extern _BEEPS2 U0 Beeps2(I64 cnt);
|
_extern _BEEPS2 U0 Beeps2(I64 count);
|
||||||
|
|
||||||
U0 AsmAndC2()
|
U0 AsmAndC2()
|
||||||
{
|
{
|
||||||
@ -73,7 +73,7 @@ U0 AsmAndC2()
|
|||||||
ADD RAX,U64 [&glbl_ona_base] //Intentionally evaluated at run time
|
ADD RAX,U64 [&glbl_ona_base] //Intentionally evaluated at run time
|
||||||
PUSH RAX
|
PUSH RAX
|
||||||
CALL &Snd //We can skip IMPORT with & if JIT compiling.
|
CALL &Snd //We can skip IMPORT with & if JIT compiling.
|
||||||
MOV RCX,cnts.time_stamp_freq>>3 //JIT Const. Simple delay loop.
|
MOV RCX,counts.time_stamp_freq>>3 //JIT Const. Simple delay loop.
|
||||||
@@10: LOOP @@10
|
@@10: LOOP @@10
|
||||||
|
|
||||||
POP RCX
|
POP RCX
|
||||||
|
@ -14,7 +14,7 @@ U0 AsmAndC3()
|
|||||||
STC
|
STC
|
||||||
ADC AL,0 //Round-about way to make the not-special constant, 0x42.
|
ADC AL,0 //Round-about way to make the not-special constant, 0x42.
|
||||||
CALL PUT_HEX_U8
|
CALL PUT_HEX_U8
|
||||||
MOV RCX,cnts.time_stamp_freq>>5 //JIT Const. Simple delay loop.
|
MOV RCX,counts.time_stamp_freq>>5 //JIT Const. Simple delay loop.
|
||||||
@@1: LOOP @@1
|
@@1: LOOP @@1
|
||||||
'\n';
|
'\n';
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
//Shows the $LK,"Carry",A="MN:Carry"$ function. It holds the CPU carry flag.
|
//Shows the $LK,"Carry",A="MN:Carry"$ function. It holds the CPU carry flag.
|
||||||
//$LK,"U",A="MN:U"$() Unassemble to make sure it is right.
|
//$LK,"U",A="MN:U"$() Unassemble to make sure it is right.
|
||||||
|
|
||||||
U0 BigCnt()
|
U0 BigCount()
|
||||||
{
|
{
|
||||||
U64 lo=0,hi=0;
|
U64 lo=0,hi=0;
|
||||||
"BigCnt\n";
|
"BigCount\n";
|
||||||
while (hi<0x10) {
|
while (hi<0x10) {
|
||||||
lo+=1<<58;
|
lo+=1<<58;
|
||||||
hi+=Carry;
|
hi+=Carry;
|
||||||
@ -12,7 +12,7 @@ U0 BigCnt()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BigCnt;
|
BigCount;
|
||||||
|
|
||||||
U0 BigShift()
|
U0 BigShift()
|
||||||
{
|
{
|
||||||
|
@ -29,7 +29,7 @@ ClickCallBack;
|
|||||||
|
|
||||||
I64 MyLeftCB2(CDoc *,CDocEntry *)
|
I64 MyLeftCB2(CDoc *,CDocEntry *)
|
||||||
{
|
{
|
||||||
return cnts.jiffies;
|
return counts.jiffies;
|
||||||
}
|
}
|
||||||
|
|
||||||
U0 PopUpJiffiesCallBack(I64 i)
|
U0 PopUpJiffiesCallBack(I64 i)
|
||||||
|
@ -14,7 +14,7 @@ output $LK,"Silent",A="MN:Silent"$().
|
|||||||
U0 UnusedDefineScan()
|
U0 UnusedDefineScan()
|
||||||
{
|
{
|
||||||
CDoc *old_put_doc,*old_display_doc,*doc;
|
CDoc *old_put_doc,*old_display_doc,*doc;
|
||||||
I64 i,cnt=0;
|
I64 i,count=0;
|
||||||
CHashTable *table;
|
CHashTable *table;
|
||||||
CHash *tmph;
|
CHash *tmph;
|
||||||
CDocEntry *doc_e,*doc_e2;
|
CDocEntry *doc_e,*doc_e2;
|
||||||
@ -27,7 +27,7 @@ U0 UnusedDefineScan()
|
|||||||
tmph=table->body[i];
|
tmph=table->body[i];
|
||||||
while (tmph) {
|
while (tmph) {
|
||||||
if (tmph->type&HTT_DEFINE_STR)
|
if (tmph->type&HTT_DEFINE_STR)
|
||||||
cnt++;
|
count++;
|
||||||
tmph=tmph->next;
|
tmph=tmph->next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -35,7 +35,7 @@ U0 UnusedDefineScan()
|
|||||||
}
|
}
|
||||||
|
|
||||||
progress1=0;
|
progress1=0;
|
||||||
progress1_max=cnt;
|
progress1_max=count;
|
||||||
StrCpy(progress1_desc,"Define Scan");
|
StrCpy(progress1_desc,"Define Scan");
|
||||||
|
|
||||||
table=Fs->hash_table;
|
table=Fs->hash_table;
|
||||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -4,7 +4,7 @@ RegDft("ZenithOS/RawHide","F64 best_score=9999;\n");
|
|||||||
RegExe("ZenithOS/RawHide");
|
RegExe("ZenithOS/RawHide");
|
||||||
|
|
||||||
F64 t0,tf;
|
F64 t0,tf;
|
||||||
I64 outside_cnt;
|
I64 outside_count;
|
||||||
|
|
||||||
#define MAP_WIDTH 1000
|
#define MAP_WIDTH 1000
|
||||||
#define MAP_HEIGHT 1000
|
#define MAP_HEIGHT 1000
|
||||||
@ -257,7 +257,7 @@ U0 DrawIt(CTask *task,CDC *dc)
|
|||||||
}
|
}
|
||||||
GrPrint(dc,-task->scroll_x,-task->scroll_y,
|
GrPrint(dc,-task->scroll_x,-task->scroll_y,
|
||||||
"Outside:%03d Time:%7.2fs Best:%7.2fs",
|
"Outside:%03d Time:%7.2fs Best:%7.2fs",
|
||||||
outside_cnt,t,best_score);
|
outside_count,t,best_score);
|
||||||
}
|
}
|
||||||
|
|
||||||
U0 BuddySel(I64 i)
|
U0 BuddySel(I64 i)
|
||||||
@ -328,8 +328,8 @@ Bool CheckMap(I64 x,I64 y)
|
|||||||
|
|
||||||
U0 AnimateTask(CTask *parent)
|
U0 AnimateTask(CTask *parent)
|
||||||
{
|
{
|
||||||
I64 i,cx,cy,cursor_x,cursor_y,dd,ddx,ddy,cnt,max_speed=I64_MAX,updates=0,
|
I64 i,cx,cy,cursor_x,cursor_y,dd,ddx,ddy,count,max_speed=I64_MAX,updates=0,
|
||||||
my_outside_cnt;
|
my_outside_count;
|
||||||
F64 f,d,dx,dy,s,stress;
|
F64 f,d,dx,dy,s,stress;
|
||||||
Animal *tmpa,*tmpa1;
|
Animal *tmpa,*tmpa1;
|
||||||
while (TRUE) {
|
while (TRUE) {
|
||||||
@ -338,8 +338,8 @@ U0 AnimateTask(CTask *parent)
|
|||||||
cy=(MAP_HEIGHT-parent->pix_height)/2;
|
cy=(MAP_HEIGHT-parent->pix_height)/2;
|
||||||
cursor_x=ms.pos.x+cx-parent->pix_left-parent->scroll_x;
|
cursor_x=ms.pos.x+cx-parent->pix_left-parent->scroll_x;
|
||||||
cursor_y=ms.pos.y+cy-parent->pix_top -parent->scroll_y;
|
cursor_y=ms.pos.y+cy-parent->pix_top -parent->scroll_y;
|
||||||
cnt=0;stress=0;
|
count=0;stress=0;
|
||||||
my_outside_cnt=0;
|
my_outside_count=0;
|
||||||
if (cursor_x<FENCE_WIDTH && cursor_y<FENCE_HEIGHT)
|
if (cursor_x<FENCE_WIDTH && cursor_y<FENCE_HEIGHT)
|
||||||
gate_t=tS;
|
gate_t=tS;
|
||||||
RedrawGate;
|
RedrawGate;
|
||||||
@ -409,17 +409,17 @@ U0 AnimateTask(CTask *parent)
|
|||||||
tmpa->y -=tmpa->dy;
|
tmpa->y -=tmpa->dy;
|
||||||
tmpa->dy=-tmpa->dy;
|
tmpa->dy=-tmpa->dy;
|
||||||
}
|
}
|
||||||
cnt++;
|
count++;
|
||||||
if (tmpa->x>>32>=FENCE_WIDTH || tmpa->y>>32>=FENCE_HEIGHT)
|
if (tmpa->x>>32>=FENCE_WIDTH || tmpa->y>>32>=FENCE_HEIGHT)
|
||||||
my_outside_cnt++;
|
my_outside_count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
outside_cnt=my_outside_cnt;
|
outside_count=my_outside_count;
|
||||||
|
|
||||||
if (!(updates&15))
|
if (!(updates&15))
|
||||||
RiverDropsNext(parent);
|
RiverDropsNext(parent);
|
||||||
|
|
||||||
if (!tf && !outside_cnt) {
|
if (!tf && !outside_count) {
|
||||||
tf=tS;
|
tf=tS;
|
||||||
music.mute=TRUE;
|
music.mute=TRUE;
|
||||||
Snd(86);Sleep(200);Snd;Sleep(100);
|
Snd(86);Sleep(200);Snd;Sleep(100);
|
||||||
@ -432,8 +432,8 @@ U0 AnimateTask(CTask *parent)
|
|||||||
|
|
||||||
updates++;
|
updates++;
|
||||||
|
|
||||||
if (cnt)
|
if (count)
|
||||||
stress/=cnt;
|
stress/=count;
|
||||||
else
|
else
|
||||||
stress=0;
|
stress=0;
|
||||||
if (stress>100.0) {
|
if (stress>100.0) {
|
||||||
@ -501,7 +501,7 @@ U0 ReInit()
|
|||||||
a[i].frame0=RandU16&3;
|
a[i].frame0=RandU16&3;
|
||||||
BuddySel(i);
|
BuddySel(i);
|
||||||
}
|
}
|
||||||
outside_cnt=ANIMALS_NUM;
|
outside_count=ANIMALS_NUM;
|
||||||
gate_t=0;
|
gate_t=0;
|
||||||
gate_é=0;
|
gate_é=0;
|
||||||
t0=tS;
|
t0=tS;
|
||||||
|
Binary file not shown.
@ -148,7 +148,7 @@ class Bird
|
|||||||
Bird *next,*last;
|
Bird *next,*last;
|
||||||
CD3I64 p;
|
CD3I64 p;
|
||||||
F64 é;
|
F64 é;
|
||||||
} b_head[mp_cnt];
|
} b_head[mp_count];
|
||||||
|
|
||||||
class Obj
|
class Obj
|
||||||
{
|
{
|
||||||
@ -162,7 +162,7 @@ class Panel
|
|||||||
{//Polygon or Obj
|
{//Polygon or Obj
|
||||||
Panel *next;
|
Panel *next;
|
||||||
CD3I32 *pts;
|
CD3I32 *pts;
|
||||||
I64 cnt;
|
I64 count;
|
||||||
U16 update,num_sides;
|
U16 update,num_sides;
|
||||||
CColorROPU32 color;
|
CColorROPU32 color;
|
||||||
Obj *next_obj,*last_obj;
|
Obj *next_obj,*last_obj;
|
||||||
@ -274,8 +274,8 @@ U0 MPDoPanels(CTask *task)
|
|||||||
Panel *tmpp,*start_ptr=NULL,*end_ptr=NULL;
|
Panel *tmpp,*start_ptr=NULL,*end_ptr=NULL;
|
||||||
CD3I32 *poly;
|
CD3I32 *poly;
|
||||||
Obj *tmpo;
|
Obj *tmpo;
|
||||||
lo=Gs->num*(MAP_HEIGHT-1)/mp_cnt;
|
lo=Gs->num*(MAP_HEIGHT-1)/mp_count;
|
||||||
hi=(Gs->num+1)*(MAP_HEIGHT-1)/mp_cnt;
|
hi=(Gs->num+1)*(MAP_HEIGHT-1)/mp_count;
|
||||||
for (threshold=8;threshold>=1;threshold--)
|
for (threshold=8;threshold>=1;threshold--)
|
||||||
for (j=lo;j<hi;j++) {
|
for (j=lo;j<hi;j++) {
|
||||||
for (i=0;i<MAP_WIDTH-1;i++) {
|
for (i=0;i<MAP_WIDTH-1;i++) {
|
||||||
@ -438,8 +438,8 @@ for each spot.
|
|||||||
MemSet(panels,0,sizeof(panels));
|
MemSet(panels,0,sizeof(panels));
|
||||||
CalcNormals;
|
CalcNormals;
|
||||||
panel_head=NULL;
|
panel_head=NULL;
|
||||||
mp.init_not_done_flags=1<<mp_cnt-1;
|
mp.init_not_done_flags=1<<mp_count-1;
|
||||||
for (i=0;i<mp_cnt;i++)
|
for (i=0;i<mp_count;i++)
|
||||||
Spawn(&MPDoPanels,Fs,"Do Panels",i);
|
Spawn(&MPDoPanels,Fs,"Do Panels",i);
|
||||||
while (mp.init_not_done_flags)
|
while (mp.init_not_done_flags)
|
||||||
Sleep(1);
|
Sleep(1);
|
||||||
@ -660,20 +660,20 @@ U0 MPDrawIt(CTask *task,CDC *dc)
|
|||||||
xh2>>=1; yh2>>=1;
|
xh2>>=1; yh2>>=1;
|
||||||
w_on_map=FALSE;
|
w_on_map=FALSE;
|
||||||
dd_old=I64_MAX;
|
dd_old=I64_MAX;
|
||||||
for (strip_width=0;cnts.jiffies<update_jiffy_limit;strip_width++) {
|
for (strip_width=0;counts.jiffies<update_jiffy_limit;strip_width++) {
|
||||||
x1h=x1wa;
|
x1h=x1wa;
|
||||||
y1h=y1wa;
|
y1h=y1wa;
|
||||||
h_on_map=FALSE;
|
h_on_map=FALSE;
|
||||||
for (j=0;j<strip_height && cnts.jiffies<update_jiffy_limit;j++) {
|
for (j=0;j<strip_height && counts.jiffies<update_jiffy_limit;j++) {
|
||||||
x1=x1h>>8; y1=y1h>>8;
|
x1=x1h>>8; y1=y1h>>8;
|
||||||
if (0<=x1<MAP_WIDTH && 0<=y1<MAP_HEIGHT) {
|
if (0<=x1<MAP_WIDTH && 0<=y1<MAP_HEIGHT) {
|
||||||
if ((tmpp=panels[y1][x1]) && tmpp->update!=update) {
|
if ((tmpp=panels[y1][x1]) && tmpp->update!=update) {
|
||||||
tmpp->update=update;
|
tmpp->update=update;
|
||||||
if (tmpp->cnt>8*(1.1-Gs->idle_factor)) {
|
if (tmpp->count>8*(1.1-Gs->idle_factor)) {
|
||||||
dc->color=tmpp->color;
|
dc->color=tmpp->color;
|
||||||
tmpp->cnt=GrFillPoly3(dc,tmpp->num_sides,tmpp->pts);
|
tmpp->count=GrFillPoly3(dc,tmpp->num_sides,tmpp->pts);
|
||||||
} else
|
} else
|
||||||
tmpp->cnt++;
|
tmpp->count++;
|
||||||
tmpo=tmpp->next_obj;
|
tmpo=tmpp->next_obj;
|
||||||
while (tmpo!=&tmpp->next_obj) {
|
while (tmpo!=&tmpp->next_obj) {
|
||||||
Sprite3(dc,tmpo->p.x,tmpo->p.y,tmpo->p.z,tmpo->img);
|
Sprite3(dc,tmpo->p.x,tmpo->p.y,tmpo->p.z,tmpo->img);
|
||||||
@ -859,7 +859,7 @@ U0 Core0Talons()
|
|||||||
I64 i,xx,yy,elev,height,cx=Fs->pix_width>>1,cy=Fs->pix_height>>1;
|
I64 i,xx,yy,elev,height,cx=Fs->pix_width>>1,cy=Fs->pix_height>>1;
|
||||||
F64 min_strip_width,tt;
|
F64 min_strip_width,tt;
|
||||||
|
|
||||||
update_jiffy_limit=cnts.jiffies+JIFFY_FREQ/40;
|
update_jiffy_limit=counts.jiffies+JIFFY_FREQ/40;
|
||||||
|
|
||||||
xx=x/(MAP_SCALE*COORDINATE_SCALE);
|
xx=x/(MAP_SCALE*COORDINATE_SCALE);
|
||||||
yy=y/(MAP_SCALE*COORDINATE_SCALE);
|
yy=y/(MAP_SCALE*COORDINATE_SCALE);
|
||||||
@ -887,13 +887,13 @@ U0 Core0Talons()
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
DCDepthBufRst(dc);
|
DCDepthBufRst(dc);
|
||||||
mp.update_not_done_flags=1<<mp_cnt-1;
|
mp.update_not_done_flags=1<<mp_count-1;
|
||||||
MPDrawIt(Fs,dc);
|
MPDrawIt(Fs,dc);
|
||||||
while (mp.update_not_done_flags)
|
while (mp.update_not_done_flags)
|
||||||
Sleep(1);
|
Sleep(1);
|
||||||
|
|
||||||
min_strip_width=F64_MAX;
|
min_strip_width=F64_MAX;
|
||||||
for (i=0;i<mp_cnt;i++)
|
for (i=0;i<mp_count;i++)
|
||||||
min_strip_width=Min(min_strip_width,32.0*mp.strip_width[i]/(i+32.0));
|
min_strip_width=Min(min_strip_width,32.0*mp.strip_width[i]/(i+32.0));
|
||||||
strip_height=ClampI64(
|
strip_height=ClampI64(
|
||||||
strip_height*Clamp(0.25*min_strip_width/strip_height,0.9,1.1),
|
strip_height*Clamp(0.25*min_strip_width/strip_height,0.9,1.1),
|
||||||
@ -1028,7 +1028,7 @@ U0 AnimateTask(I64)
|
|||||||
speed=Clamp(speed+(0.0005-0.0002*Abs(è)/(ã/4)),0.1,5.0);
|
speed=Clamp(speed+(0.0005-0.0002*Abs(è)/(ã/4)),0.1,5.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i=0;i<mp_cnt;i++) {
|
for (i=0;i<mp_count;i++) {
|
||||||
tmpb=b_head[i].next;
|
tmpb=b_head[i].next;
|
||||||
while (tmpb!=&b_head[i]) {
|
while (tmpb!=&b_head[i]) {
|
||||||
tmpb->p.x+=10*ms/1000*MAP_SCALE*Cos(tmpb->é);
|
tmpb->p.x+=10*ms/1000*MAP_SCALE*Cos(tmpb->é);
|
||||||
@ -1047,7 +1047,7 @@ U0 AnimateTask(I64)
|
|||||||
U0 MPEnd()
|
U0 MPEnd()
|
||||||
{
|
{
|
||||||
update_jiffy_limit=0;
|
update_jiffy_limit=0;
|
||||||
mp.app_not_done_flags=1<<mp_cnt-1-1;
|
mp.app_not_done_flags=1<<mp_count-1-1;
|
||||||
mp.app_done=TRUE;
|
mp.app_done=TRUE;
|
||||||
//Wait for all cores to exit
|
//Wait for all cores to exit
|
||||||
while (mp.app_not_done_flags)
|
while (mp.app_not_done_flags)
|
||||||
@ -1119,7 +1119,7 @@ U0 Init()
|
|||||||
yy=y/(MAP_SCALE*COORDINATE_SCALE);
|
yy=y/(MAP_SCALE*COORDINATE_SCALE);
|
||||||
z+=elevations[yy][xx]*COORDINATE_SCALE;
|
z+=elevations[yy][xx]*COORDINATE_SCALE;
|
||||||
|
|
||||||
for (i=0;i<mp_cnt;i++)
|
for (i=0;i<mp_count;i++)
|
||||||
QueueInit(&b_head[i]);
|
QueueInit(&b_head[i]);
|
||||||
|
|
||||||
for (i=0;i<B_NUM;i++) {
|
for (i=0;i<B_NUM;i++) {
|
||||||
@ -1129,10 +1129,10 @@ U0 Init()
|
|||||||
tmpb->p.z=BIRD_ELEVATION*MAP_SCALE+
|
tmpb->p.z=BIRD_ELEVATION*MAP_SCALE+
|
||||||
elevations[tmpb->p.y/MAP_SCALE][tmpb->p.x/MAP_SCALE];
|
elevations[tmpb->p.y/MAP_SCALE][tmpb->p.x/MAP_SCALE];
|
||||||
tmpb->é=2*ã*Rand;
|
tmpb->é=2*ã*Rand;
|
||||||
QueueInsert(tmpb,b_head[i%mp_cnt].last);
|
QueueInsert(tmpb,b_head[i%mp_count].last);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i=1;i<mp_cnt;i++)
|
for (i=1;i<mp_count;i++)
|
||||||
Spawn(&CoreAPTalonsTask,Fs,"AP Talons",i);
|
Spawn(&CoreAPTalonsTask,Fs,"AP Talons",i);
|
||||||
Fs->task_end_cb=&TaskEndCB;
|
Fs->task_end_cb=&TaskEndCB;
|
||||||
game_t0=tS;
|
game_t0=tS;
|
||||||
@ -1150,7 +1150,7 @@ U0 CleanUp()
|
|||||||
Free(tmpp);
|
Free(tmpp);
|
||||||
tmpp=tmpp1;
|
tmpp=tmpp1;
|
||||||
}
|
}
|
||||||
for (i=0;i<mp_cnt;i++) {
|
for (i=0;i<mp_count;i++) {
|
||||||
QueueDel(&b_head[i]);
|
QueueDel(&b_head[i]);
|
||||||
QueueInit(&b_head[i]);
|
QueueInit(&b_head[i]);
|
||||||
}
|
}
|
||||||
|
@ -296,8 +296,8 @@ U0 InitTrack()
|
|||||||
CoupleEnds;
|
CoupleEnds;
|
||||||
|
|
||||||
tmpt=track_head.next;
|
tmpt=track_head.next;
|
||||||
for (i=0;i<mp_cnt;i++) {
|
for (i=0;i<mp_count;i++) {
|
||||||
j=(i+1)*track_head.last->num/mp_cnt+1;
|
j=(i+1)*track_head.last->num/mp_count+1;
|
||||||
track_start[i]=tmpt;
|
track_start[i]=tmpt;
|
||||||
while (tmpt!=&track_head && tmpt->num!=j)
|
while (tmpt!=&track_head && tmpt->num!=j)
|
||||||
tmpt=tmpt->next;
|
tmpt=tmpt->next;
|
||||||
@ -378,7 +378,7 @@ U0 MPUpdateWin(CDC *dc2)
|
|||||||
}
|
}
|
||||||
|
|
||||||
dc->flags|=DCF_TRANSFORMATION;
|
dc->flags|=DCF_TRANSFORMATION;
|
||||||
for (i=Gs->num;i<BUSHES_NUM;i+=mp_cnt) {
|
for (i=Gs->num;i<BUSHES_NUM;i+=mp_count) {
|
||||||
x=b[i].p.x-c[0].p.x; y=b[i].p.y-c[0].p.y; z=b[i].p.z-c[0].p.z;
|
x=b[i].p.x-c[0].p.x; y=b[i].p.y-c[0].p.y; z=b[i].p.z-c[0].p.z;
|
||||||
Mat4x4MulXYZ(r,&x,&y,&z);
|
Mat4x4MulXYZ(r,&x,&y,&z);
|
||||||
if (z>0) {
|
if (z>0) {
|
||||||
@ -394,7 +394,7 @@ U0 MPUpdateWin(CDC *dc2)
|
|||||||
dc->flags&=~(DCF_SYMMETRY|DCF_JUST_MIRROR);
|
dc->flags&=~(DCF_SYMMETRY|DCF_JUST_MIRROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (i=Gs->num+1;i<CARS_NUM;i+=mp_cnt) {
|
for (i=Gs->num+1;i<CARS_NUM;i+=mp_count) {
|
||||||
tmpc=&c[i];
|
tmpc=&c[i];
|
||||||
x=tmpc->p.x-c[0].p.x; y=tmpc->p.y-c[0].p.y; z=tmpc->p.z-c[0].p.z;
|
x=tmpc->p.x-c[0].p.x; y=tmpc->p.y-c[0].p.y; z=tmpc->p.z-c[0].p.z;
|
||||||
Mat4x4MulXYZ(r,&x,&y,&z);
|
Mat4x4MulXYZ(r,&x,&y,&z);
|
||||||
@ -455,8 +455,8 @@ U0 DrawIt(CTask *task,CDC *dc)
|
|||||||
GrFloodFill(dc,s*x+cx,15+HORIZON_DIP*Sin(dip_é));
|
GrFloodFill(dc,s*x+cx,15+HORIZON_DIP*Sin(dip_é));
|
||||||
}
|
}
|
||||||
|
|
||||||
mp_not_done_flags=1<<mp_cnt-1;
|
mp_not_done_flags=1<<mp_count-1;
|
||||||
for (i=0;i<mp_cnt;i++)
|
for (i=0;i<mp_count;i++)
|
||||||
JobQueue(&MPUpdateWin,dc,i);
|
JobQueue(&MPUpdateWin,dc,i);
|
||||||
while (mp_not_done_flags)
|
while (mp_not_done_flags)
|
||||||
Yield;
|
Yield;
|
||||||
|
@ -99,7 +99,7 @@ U64 snow_x,snow_y,new_snow_mS;
|
|||||||
CDC *snow_tile;
|
CDC *snow_tile;
|
||||||
|
|
||||||
I64 king_x,king_y,king_mS,king_phase,
|
I64 king_x,king_y,king_mS,king_phase,
|
||||||
not_stopped_cnt;
|
not_stopped_count;
|
||||||
F64 king_timeout,king_é,t0,tf,door_open_t0;
|
F64 king_timeout,king_é,t0,tf,door_open_t0;
|
||||||
I64 animate_mS,animate_phase;
|
I64 animate_mS,animate_phase;
|
||||||
|
|
||||||
@ -218,7 +218,7 @@ U0 DrawIt(CTask *task,CDC *dc)
|
|||||||
}
|
}
|
||||||
dc->color=LTBLUE;
|
dc->color=LTBLUE;
|
||||||
GrPrint(dc,0,0,"Freezing Peasants:%d Time:%3.2f Best:%3.2f",
|
GrPrint(dc,0,0,"Freezing Peasants:%d Time:%3.2f Best:%3.2f",
|
||||||
not_stopped_cnt,tt-t0,best_score);
|
not_stopped_count,tt-t0,best_score);
|
||||||
}
|
}
|
||||||
|
|
||||||
U0 StepNew(CTask *task,I64 x,I64 y,F64 é,Bool left_right,Bool king)
|
U0 StepNew(CTask *task,I64 x,I64 y,F64 é,Bool left_right,Bool king)
|
||||||
@ -356,7 +356,7 @@ U0 AnimateTask(I64)
|
|||||||
tmps=tmps1;
|
tmps=tmps1;
|
||||||
}
|
}
|
||||||
|
|
||||||
not_stopped_cnt=0;
|
not_stopped_count=0;
|
||||||
tmpp=peasant_head.next;
|
tmpp=peasant_head.next;
|
||||||
while (tmpp!=&peasant_head) {
|
while (tmpp!=&peasant_head) {
|
||||||
if (tmpp->stopped) {
|
if (tmpp->stopped) {
|
||||||
@ -388,12 +388,12 @@ U0 AnimateTask(I64)
|
|||||||
if (!animate_mS && animate_phase&1)
|
if (!animate_mS && animate_phase&1)
|
||||||
StepNew(Fs->parent_task,tmpp->x,tmpp->y,tmpp->é,
|
StepNew(Fs->parent_task,tmpp->x,tmpp->y,tmpp->é,
|
||||||
animate_phase&2,FALSE);
|
animate_phase&2,FALSE);
|
||||||
not_stopped_cnt++;
|
not_stopped_count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tmpp=tmpp->next;
|
tmpp=tmpp->next;
|
||||||
}
|
}
|
||||||
if (!not_stopped_cnt && !tf) {
|
if (!not_stopped_count && !tf) {
|
||||||
tf=tS;
|
tf=tS;
|
||||||
music.mute=TRUE;
|
music.mute=TRUE;
|
||||||
Snd(86);Sleep(200);Snd;Sleep(100);
|
Snd(86);Sleep(200);Snd;Sleep(100);
|
||||||
|
Binary file not shown.
@ -12,7 +12,7 @@ U0 DrawIt(CTask *,CDC *dc2)
|
|||||||
|
|
||||||
U0 AnimateTask(I64)
|
U0 AnimateTask(I64)
|
||||||
{
|
{
|
||||||
I64 x,y,x1,y1,cnt,next_dc;
|
I64 x,y,x1,y1,count,next_dc;
|
||||||
while (TRUE) {
|
while (TRUE) {
|
||||||
next_dc=cur_dc^1;
|
next_dc=cur_dc^1;
|
||||||
start_over:
|
start_over:
|
||||||
@ -20,20 +20,20 @@ start_over:
|
|||||||
DCClear(dc[next_dc]);
|
DCClear(dc[next_dc]);
|
||||||
for (y=1;y<Fs->parent_task->pix_height-1;y++) {
|
for (y=1;y<Fs->parent_task->pix_height-1;y++) {
|
||||||
for (x=1;x<Fs->parent_task->pix_width-1;x++) {
|
for (x=1;x<Fs->parent_task->pix_width-1;x++) {
|
||||||
cnt=0;
|
count=0;
|
||||||
for (y1=y-1;y1<=y+1;y1++)
|
for (y1=y-1;y1<=y+1;y1++)
|
||||||
for (x1=x-1;x1<=x+1;x1++)
|
for (x1=x-1;x1<=x+1;x1++)
|
||||||
if (GrPeek(dc[cur_dc],x1,y1)==GREEN)
|
if (GrPeek(dc[cur_dc],x1,y1)==GREEN)
|
||||||
cnt++;
|
count++;
|
||||||
if (restart) goto start_over;
|
if (restart) goto start_over;
|
||||||
if (GrPeek(dc[cur_dc],x,y)==GREEN) {
|
if (GrPeek(dc[cur_dc],x,y)==GREEN) {
|
||||||
if (cnt==3) {
|
if (count==3) {
|
||||||
dc[next_dc]->color=GREEN;
|
dc[next_dc]->color=GREEN;
|
||||||
GrPlot(dc[next_dc],x,y);
|
GrPlot(dc[next_dc],x,y);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// if (cnt==3) {//Use this for the classic rules
|
// if (count==3) {//Use this for the classic rules
|
||||||
if (cnt==2) {
|
if (count==2) {
|
||||||
dc[next_dc]->color=GREEN;
|
dc[next_dc]->color=GREEN;
|
||||||
GrPlot(dc[next_dc],x,y);
|
GrPlot(dc[next_dc],x,y);
|
||||||
}
|
}
|
||||||
@ -48,7 +48,7 @@ start_over:
|
|||||||
|
|
||||||
public U0 Life()
|
public U0 Life()
|
||||||
{
|
{
|
||||||
I64 message_code,cnt,x1,y1,x2,y2,arg1,arg2;
|
I64 message_code,count,x1,y1,x2,y2,arg1,arg2;
|
||||||
|
|
||||||
dc[0]=DCNew(GR_WIDTH,GR_HEIGHT);
|
dc[0]=DCNew(GR_WIDTH,GR_HEIGHT);
|
||||||
dc[1]=DCNew(GR_WIDTH,GR_HEIGHT);
|
dc[1]=DCNew(GR_WIDTH,GR_HEIGHT);
|
||||||
@ -71,7 +71,7 @@ public U0 Life()
|
|||||||
case MESSAGE_MS_L_DOWN:
|
case MESSAGE_MS_L_DOWN:
|
||||||
x1=arg1; y1=arg2;
|
x1=arg1; y1=arg2;
|
||||||
x2=arg1; y2=arg2;
|
x2=arg1; y2=arg2;
|
||||||
cnt=0;
|
count=0;
|
||||||
while (message_code!=MESSAGE_MS_L_UP) {
|
while (message_code!=MESSAGE_MS_L_UP) {
|
||||||
restart=TRUE;
|
restart=TRUE;
|
||||||
dc[cur_dc]->color=GREEN;
|
dc[cur_dc]->color=GREEN;
|
||||||
|
@ -8,18 +8,18 @@ class Photon
|
|||||||
{
|
{
|
||||||
Photon *next,*last;
|
Photon *next,*last;
|
||||||
CD3 p,v,n,p_normal_inhibit;
|
CD3 p,v,n,p_normal_inhibit;
|
||||||
} p_root[mp_cnt];
|
} p_root[mp_count];
|
||||||
I64 p_root_locks;
|
I64 p_root_locks;
|
||||||
|
|
||||||
#define ANIMATE_JIFFIES (JIFFY_FREQ*0.01)
|
#define ANIMATE_JIFFIES (JIFFY_FREQ*0.01)
|
||||||
I64 master_sleep_jiffy;
|
I64 master_sleep_jiffy;
|
||||||
CTask *animate_tasks[mp_cnt];
|
CTask *animate_tasks[mp_count];
|
||||||
|
|
||||||
#define LENS_COLOR WHITE
|
#define LENS_COLOR WHITE
|
||||||
#define MIRROR_COLOR DKGRAY
|
#define MIRROR_COLOR DKGRAY
|
||||||
CDC *map;
|
CDC *map;
|
||||||
|
|
||||||
I64 photon_cnt,mirror_cnt,snell_cnt,normal_inhibit,zero_normal;
|
I64 photon_count,mirror_count,snell_count,normal_inhibit,zero_normal;
|
||||||
Bool full_speed,show_normals;
|
Bool full_speed,show_normals;
|
||||||
|
|
||||||
U8 *bmp_refract,*bmp_reflect;
|
U8 *bmp_refract,*bmp_reflect;
|
||||||
@ -45,7 +45,7 @@ U0 BmpLine(U8 *bmp,F64 x1,F64 y1,F64 x2,F64 y2)
|
|||||||
|
|
||||||
Photon *PhotonNew()
|
Photon *PhotonNew()
|
||||||
{
|
{
|
||||||
I64 num=photon_cnt++%mp_cnt;
|
I64 num=photon_count++%mp_count;
|
||||||
Photon *res=CAlloc(sizeof(Photon));
|
Photon *res=CAlloc(sizeof(Photon));
|
||||||
while (LBts(&p_root_locks,num))
|
while (LBts(&p_root_locks,num))
|
||||||
Yield;
|
Yield;
|
||||||
@ -65,9 +65,9 @@ U0 DrawIt(CTask *,CDC *dc)
|
|||||||
bmp_mem,bmp_mem/1024/1024,bmp_scale,
|
bmp_mem,bmp_mem/1024/1024,bmp_scale,
|
||||||
map->width,map->height,bmp_width,bmp_height);
|
map->width,map->height,bmp_width,bmp_height);
|
||||||
GrPrint(dc,0,FONT_HEIGHT,
|
GrPrint(dc,0,FONT_HEIGHT,
|
||||||
"PhotonCnt:%d MirrorCnt:%d SnellCnt:%d SnellInhibit:%d ZeroNormal:%d",
|
"PhotonCount:%d MirrorCount:%d SnellCount:%d SnellInhibit:%d ZeroNormal:%d",
|
||||||
photon_cnt,mirror_cnt,snell_cnt,normal_inhibit,zero_normal);
|
photon_count,mirror_count,snell_count,normal_inhibit,zero_normal);
|
||||||
for (i=0;i<mp_cnt;i++) {
|
for (i=0;i<mp_count;i++) {
|
||||||
while (LBts(&p_root_locks,i))
|
while (LBts(&p_root_locks,i))
|
||||||
Yield;
|
Yield;
|
||||||
tmpp=p_root[i].next;
|
tmpp=p_root[i].next;
|
||||||
@ -236,7 +236,7 @@ U0 Mirror(Photon *tmpp)
|
|||||||
é$SY,3$n$SY,0$=Arg(tmpp->n.x,tmpp->n.y);
|
é$SY,3$n$SY,0$=Arg(tmpp->n.x,tmpp->n.y);
|
||||||
|
|
||||||
D3Equ(&tmpp->v,Cos(2*é$SY,3$n$SY,0$+ã-é),Sin(2*é$SY,3$n$SY,0$+ã-é));
|
D3Equ(&tmpp->v,Cos(2*é$SY,3$n$SY,0$+ã-é),Sin(2*é$SY,3$n$SY,0$+ã-é));
|
||||||
lock {mirror_cnt++;}
|
lock {mirror_count++;}
|
||||||
}
|
}
|
||||||
|
|
||||||
U0 SnellsLaw(Photon *tmpp,I64 last,I64 next)
|
U0 SnellsLaw(Photon *tmpp,I64 last,I64 next)
|
||||||
@ -264,15 +264,15 @@ U0 SnellsLaw(Photon *tmpp,I64 last,I64 next)
|
|||||||
é=é$SY,3$n$SY,0$-é2;
|
é=é$SY,3$n$SY,0$-é2;
|
||||||
|
|
||||||
D3Equ(&tmpp->v,Cos(é),Sin(é));
|
D3Equ(&tmpp->v,Cos(é),Sin(é));
|
||||||
lock {snell_cnt++;}
|
lock {snell_count++;}
|
||||||
}
|
}
|
||||||
|
|
||||||
U0 AnimateTask(I64)
|
U0 AnimateTask(I64)
|
||||||
{
|
{
|
||||||
while (TRUE) {
|
while (TRUE) {
|
||||||
master_sleep_jiffy+=ANIMATE_JIFFIES;
|
master_sleep_jiffy+=ANIMATE_JIFFIES;
|
||||||
if (cnts.jiffies>=master_sleep_jiffy)
|
if (counts.jiffies>=master_sleep_jiffy)
|
||||||
master_sleep_jiffy=cnts.jiffies+ANIMATE_JIFFIES;
|
master_sleep_jiffy=counts.jiffies+ANIMATE_JIFFIES;
|
||||||
SleepUntil(master_sleep_jiffy);
|
SleepUntil(master_sleep_jiffy);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -338,11 +338,11 @@ U0 MPAnimateTask(I64)
|
|||||||
}
|
}
|
||||||
|
|
||||||
tmpp=tmpp->next;
|
tmpp=tmpp->next;
|
||||||
if (cnts.jiffies>=timeout_jiffy)
|
if (counts.jiffies>=timeout_jiffy)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
LBtr(&p_root_locks,Gs->num);
|
LBtr(&p_root_locks,Gs->num);
|
||||||
if (cnts.jiffies>=timeout_jiffy) {
|
if (counts.jiffies>=timeout_jiffy) {
|
||||||
Sleep(1);
|
Sleep(1);
|
||||||
timeout_jiffy=master_sleep_jiffy+ANIMATE_JIFFIES;
|
timeout_jiffy=master_sleep_jiffy+ANIMATE_JIFFIES;
|
||||||
}
|
}
|
||||||
@ -359,11 +359,11 @@ U0 MPAnimateTask(I64)
|
|||||||
U0 Init()
|
U0 Init()
|
||||||
{
|
{
|
||||||
I64 i;
|
I64 i;
|
||||||
master_sleep_jiffy=cnts.jiffies;
|
master_sleep_jiffy=counts.jiffies;
|
||||||
full_speed=show_normals=FALSE;
|
full_speed=show_normals=FALSE;
|
||||||
photon_cnt=mirror_cnt=snell_cnt=normal_inhibit=zero_normal=0;
|
photon_count=mirror_count=snell_count=normal_inhibit=zero_normal=0;
|
||||||
map=DCNew(Fs->pix_width,Fs->pix_height);
|
map=DCNew(Fs->pix_width,Fs->pix_height);
|
||||||
for (i=0;i<mp_cnt;i++) {
|
for (i=0;i<mp_count;i++) {
|
||||||
while (LBts(&p_root_locks,i))
|
while (LBts(&p_root_locks,i))
|
||||||
Yield;
|
Yield;
|
||||||
QueueInit(&p_root[i]);
|
QueueInit(&p_root[i]);
|
||||||
@ -391,7 +391,7 @@ U0 Init()
|
|||||||
U0 CleanUp()
|
U0 CleanUp()
|
||||||
{
|
{
|
||||||
I64 i;
|
I64 i;
|
||||||
for (i=0;i<mp_cnt;i++) {
|
for (i=0;i<mp_count;i++) {
|
||||||
while (LBts(&p_root_locks,i))
|
while (LBts(&p_root_locks,i))
|
||||||
Yield;
|
Yield;
|
||||||
QueueDel(&p_root[i],TRUE);
|
QueueDel(&p_root[i],TRUE);
|
||||||
@ -452,7 +452,7 @@ U0 LTMenuSet(I64 mode)
|
|||||||
#define PTS_NUM 1024
|
#define PTS_NUM 1024
|
||||||
U0 LightTable()
|
U0 LightTable()
|
||||||
{
|
{
|
||||||
I64 message_code,mode=LTM_REFLECT_LINE,i,cnt,arg1,arg2,x1,y1,x2,y2;
|
I64 message_code,mode=LTM_REFLECT_LINE,i,count,arg1,arg2,x1,y1,x2,y2;
|
||||||
CD3I32 *c=MAlloc(PTS_NUM*sizeof(CD3I32));
|
CD3I32 *c=MAlloc(PTS_NUM*sizeof(CD3I32));
|
||||||
|
|
||||||
p_root_locks=0;
|
p_root_locks=0;
|
||||||
@ -500,7 +500,7 @@ U0 LightTable()
|
|||||||
Init;
|
Init;
|
||||||
Fs->draw_it=&DrawIt;
|
Fs->draw_it=&DrawIt;
|
||||||
Fs->animate_task=Spawn(&AnimateTask,NULL,"Animate",,Fs);
|
Fs->animate_task=Spawn(&AnimateTask,NULL,"Animate",,Fs);
|
||||||
for (i=0;i<mp_cnt;i++)
|
for (i=0;i<mp_count;i++)
|
||||||
animate_tasks[i]=Spawn(&MPAnimateTask,NULL,"MPAnimate",i);
|
animate_tasks[i]=Spawn(&MPAnimateTask,NULL,"MPAnimate",i);
|
||||||
try {
|
try {
|
||||||
while (TRUE) {
|
while (TRUE) {
|
||||||
@ -558,37 +558,37 @@ lt_restart:
|
|||||||
break;
|
break;
|
||||||
case LTM_REFLECT_SPLINE:
|
case LTM_REFLECT_SPLINE:
|
||||||
case LTM_REFRACT_SPLINE:
|
case LTM_REFRACT_SPLINE:
|
||||||
cnt=0;
|
count=0;
|
||||||
if (mode==LTM_REFLECT_SPLINE)
|
if (mode==LTM_REFLECT_SPLINE)
|
||||||
map->color=ROP_XOR+MIRROR_COLOR;
|
map->color=ROP_XOR+MIRROR_COLOR;
|
||||||
else
|
else
|
||||||
map->color=ROP_XOR+LENS_COLOR;
|
map->color=ROP_XOR+LENS_COLOR;
|
||||||
do {
|
do {
|
||||||
c[cnt].x=arg1; c[cnt].y=arg2; c[cnt].z=0;
|
c[count].x=arg1; c[count].y=arg2; c[count].z=0;
|
||||||
Gr2BSpline(map,c,cnt+1);
|
Gr2BSpline(map,c,count+1);
|
||||||
message_code=GetMessage(&arg1,&arg2,1<<MESSAGE_KEY_DOWN+1<<MESSAGE_MS_L_UP+
|
message_code=GetMessage(&arg1,&arg2,1<<MESSAGE_KEY_DOWN+1<<MESSAGE_MS_L_UP+
|
||||||
1<<MESSAGE_MS_MOVE+1<<MESSAGE_MS_R_UP);
|
1<<MESSAGE_MS_MOVE+1<<MESSAGE_MS_R_UP);
|
||||||
Gr2BSpline(map,c,cnt+1);
|
Gr2BSpline(map,c,count+1);
|
||||||
if (message_code==MESSAGE_KEY_DOWN)
|
if (message_code==MESSAGE_KEY_DOWN)
|
||||||
goto lt_restart;
|
goto lt_restart;
|
||||||
else if (message_code==MESSAGE_MS_L_UP) {
|
else if (message_code==MESSAGE_MS_L_UP) {
|
||||||
Sweep(100,90,100);
|
Sweep(100,90,100);
|
||||||
cnt++;
|
count++;
|
||||||
}
|
}
|
||||||
} while (cnt<PTS_NUM-1 && message_code!=MESSAGE_MS_R_UP);
|
} while (count<PTS_NUM-1 && message_code!=MESSAGE_MS_R_UP);
|
||||||
if (mode==LTM_REFLECT_SPLINE)
|
if (mode==LTM_REFLECT_SPLINE)
|
||||||
map->color=MIRROR_COLOR;
|
map->color=MIRROR_COLOR;
|
||||||
else
|
else
|
||||||
map->color=LENS_COLOR;
|
map->color=LENS_COLOR;
|
||||||
Gr2BSpline3(map,c,cnt);
|
Gr2BSpline3(map,c,count);
|
||||||
for (i=0;i<cnt;i++) {
|
for (i=0;i<count;i++) {
|
||||||
c[i].x*=bmp_scale;
|
c[i].x*=bmp_scale;
|
||||||
c[i].y*=bmp_scale;
|
c[i].y*=bmp_scale;
|
||||||
}
|
}
|
||||||
if (mode==LTM_REFLECT_SPLINE)
|
if (mode==LTM_REFLECT_SPLINE)
|
||||||
BSpline2(bmp_reflect,c,cnt,&BmpPlot);
|
BSpline2(bmp_reflect,c,count,&BmpPlot);
|
||||||
else
|
else
|
||||||
BSpline2(bmp_refract,c,cnt,&BmpPlot);
|
BSpline2(bmp_refract,c,count,&BmpPlot);
|
||||||
mode=LTM_REFLECT_LINE;
|
mode=LTM_REFLECT_LINE;
|
||||||
LTMenuSet(mode);
|
LTMenuSet(mode);
|
||||||
break;
|
break;
|
||||||
@ -640,7 +640,7 @@ lt_done:
|
|||||||
PutExcept;
|
PutExcept;
|
||||||
Free(c);
|
Free(c);
|
||||||
SettingsPop;
|
SettingsPop;
|
||||||
for (i=0;i<mp_cnt;i++)
|
for (i=0;i<mp_count;i++)
|
||||||
Kill(animate_tasks[i]);
|
Kill(animate_tasks[i]);
|
||||||
CleanUp;
|
CleanUp;
|
||||||
MenuPop;
|
MenuPop;
|
||||||
|
Binary file not shown.
@ -47,7 +47,7 @@ F64 MPDraw(CTask *task)
|
|||||||
{
|
{
|
||||||
Complex xx;
|
Complex xx;
|
||||||
I64 x,y,w=task->pix_width,h=task->pix_height,cx=w/2,cy=h/2,
|
I64 x,y,w=task->pix_width,h=task->pix_height,cx=w/2,cy=h/2,
|
||||||
lo=Gs->num*h/mp_cnt,hi=(Gs->num+1)*h/mp_cnt;
|
lo=Gs->num*h/mp_count,hi=(Gs->num+1)*h/mp_count;
|
||||||
F64 yy,y_total=0;
|
F64 yy,y_total=0;
|
||||||
CDC *dc=DCAlias(,task);
|
CDC *dc=DCAlias(,task);
|
||||||
for (y=lo;y<hi;y++) {
|
for (y=lo;y<hi;y++) {
|
||||||
@ -70,10 +70,10 @@ U0 Draw()
|
|||||||
I64 i,w=Fs->pix_width,h=Fs->pix_height,cx=w/2,cy=h/2;
|
I64 i,w=Fs->pix_width,h=Fs->pix_height,cx=w/2,cy=h/2;
|
||||||
CDC *dc=DCAlias;
|
CDC *dc=DCAlias;
|
||||||
while (TRUE) {
|
while (TRUE) {
|
||||||
for (i=0;i<mp_cnt;i++)
|
for (i=0;i<mp_count;i++)
|
||||||
tmpm[i]=JobQueue(&MPDraw,Fs,i,0);
|
tmpm[i]=JobQueue(&MPDraw,Fs,i,0);
|
||||||
y_total=0;
|
y_total=0;
|
||||||
for (i=0;i<mp_cnt;i++)
|
for (i=0;i<mp_count;i++)
|
||||||
y_total+=JobResGet(tmpm[i])(F64);
|
y_total+=JobResGet(tmpm[i])(F64);
|
||||||
|
|
||||||
if (!y_total) break;
|
if (!y_total) break;
|
||||||
|
@ -65,8 +65,8 @@ U0 PredatorPrey()
|
|||||||
GrLine(dc,OX,0,OX,GR_HEIGHT-FONT_HEIGHT-1);
|
GrLine(dc,OX,0,OX,GR_HEIGHT-FONT_HEIGHT-1);
|
||||||
GrLine(dc,0,OY,GR_WIDTH-1,OY);
|
GrLine(dc,0,OY,GR_WIDTH-1,OY);
|
||||||
while (!ScanChar) {
|
while (!ScanChar) {
|
||||||
mp_not_done_flags=1<<mp_cnt-1;
|
mp_not_done_flags=1<<mp_count-1;
|
||||||
for (i=0;i<mp_cnt;i++)
|
for (i=0;i<mp_count;i++)
|
||||||
JobQueue(&PlotTrajectory,Fs,i);
|
JobQueue(&PlotTrajectory,Fs,i);
|
||||||
do Yield;
|
do Yield;
|
||||||
while (mp_not_done_flags);
|
while (mp_not_done_flags);
|
||||||
|
Binary file not shown.
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
public U0 SpeedLineDemo()
|
public U0 SpeedLineDemo()
|
||||||
{
|
{
|
||||||
I64 message_code,cnt,x1,y1,x2,y2,arg1,arg2,color=BLACK;
|
I64 message_code,count,x1,y1,x2,y2,arg1,arg2,color=BLACK;
|
||||||
CDC *dc=DCAlias;
|
CDC *dc=DCAlias;
|
||||||
dc->color=color;
|
dc->color=color;
|
||||||
|
|
||||||
@ -26,7 +26,7 @@ public U0 SpeedLineDemo()
|
|||||||
case MESSAGE_MS_L_DOWN:
|
case MESSAGE_MS_L_DOWN:
|
||||||
x1=arg1; y1=arg2;
|
x1=arg1; y1=arg2;
|
||||||
x2=arg1; y2=arg2;
|
x2=arg1; y2=arg2;
|
||||||
cnt=0;
|
count=0;
|
||||||
while (message_code!=MESSAGE_MS_L_UP) {
|
while (message_code!=MESSAGE_MS_L_UP) {
|
||||||
dc->thick=0.04*ms.speed;
|
dc->thick=0.04*ms.speed;
|
||||||
GrLine3(dc,x1,y1,0,x2,y2,0);
|
GrLine3(dc,x1,y1,0,x2,y2,0);
|
||||||
|
Binary file not shown.
@ -1,6 +1,6 @@
|
|||||||
//See $LK,"PCI",A="HI:PCI"$.
|
//See $LK,"PCI",A="HI:PCI"$.
|
||||||
|
|
||||||
#if mp_cnt>1
|
#if mp_count>1
|
||||||
#define DEST_CPU 1
|
#define DEST_CPU 1
|
||||||
#else
|
#else
|
||||||
#define DEST_CPU 0
|
#define DEST_CPU 0
|
||||||
@ -56,7 +56,7 @@ U0 Main()
|
|||||||
Sleep(1000);
|
Sleep(1000);
|
||||||
"The keyboard and timer seem to be active.\n"
|
"The keyboard and timer seem to be active.\n"
|
||||||
"IntA:%d IntB:%d IntC:%d IntD:%d\n\n"
|
"IntA:%d IntB:%d IntC:%d IntD:%d\n\n"
|
||||||
"IntB is my keybaord and regs a single KEY-UP.\n"
|
"IntB is my keyboard and regs a single KEY-UP.\n"
|
||||||
"Rerun and press a few keys.\n",
|
"Rerun and press a few keys.\n",
|
||||||
progress1,progress2,progress3,progress4;
|
progress1,progress2,progress3,progress4;
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ class PowPrime
|
|||||||
|
|
||||||
class Prime
|
class Prime
|
||||||
{
|
{
|
||||||
U32 prime,pow_cnt;
|
U32 prime,pow_count;
|
||||||
PowPrime *pp;
|
PowPrime *pp;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -110,7 +110,7 @@ PowPrime *PowPrimesNew(I64 N,I64 sqrt_primes,Prime *primes,I64 *_num_powprimes)
|
|||||||
pp->sumfact=sf;
|
pp->sumfact=sf;
|
||||||
j*=p->prime;
|
j*=p->prime;
|
||||||
pp++;
|
pp++;
|
||||||
p->pow_cnt++;
|
p->pow_count++;
|
||||||
}
|
}
|
||||||
p++;
|
p++;
|
||||||
}
|
}
|
||||||
@ -259,32 +259,32 @@ class RangeJob
|
|||||||
I64 num,lo,hi,N,sqrt_primes,cbrt_primes;
|
I64 num,lo,hi,N,sqrt_primes,cbrt_primes;
|
||||||
Prime *primes;
|
Prime *primes;
|
||||||
CJob *cmd;
|
CJob *cmd;
|
||||||
} rj[mp_cnt];
|
} rj[mp_count];
|
||||||
|
|
||||||
I64 TestCoreSubRange(RangeJob *r)
|
I64 TestCoreSubRange(RangeJob *r)
|
||||||
{
|
{
|
||||||
I64 i,j,m,n,n2,sf,res=0,range=r->hi-r->lo,
|
I64 i,j,m,n,n2,sf,res=0,range=r->hi-r->lo,
|
||||||
*sumfacts=MAlloc(range*sizeof(I64)),
|
*sumfacts=MAlloc(range*sizeof(I64)),
|
||||||
*residue =MAlloc(range*sizeof(I64));
|
*residue =MAlloc(range*sizeof(I64));
|
||||||
U16 *pow_cnt =MAlloc(range*sizeof(U16));
|
U16 *pow_count =MAlloc(range*sizeof(U16));
|
||||||
Prime *p=r->primes;
|
Prime *p=r->primes;
|
||||||
PowPrime *pp;
|
PowPrime *pp;
|
||||||
MemSetI64(sumfacts,1,range);
|
MemSetI64(sumfacts,1,range);
|
||||||
for (n=r->lo;n<r->hi;n++)
|
for (n=r->lo;n<r->hi;n++)
|
||||||
residue[n-r->lo]=n;
|
residue[n-r->lo]=n;
|
||||||
for (j=0;j<r->sqrt_primes;j++) {
|
for (j=0;j<r->sqrt_primes;j++) {
|
||||||
MemSet(pow_cnt,0,range*sizeof(U16));
|
MemSet(pow_count,0,range*sizeof(U16));
|
||||||
m=1;
|
m=1;
|
||||||
for (i=0;i<p->pow_cnt;i++) {
|
for (i=0;i<p->pow_count;i++) {
|
||||||
m*=p->prime;
|
m*=p->prime;
|
||||||
n=m-r->lo%m;
|
n=m-r->lo%m;
|
||||||
while (n<range) {
|
while (n<range) {
|
||||||
pow_cnt[n]++;
|
pow_count[n]++;
|
||||||
n+=m;
|
n+=m;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (n=0;n<range;n++)
|
for (n=0;n<range;n++)
|
||||||
if (i=pow_cnt[n]) {
|
if (i=pow_count[n]) {
|
||||||
pp=&p->pp[i-1];
|
pp=&p->pp[i-1];
|
||||||
sumfacts[n]*=pp->sumfact;
|
sumfacts[n]*=pp->sumfact;
|
||||||
residue [n]/=pp->n;
|
residue [n]/=pp->n;
|
||||||
@ -307,7 +307,7 @@ I64 TestCoreSubRange(RangeJob *r)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Free(pow_cnt);
|
Free(pow_count);
|
||||||
Free(residue);
|
Free(residue);
|
||||||
Free(sumfacts);
|
Free(sumfacts);
|
||||||
return res;
|
return res;
|
||||||
@ -340,7 +340,7 @@ I64 MagicPairs(I64 N)
|
|||||||
F64 t0=tS;
|
F64 t0=tS;
|
||||||
I64 res=0;
|
I64 res=0;
|
||||||
I64 sqrt_primes,cbrt_primes,num_powprimes,
|
I64 sqrt_primes,cbrt_primes,num_powprimes,
|
||||||
i,k,n=(N-1)/mp_cnt+1;
|
i,k,n=(N-1)/mp_count+1;
|
||||||
Prime *primes=PrimesNew(N,&sqrt_primes,&cbrt_primes);
|
Prime *primes=PrimesNew(N,&sqrt_primes,&cbrt_primes);
|
||||||
PowPrime *powprimes=PowPrimesNew(N,sqrt_primes,primes,&num_powprimes);
|
PowPrime *powprimes=PowPrimesNew(N,sqrt_primes,primes,&num_powprimes);
|
||||||
|
|
||||||
@ -350,7 +350,7 @@ I64 MagicPairs(I64 N)
|
|||||||
*progress1_desc=0;
|
*progress1_desc=0;
|
||||||
progress1_max=N;
|
progress1_max=N;
|
||||||
k=2;
|
k=2;
|
||||||
for (i=0;i<mp_cnt;i++) {
|
for (i=0;i<mp_count;i++) {
|
||||||
rj[i].doc=DocPut;
|
rj[i].doc=DocPut;
|
||||||
rj[i].num=i;
|
rj[i].num=i;
|
||||||
rj[i].lo=k;
|
rj[i].lo=k;
|
||||||
@ -361,9 +361,9 @@ I64 MagicPairs(I64 N)
|
|||||||
rj[i].sqrt_primes=sqrt_primes;
|
rj[i].sqrt_primes=sqrt_primes;
|
||||||
rj[i].cbrt_primes=cbrt_primes;
|
rj[i].cbrt_primes=cbrt_primes;
|
||||||
rj[i].primes=primes;
|
rj[i].primes=primes;
|
||||||
rj[i].cmd=JobQueue(&TestCoreRange,&rj[i],mp_cnt-1-i,0);
|
rj[i].cmd=JobQueue(&TestCoreRange,&rj[i],mp_count-1-i,0);
|
||||||
}
|
}
|
||||||
for (i=0;i<mp_cnt;i++)
|
for (i=0;i<mp_count;i++)
|
||||||
res+=JobResGet(rj[i].cmd);
|
res+=JobResGet(rj[i].cmd);
|
||||||
Free(powprimes);
|
Free(powprimes);
|
||||||
Free(primes);
|
Free(primes);
|
||||||
|
@ -26,7 +26,7 @@ U0 UnlockedInc()
|
|||||||
tmpm1=JobQueue(&MPUnlockedInc,NULL,1,0);
|
tmpm1=JobQueue(&MPUnlockedInc,NULL,1,0);
|
||||||
JobResGet(tmpm0);
|
JobResGet(tmpm0);
|
||||||
JobResGet(tmpm1);
|
JobResGet(tmpm1);
|
||||||
"Correct Cnt:%X Actual Cnt:%X\n",CNT*2,glbl;
|
"Correct Count:%X Actual Count:%X\n",CNT*2,glbl;
|
||||||
}
|
}
|
||||||
|
|
||||||
U0 MPLockedInc(I64)
|
U0 MPLockedInc(I64)
|
||||||
@ -45,7 +45,7 @@ U0 LockedInc()
|
|||||||
tmpm1=JobQueue(&MPLockedInc,NULL,1,0);
|
tmpm1=JobQueue(&MPLockedInc,NULL,1,0);
|
||||||
JobResGet(tmpm0);
|
JobResGet(tmpm0);
|
||||||
JobResGet(tmpm1);
|
JobResGet(tmpm1);
|
||||||
"Correct Cnt:%X Actual Cnt:%X\n",CNT*2,glbl;
|
"Correct Count:%X Actual Count:%X\n",CNT*2,glbl;
|
||||||
}
|
}
|
||||||
|
|
||||||
UnlockedInc;
|
UnlockedInc;
|
||||||
|
@ -1,36 +1,36 @@
|
|||||||
I64 mp_n;
|
I64 mp_n;
|
||||||
|
|
||||||
I64 MPSum(I64 my_mp_cnt)
|
I64 MPSum(I64 my_mp_count)
|
||||||
{//We could use the formula n*(n+1)/2
|
{//We could use the formula n*(n+1)/2
|
||||||
I64 lo=mp_n*Gs->num/my_mp_cnt,
|
I64 lo=mp_n*Gs->num/my_mp_count,
|
||||||
hi=mp_n*(Gs->num+1)/my_mp_cnt,
|
hi=mp_n*(Gs->num+1)/my_mp_count,
|
||||||
res=0,i;
|
res=0,i;
|
||||||
for (i=lo;i<hi;i++)
|
for (i=lo;i<hi;i++)
|
||||||
res+=i;
|
res+=i;
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
I64 Sum(I64 n,I64 my_mp_cnt)
|
I64 Sum(I64 n,I64 my_mp_count)
|
||||||
{
|
{
|
||||||
CJob *tmpm[MP_PROCESSORS_NUM];
|
CJob *tmpm[MP_PROCESSORS_NUM];
|
||||||
I64 res=0,i;
|
I64 res=0,i;
|
||||||
mp_n=n+1;
|
mp_n=n+1;
|
||||||
for (i=0;i<my_mp_cnt;i++)
|
for (i=0;i<my_mp_count;i++)
|
||||||
tmpm[i]=JobQueue(&MPSum,my_mp_cnt,i,0);
|
tmpm[i]=JobQueue(&MPSum,my_mp_count,i,0);
|
||||||
for (i=0;i<my_mp_cnt;i++)
|
for (i=0;i<my_mp_count;i++)
|
||||||
res+=JobResGet(tmpm[i]);
|
res+=JobResGet(tmpm[i]);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define SAMPLE_SIZE 100
|
#define SAMPLE_SIZE 100
|
||||||
|
|
||||||
F64 Test(I64 n,I64 my_mp_cnt)
|
F64 Test(I64 n,I64 my_mp_count)
|
||||||
{
|
{
|
||||||
I64 i,val=0;
|
I64 i,val=0;
|
||||||
F64 start,end;
|
F64 start,end;
|
||||||
start=tS;
|
start=tS;
|
||||||
for (i=0;i<SAMPLE_SIZE;i++)
|
for (i=0;i<SAMPLE_SIZE;i++)
|
||||||
val+=Sum(n,my_mp_cnt);
|
val+=Sum(n,my_mp_count);
|
||||||
end=tS;
|
end=tS;
|
||||||
"Val:%,d\n",val/SAMPLE_SIZE;
|
"Val:%,d\n",val/SAMPLE_SIZE;
|
||||||
"$$RED$$N:%12,d Time:%10.8f$$FG$$\n",n,(end-start)/SAMPLE_SIZE;
|
"$$RED$$N:%12,d Time:%10.8f$$FG$$\n",n,(end-start)/SAMPLE_SIZE;
|
||||||
@ -53,7 +53,7 @@ U0 MPAdd()
|
|||||||
|
|
||||||
for (i=0,n=VAL_MIN;i<TESTS_NUM;i++,n*=10) {
|
for (i=0,n=VAL_MIN;i<TESTS_NUM;i++,n*=10) {
|
||||||
t1=Test(n,1);
|
t1=Test(n,1);
|
||||||
t2=Test(n,mp_cnt);
|
t2=Test(n,mp_count);
|
||||||
ress[i]=t2*100.0/t1;
|
ress[i]=t2*100.0/t1;
|
||||||
"$$GREEN$$%8.4f%%$$FG$$\n\n",ress[i];
|
"$$GREEN$$%8.4f%%$$FG$$\n\n",ress[i];
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ U0 MPPrintDemo()
|
|||||||
{
|
{
|
||||||
I64 i;
|
I64 i;
|
||||||
for (i=0;i<500;i++)
|
for (i=0;i<500;i++)
|
||||||
JobQueue(&Job,DocPut,i%mp_cnt);
|
JobQueue(&Job,DocPut,i%mp_count);
|
||||||
Sleep(500);
|
Sleep(500);
|
||||||
"$$FG$$\n";
|
"$$FG$$\n";
|
||||||
}
|
}
|
||||||
|
@ -6,10 +6,10 @@ for sorting. Then, it merge sorts them.
|
|||||||
|
|
||||||
#define NUM 1000000
|
#define NUM 1000000
|
||||||
|
|
||||||
I64 my_mp_cnt=1<<Bsr(mp_cnt);//Power of 2
|
I64 my_mp_count=1<<Bsr(mp_count);//Power of 2
|
||||||
|
|
||||||
I32 *arg1,*arg2;
|
I32 *arg1,*arg2;
|
||||||
I32 *b[my_mp_cnt],bn[my_mp_cnt];
|
I32 *b[my_mp_count],bn[my_mp_count];
|
||||||
I64 mp_not_done_flags;
|
I64 mp_not_done_flags;
|
||||||
|
|
||||||
I64 Compare(I32 *e1,I32 *e2)
|
I64 Compare(I32 *e1,I32 *e2)
|
||||||
@ -93,7 +93,7 @@ U0 MPRadixSortDemo(I64 dummy=0)
|
|||||||
"Time:%9.6f\n",tS-t0;
|
"Time:%9.6f\n",tS-t0;
|
||||||
D(arg2+NUM/4);
|
D(arg2+NUM/4);
|
||||||
|
|
||||||
for (i=0;i<my_mp_cnt;i++) {
|
for (i=0;i<my_mp_count;i++) {
|
||||||
//$WW,0$We must do full size, just in case.
|
//$WW,0$We must do full size, just in case.
|
||||||
//There will be uneven split between cores
|
//There will be uneven split between cores
|
||||||
//depending on the distribution of rand numbers.
|
//depending on the distribution of rand numbers.
|
||||||
@ -101,23 +101,23 @@ U0 MPRadixSortDemo(I64 dummy=0)
|
|||||||
bn[i]=0;
|
bn[i]=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (my_mp_cnt<2) throw('MultCore');
|
if (my_mp_count<2) throw('MultCore');
|
||||||
|
|
||||||
"$$GREEN$$MP Radix QSortU32$$FG$$\n";
|
"$$GREEN$$MP Radix QSortU32$$FG$$\n";
|
||||||
t0=tS;
|
t0=tS;
|
||||||
k1=32-Bsr(my_mp_cnt);
|
k1=32-Bsr(my_mp_count);
|
||||||
k2=my_mp_cnt/2;
|
k2=my_mp_count/2;
|
||||||
for (i=0;i<NUM;i++) {
|
for (i=0;i<NUM;i++) {
|
||||||
j=arg1[i]>>k1+k2; //This is a preliminary radix sort.
|
j=arg1[i]>>k1+k2; //This is a preliminary radix sort.
|
||||||
b[j][bn[j]++]=arg1[i];
|
b[j][bn[j]++]=arg1[i];
|
||||||
}
|
}
|
||||||
mp_not_done_flags=1<<my_mp_cnt-1;
|
mp_not_done_flags=1<<my_mp_count-1;
|
||||||
for (i=0;i<my_mp_cnt;i++)
|
for (i=0;i<my_mp_count;i++)
|
||||||
Spawn(&MPSort,NULL,NULL,i);
|
Spawn(&MPSort,NULL,NULL,i);
|
||||||
while (mp_not_done_flags)
|
while (mp_not_done_flags)
|
||||||
Yield;
|
Yield;
|
||||||
j=0;
|
j=0;
|
||||||
for (i=0;i<my_mp_cnt;i++) {
|
for (i=0;i<my_mp_count;i++) {
|
||||||
MemCpy(&arg2[j],b[i],bn[i]*sizeof(I32));
|
MemCpy(&arg2[j],b[i],bn[i]*sizeof(I32));
|
||||||
j+=bn[i];
|
j+=bn[i];
|
||||||
}
|
}
|
||||||
@ -126,7 +126,7 @@ U0 MPRadixSortDemo(I64 dummy=0)
|
|||||||
|
|
||||||
Free(arg1);
|
Free(arg1);
|
||||||
Free(arg2);
|
Free(arg2);
|
||||||
for (i=0;i<my_mp_cnt;i++)
|
for (i=0;i<my_mp_count;i++)
|
||||||
Free(b[i]);
|
Free(b[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,10 +37,10 @@ U0 PDAnswer(U8 *a,I64 len)
|
|||||||
U0 MPPalindrome(I64 dummy=0)
|
U0 MPPalindrome(I64 dummy=0)
|
||||||
{
|
{
|
||||||
no_warn dummy;
|
no_warn dummy;
|
||||||
U8 *src=buf+BORDER_CHARS+size*Gs->num/mp_cnt,
|
U8 *src=buf+BORDER_CHARS+size*Gs->num/mp_count,
|
||||||
*f,*b;
|
*f,*b;
|
||||||
I64 len,best=0,
|
I64 len,best=0,
|
||||||
my_size=(size+mp_cnt-1)/mp_cnt;
|
my_size=(size+mp_count-1)/mp_count;
|
||||||
while (my_size--) {
|
while (my_size--) {
|
||||||
|
|
||||||
//Odd
|
//Odd
|
||||||
@ -83,8 +83,8 @@ U0 Palindrome(U8 *filename)
|
|||||||
PDNormalize;
|
PDNormalize;
|
||||||
|
|
||||||
doc=DocPut;
|
doc=DocPut;
|
||||||
mp_not_done_flags=1<<mp_cnt-1;
|
mp_not_done_flags=1<<mp_count-1;
|
||||||
for (i=0;i<mp_cnt;i++)
|
for (i=0;i<mp_count;i++)
|
||||||
JobQueue(&MPPalindrome,NULL,i);
|
JobQueue(&MPPalindrome,NULL,i);
|
||||||
while (mp_not_done_flags)
|
while (mp_not_done_flags)
|
||||||
Yield;
|
Yield;
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
U8 *master_bitmap;
|
U8 *master_bitmap;
|
||||||
I64 prime_range,my_mp_cnt,pending;
|
I64 prime_range,my_mp_count,pending;
|
||||||
|
|
||||||
U0 PrimesJob(I64 i)
|
U0 PrimesJob(I64 i)
|
||||||
{
|
{
|
||||||
I64 j,k,l=Sqrt(prime_range),
|
I64 j,k,l=Sqrt(prime_range),
|
||||||
lo=i*prime_range/my_mp_cnt,
|
lo=i*prime_range/my_mp_count,
|
||||||
hi=(i+1)*prime_range/my_mp_cnt,
|
hi=(i+1)*prime_range/my_mp_count,
|
||||||
lo2=lo+sys_cache_line_width,
|
lo2=lo+sys_cache_line_width,
|
||||||
hi2=hi-sys_cache_line_width;
|
hi2=hi-sys_cache_line_width;
|
||||||
if (lo2>hi2) lo2=hi2;
|
if (lo2>hi2) lo2=hi2;
|
||||||
@ -35,20 +35,20 @@ U0 PrimesJob(I64 i)
|
|||||||
lock pending--;
|
lock pending--;
|
||||||
}
|
}
|
||||||
|
|
||||||
I64 Primes(I64 range,I64 _my_mp_cnt)
|
I64 Primes(I64 range,I64 _my_mp_count)
|
||||||
{
|
{
|
||||||
I64 i,prime_cnt=0;
|
I64 i,prime_count=0;
|
||||||
F64 t0=tS,tf;
|
F64 t0=tS,tf;
|
||||||
prime_range=range;
|
prime_range=range;
|
||||||
if (_my_mp_cnt<=mp_cnt)
|
if (_my_mp_count<=mp_count)
|
||||||
my_mp_cnt=_my_mp_cnt;
|
my_mp_count=_my_mp_count;
|
||||||
else
|
else
|
||||||
my_mp_cnt=mp_cnt;
|
my_mp_count=mp_count;
|
||||||
master_bitmap=CAlloc((prime_range+7)/8+1);
|
master_bitmap=CAlloc((prime_range+7)/8+1);
|
||||||
Bts(master_bitmap,0);
|
Bts(master_bitmap,0);
|
||||||
Bts(master_bitmap,1);
|
Bts(master_bitmap,1);
|
||||||
pending=my_mp_cnt;
|
pending=my_mp_count;
|
||||||
for (i=0;i<my_mp_cnt;i++)
|
for (i=0;i<my_mp_count;i++)
|
||||||
JobQueue(&PrimesJob,i,i);
|
JobQueue(&PrimesJob,i,i);
|
||||||
while (pending)
|
while (pending)
|
||||||
Yield;
|
Yield;
|
||||||
@ -56,20 +56,20 @@ I64 Primes(I64 range,I64 _my_mp_cnt)
|
|||||||
|
|
||||||
for (i=0;i<prime_range;i++)
|
for (i=0;i<prime_range;i++)
|
||||||
if (!Bt(master_bitmap,i))
|
if (!Bt(master_bitmap,i))
|
||||||
prime_cnt++;
|
prime_count++;
|
||||||
|
|
||||||
for (i=MaxI64(prime_range-100,0);i<prime_range;i++)
|
for (i=MaxI64(prime_range-100,0);i<prime_range;i++)
|
||||||
if (!Bt(master_bitmap,i))
|
if (!Bt(master_bitmap,i))
|
||||||
"%d ",i;
|
"%d ",i;
|
||||||
|
|
||||||
"\n$$RED$$CPUs:%d PrimeRange:%,d PrimeCnt:%,d Time:%9.7,f$$FG$$\n",
|
"\n$$RED$$CPUs:%d PrimeRange:%,d PrimeCount:%,d Time:%9.7,f$$FG$$\n",
|
||||||
my_mp_cnt,prime_range,prime_cnt,tf-t0;
|
my_mp_count,prime_range,prime_count,tf-t0;
|
||||||
|
|
||||||
Free(master_bitmap);
|
Free(master_bitmap);
|
||||||
return prime_cnt;
|
return prime_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
Primes(100,1);
|
Primes(100,1);
|
||||||
Primes(100,mp_cnt);
|
Primes(100,mp_count);
|
||||||
Primes(1000000,1);
|
Primes(1000000,1);
|
||||||
Primes(1000000,mp_cnt);
|
Primes(1000000,mp_count);
|
||||||
|
@ -5,8 +5,8 @@ I64 mp_not_done_flags,grand_total;
|
|||||||
U0 MPRoutine(CDoc *doc)
|
U0 MPRoutine(CDoc *doc)
|
||||||
{
|
{
|
||||||
I64 i,sum=0,
|
I64 i,sum=0,
|
||||||
lo=NUM*Gs->num/mp_cnt, //This is how to divide a job
|
lo=NUM*Gs->num/mp_count, //This is how to divide a job
|
||||||
hi=NUM*(Gs->num+1)/mp_cnt;
|
hi=NUM*(Gs->num+1)/mp_count;
|
||||||
for (i=lo;i<hi;i++)
|
for (i=lo;i<hi;i++)
|
||||||
sum+=i;
|
sum+=i;
|
||||||
DocPrint(doc,"Core#%d:%d-%d:%d\n",Gs->num,lo,hi-1,sum);
|
DocPrint(doc,"Core#%d:%d-%d:%d\n",Gs->num,lo,hi-1,sum);
|
||||||
@ -18,8 +18,8 @@ U0 Main()
|
|||||||
{
|
{
|
||||||
I64 i;
|
I64 i;
|
||||||
grand_total=0;
|
grand_total=0;
|
||||||
mp_not_done_flags=1<<mp_cnt-1;
|
mp_not_done_flags=1<<mp_count-1;
|
||||||
for (i=0;i<mp_cnt;i++)
|
for (i=0;i<mp_count;i++)
|
||||||
Spawn(&MPRoutine,DocPut,NULL,i);
|
Spawn(&MPRoutine,DocPut,NULL,i);
|
||||||
while (mp_not_done_flags)
|
while (mp_not_done_flags)
|
||||||
Yield;
|
Yield;
|
||||||
|
@ -17,7 +17,7 @@ class LinkStruct
|
|||||||
{
|
{
|
||||||
LinkStruct *left,*right;
|
LinkStruct *left,*right;
|
||||||
U8 *link,*file;
|
U8 *link,*file;
|
||||||
I64 cnt;
|
I64 count;
|
||||||
};
|
};
|
||||||
|
|
||||||
class BlockedStruct
|
class BlockedStruct
|
||||||
@ -262,7 +262,7 @@ U0 LinkTreeAdd(LinkStruct **_root,LogStruct *tmplg)
|
|||||||
}
|
}
|
||||||
if (root=*_root) {
|
if (root=*_root) {
|
||||||
if (!(i=StrCmp(tmplg->link,root->link)))
|
if (!(i=StrCmp(tmplg->link,root->link)))
|
||||||
root->cnt++;
|
root->count++;
|
||||||
else if (i<0)
|
else if (i<0)
|
||||||
LinkTreeAdd(&root->left,tmplg);
|
LinkTreeAdd(&root->left,tmplg);
|
||||||
else
|
else
|
||||||
@ -270,7 +270,7 @@ U0 LinkTreeAdd(LinkStruct **_root,LogStruct *tmplg)
|
|||||||
} else {
|
} else {
|
||||||
tmplk=CAlloc(sizeof(LinkStruct));
|
tmplk=CAlloc(sizeof(LinkStruct));
|
||||||
tmplk->link=tmplg->link;
|
tmplk->link=tmplg->link;
|
||||||
tmplk->cnt=1;
|
tmplk->count=1;
|
||||||
*_root=tmplk;
|
*_root=tmplk;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -285,7 +285,7 @@ U0 FileTreeAdd(LinkStruct **_root,LogStruct *tmplg)
|
|||||||
}
|
}
|
||||||
if (root=*_root) {
|
if (root=*_root) {
|
||||||
if (!(i=StrCmp(tmplg->file,root->file)))
|
if (!(i=StrCmp(tmplg->file,root->file)))
|
||||||
root->cnt++;
|
root->count++;
|
||||||
else if (i<0)
|
else if (i<0)
|
||||||
FileTreeAdd(&root->left,tmplg);
|
FileTreeAdd(&root->left,tmplg);
|
||||||
else
|
else
|
||||||
@ -293,7 +293,7 @@ U0 FileTreeAdd(LinkStruct **_root,LogStruct *tmplg)
|
|||||||
} else {
|
} else {
|
||||||
tmplk=CAlloc(sizeof(LinkStruct));
|
tmplk=CAlloc(sizeof(LinkStruct));
|
||||||
tmplk->file=tmplg->file;
|
tmplk->file=tmplg->file;
|
||||||
tmplk->cnt=1;
|
tmplk->count=1;
|
||||||
*_root=tmplk;
|
*_root=tmplk;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -311,7 +311,7 @@ U0 LinkTreeTraverse(LinkStruct *root)
|
|||||||
{
|
{
|
||||||
if (root) {
|
if (root) {
|
||||||
LinkTreeTraverse(root->left);
|
LinkTreeTraverse(root->left);
|
||||||
"%3d:%$$Q\n",root->cnt,root->link;
|
"%3d:%$$Q\n",root->count,root->link;
|
||||||
LinkTreeTraverse(root->right);
|
LinkTreeTraverse(root->right);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -329,16 +329,16 @@ U0 FileTreeTraverse(LinkStruct *root)
|
|||||||
{
|
{
|
||||||
if (root) {
|
if (root) {
|
||||||
FileTreeTraverse(root->left);
|
FileTreeTraverse(root->left);
|
||||||
"%3d:%$$Q\n",root->cnt,root->file;
|
"%3d:%$$Q\n",root->count,root->file;
|
||||||
FileTreeTraverse(root->right);
|
FileTreeTraverse(root->right);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
U0 DownLoadRep(LogStruct *head,CDate dstart,CDate dend)
|
U0 DownLoadRep(LogStruct *head,CDate dstart,CDate dend)
|
||||||
{
|
{
|
||||||
I64 i,j,cnt,dups,
|
I64 i,j,count,dups,
|
||||||
hours_start,hours_end,*hour_cnts,*dup_cnts,
|
hours_start,hours_end,*hour_counts,*dup_counts,
|
||||||
days_start,days_end,*day_cnts,*day_dup_cnts;
|
days_start,days_end,*day_counts,*day_dup_counts;
|
||||||
LogStruct *tmplg=head->next,*dup_head=NULL;
|
LogStruct *tmplg=head->next,*dup_head=NULL;
|
||||||
LinkStruct *link_root=NULL;
|
LinkStruct *link_root=NULL;
|
||||||
CDateStruct ds;
|
CDateStruct ds;
|
||||||
@ -349,20 +349,20 @@ U0 DownLoadRep(LogStruct *head,CDate dstart,CDate dend)
|
|||||||
days_start=(dstart+local_time_offset)>>32;
|
days_start=(dstart+local_time_offset)>>32;
|
||||||
days_end =(dend+local_time_offset)>>32;
|
days_end =(dend+local_time_offset)>>32;
|
||||||
|
|
||||||
hour_cnts=CAlloc((hours_end-hours_start+1)*sizeof(I64));
|
hour_counts=CAlloc((hours_end-hours_start+1)*sizeof(I64));
|
||||||
dup_cnts =CAlloc((hours_end-hours_start+1)*sizeof(I64));
|
dup_counts =CAlloc((hours_end-hours_start+1)*sizeof(I64));
|
||||||
day_cnts =CAlloc((days_end-days_start+1)*sizeof(I64));
|
day_counts =CAlloc((days_end-days_start+1)*sizeof(I64));
|
||||||
day_dup_cnts=CAlloc((days_end-days_start+1)*sizeof(I64));
|
day_dup_counts=CAlloc((days_end-days_start+1)*sizeof(I64));
|
||||||
dups=cnt=0;
|
dups=count=0;
|
||||||
while (tmplg!=head) {
|
while (tmplg!=head) {
|
||||||
if (IsKeeper(tmplg,dstart,dend) && IsDownLoad(tmplg)) {
|
if (IsKeeper(tmplg,dstart,dend) && IsDownLoad(tmplg)) {
|
||||||
i=tmplg->datetime*24;
|
i=tmplg->datetime*24;
|
||||||
hour_cnts[i.u32[1]-hours_start]++;
|
hour_counts[i.u32[1]-hours_start]++;
|
||||||
day_cnts[(tmplg->datetime+local_time_offset)>>32-days_start]++;
|
day_counts[(tmplg->datetime+local_time_offset)>>32-days_start]++;
|
||||||
cnt++;
|
count++;
|
||||||
if (IPNumTreeAdd(&dup_head,tmplg)) {
|
if (IPNumTreeAdd(&dup_head,tmplg)) {
|
||||||
day_dup_cnts[(tmplg->datetime+local_time_offset)>>32-days_start]++;
|
day_dup_counts[(tmplg->datetime+local_time_offset)>>32-days_start]++;
|
||||||
dup_cnts[i.u32[1]-hours_start]++;
|
dup_counts[i.u32[1]-hours_start]++;
|
||||||
dups++;
|
dups++;
|
||||||
}
|
}
|
||||||
LinkTreeAdd(&link_root,tmplg);
|
LinkTreeAdd(&link_root,tmplg);
|
||||||
@ -373,10 +373,10 @@ U0 DownLoadRep(LogStruct *head,CDate dstart,CDate dend)
|
|||||||
"\n\nDownloads of /TOS_Distro.ISO\n";
|
"\n\nDownloads of /TOS_Distro.ISO\n";
|
||||||
for (i=dstart;i<=dend;i+=1<<32)
|
for (i=dstart;i<=dend;i+=1<<32)
|
||||||
"%DDups:%5dTotal:%5dUniques:%5d\n",i,
|
"%DDups:%5dTotal:%5dUniques:%5d\n",i,
|
||||||
day_dup_cnts[(i+local_time_offset)>>32-days_start],
|
day_dup_counts[(i+local_time_offset)>>32-days_start],
|
||||||
day_cnts[(i+local_time_offset)>>32-days_start],
|
day_counts[(i+local_time_offset)>>32-days_start],
|
||||||
day_cnts[(i+local_time_offset)>>32-days_start]-
|
day_counts[(i+local_time_offset)>>32-days_start]-
|
||||||
day_dup_cnts[(i+local_time_offset)>>32-days_start];
|
day_dup_counts[(i+local_time_offset)>>32-days_start];
|
||||||
|
|
||||||
"\n\nDownloads of /TOS_Distro.ISO\n"
|
"\n\nDownloads of /TOS_Distro.ISO\n"
|
||||||
"'-' is a dup.'+' is not a dup.\n";
|
"'-' is a dup.'+' is not a dup.\n";
|
||||||
@ -387,23 +387,23 @@ U0 DownLoadRep(LogStruct *head,CDate dstart,CDate dend)
|
|||||||
for (;i<=hours_end;i++) {
|
for (;i<=hours_end;i++) {
|
||||||
Date2Struct(&ds,i<<32/24+local_time_offset);
|
Date2Struct(&ds,i<<32/24+local_time_offset);
|
||||||
"%D %02d: ",i<<32/24,ds.hour;
|
"%D %02d: ",i<<32/24,ds.hour;
|
||||||
for (j=0;j<dup_cnts[i-hours_start];j++)
|
for (j=0;j<dup_counts[i-hours_start];j++)
|
||||||
'-';
|
'-';
|
||||||
for (;j<hour_cnts[i-hours_start];j++)
|
for (;j<hour_counts[i-hours_start];j++)
|
||||||
'+';
|
'+';
|
||||||
'\n';
|
'\n';
|
||||||
}
|
}
|
||||||
"Total:%dDups:%dUniques:%d\n",cnt,dups,cnt-dups;
|
"Total:%dDups:%dUniques:%d\n",count,dups,count-dups;
|
||||||
|
|
||||||
"\n\nDownloads of /TOS_Distro.ISO\n";
|
"\n\nDownloads of /TOS_Distro.ISO\n";
|
||||||
LinkTreeTraverse(link_root);
|
LinkTreeTraverse(link_root);
|
||||||
'\n';
|
'\n';
|
||||||
|
|
||||||
LinkTreeDel(link_root);
|
LinkTreeDel(link_root);
|
||||||
Free(hour_cnts);
|
Free(hour_counts);
|
||||||
Free(dup_cnts);
|
Free(dup_counts);
|
||||||
Free(day_cnts);
|
Free(day_counts);
|
||||||
Free(day_dup_cnts);
|
Free(day_dup_counts);
|
||||||
}
|
}
|
||||||
|
|
||||||
U0 FileRep(LogStruct *head,CDate dstart,CDate dend)
|
U0 FileRep(LogStruct *head,CDate dstart,CDate dend)
|
||||||
@ -423,9 +423,9 @@ U0 FileRep(LogStruct *head,CDate dstart,CDate dend)
|
|||||||
|
|
||||||
U0 IndexRep(LogStruct *head,CDate dstart,CDate dend)
|
U0 IndexRep(LogStruct *head,CDate dstart,CDate dend)
|
||||||
{
|
{
|
||||||
I64 i,j,cnt,dups,
|
I64 i,j,count,dups,
|
||||||
hours_start,hours_end,*hour_cnts,*dup_cnts,
|
hours_start,hours_end,*hour_counts,*dup_counts,
|
||||||
days_start,days_end,*day_cnts,*day_dup_cnts;
|
days_start,days_end,*day_counts,*day_dup_counts;
|
||||||
LogStruct *tmplg=head->next,*dup_head=NULL;
|
LogStruct *tmplg=head->next,*dup_head=NULL;
|
||||||
LinkStruct *link_root=NULL;
|
LinkStruct *link_root=NULL;
|
||||||
CDateStruct ds;
|
CDateStruct ds;
|
||||||
@ -436,20 +436,20 @@ U0 IndexRep(LogStruct *head,CDate dstart,CDate dend)
|
|||||||
days_start=(dstart+local_time_offset)>>32;
|
days_start=(dstart+local_time_offset)>>32;
|
||||||
days_end =(dend+local_time_offset)>>32;
|
days_end =(dend+local_time_offset)>>32;
|
||||||
|
|
||||||
hour_cnts=CAlloc((hours_end-hours_start+1)*sizeof(I64));
|
hour_counts=CAlloc((hours_end-hours_start+1)*sizeof(I64));
|
||||||
dup_cnts =CAlloc((hours_end-hours_start+1)*sizeof(I64));
|
dup_counts =CAlloc((hours_end-hours_start+1)*sizeof(I64));
|
||||||
day_cnts =CAlloc((days_end-days_start+1)*sizeof(I64));
|
day_counts =CAlloc((days_end-days_start+1)*sizeof(I64));
|
||||||
day_dup_cnts=CAlloc((days_end-days_start+1)*sizeof(I64));
|
day_dup_counts=CAlloc((days_end-days_start+1)*sizeof(I64));
|
||||||
dups=cnt=0;
|
dups=count=0;
|
||||||
while (tmplg!=head) {
|
while (tmplg!=head) {
|
||||||
if (IsKeeper(tmplg,dstart,dend) && IsIndex(tmplg)) {
|
if (IsKeeper(tmplg,dstart,dend) && IsIndex(tmplg)) {
|
||||||
i=tmplg->datetime*24;
|
i=tmplg->datetime*24;
|
||||||
hour_cnts[i.u32[1]-hours_start]++;
|
hour_counts[i.u32[1]-hours_start]++;
|
||||||
day_cnts[(tmplg->datetime+local_time_offset)>>32-days_start]++;
|
day_counts[(tmplg->datetime+local_time_offset)>>32-days_start]++;
|
||||||
cnt++;
|
count++;
|
||||||
if (IPNumTreeAdd(&dup_head,tmplg)) {
|
if (IPNumTreeAdd(&dup_head,tmplg)) {
|
||||||
day_dup_cnts[(tmplg->datetime+local_time_offset)>>32-days_start]++;
|
day_dup_counts[(tmplg->datetime+local_time_offset)>>32-days_start]++;
|
||||||
dup_cnts[i.u32[1]-hours_start]++;
|
dup_counts[i.u32[1]-hours_start]++;
|
||||||
dups++;
|
dups++;
|
||||||
}
|
}
|
||||||
LinkTreeAdd(&link_root,tmplg);
|
LinkTreeAdd(&link_root,tmplg);
|
||||||
@ -461,10 +461,10 @@ U0 IndexRep(LogStruct *head,CDate dstart,CDate dend)
|
|||||||
"'-' is a dup.'+' is not a dup.\n";
|
"'-' is a dup.'+' is not a dup.\n";
|
||||||
for (i=dstart;i<=dend;i+=1<<32)
|
for (i=dstart;i<=dend;i+=1<<32)
|
||||||
"%DDups:%5dTotal:%5dUniques:%5d\n",i,
|
"%DDups:%5dTotal:%5dUniques:%5d\n",i,
|
||||||
day_dup_cnts[(i+local_time_offset)>>32-days_start],
|
day_dup_counts[(i+local_time_offset)>>32-days_start],
|
||||||
day_cnts[(i+local_time_offset)>>32-days_start],
|
day_counts[(i+local_time_offset)>>32-days_start],
|
||||||
day_cnts[(i+local_time_offset)>>32-days_start]-
|
day_counts[(i+local_time_offset)>>32-days_start]-
|
||||||
day_dup_cnts[(i+local_time_offset)>>32-days_start];
|
day_dup_counts[(i+local_time_offset)>>32-days_start];
|
||||||
|
|
||||||
"\n\nHits on /index.html\n";
|
"\n\nHits on /index.html\n";
|
||||||
if (hours_end-hours_start>=HOURS_MAX)
|
if (hours_end-hours_start>=HOURS_MAX)
|
||||||
@ -474,23 +474,23 @@ U0 IndexRep(LogStruct *head,CDate dstart,CDate dend)
|
|||||||
for (;i<=hours_end;i++) {
|
for (;i<=hours_end;i++) {
|
||||||
Date2Struct(&ds,i<<32/24+local_time_offset);
|
Date2Struct(&ds,i<<32/24+local_time_offset);
|
||||||
"%D %02d: ",i<<32/24,ds.hour;
|
"%D %02d: ",i<<32/24,ds.hour;
|
||||||
for (j=0;j<dup_cnts[i-hours_start];j++)
|
for (j=0;j<dup_counts[i-hours_start];j++)
|
||||||
'-';
|
'-';
|
||||||
for (;j<hour_cnts[i-hours_start];j++)
|
for (;j<hour_counts[i-hours_start];j++)
|
||||||
'+';
|
'+';
|
||||||
'\n';
|
'\n';
|
||||||
}
|
}
|
||||||
"Total:%dDups:%dUniques:%d\n",cnt,dups,cnt-dups;
|
"Total:%dDups:%dUniques:%d\n",count,dups,count-dups;
|
||||||
|
|
||||||
"\n\nHits on /index.html\n";
|
"\n\nHits on /index.html\n";
|
||||||
LinkTreeTraverse(link_root);
|
LinkTreeTraverse(link_root);
|
||||||
'\n';
|
'\n';
|
||||||
|
|
||||||
LinkTreeDel(link_root);
|
LinkTreeDel(link_root);
|
||||||
Free(hour_cnts);
|
Free(hour_counts);
|
||||||
Free(dup_cnts);
|
Free(dup_counts);
|
||||||
Free(day_cnts);
|
Free(day_counts);
|
||||||
Free(day_dup_cnts);
|
Free(day_dup_counts);
|
||||||
}
|
}
|
||||||
|
|
||||||
U0 WebLogRep(U8 *mask,U8 *output_filename)
|
U0 WebLogRep(U8 *mask,U8 *output_filename)
|
||||||
|
@ -11,4 +11,4 @@ $FG$Bit operations are "atomic", no interrupt between the reading and writing th
|
|||||||
$FG,5$These don't take a pointer, but the actual field.$FG$
|
$FG,5$These don't take a pointer, but the actual field.$FG$
|
||||||
$FG,2$Bsf$FG$: Bit Scan Fwd (Pos of first low one bit or -1)
|
$FG,2$Bsf$FG$: Bit Scan Fwd (Pos of first low one bit or -1)
|
||||||
$FG,2$Bsr$FG$: Bit Scan Rev (Pos of first high one bit or -1)
|
$FG,2$Bsr$FG$: Bit Scan Rev (Pos of first high one bit or -1)
|
||||||
$FG,2$BCnt$FG$: Bit Cnt (Cnt of set bits)
|
$FG,2$BCount$FG$: Bit Count (Count of set bits)
|
||||||
|
@ -118,9 +118,9 @@ U0 CommPutS(I64 port,U8 *st)
|
|||||||
CommPutChar(port,b);
|
CommPutChar(port,b);
|
||||||
}
|
}
|
||||||
|
|
||||||
public U0 CommPutBlk(I64 port,U8 *buf,I64 cnt)
|
public U0 CommPutBlk(I64 port,U8 *buf,I64 count)
|
||||||
{
|
{
|
||||||
while (cnt--)
|
while (count--)
|
||||||
CommPutChar(port,*buf++);
|
CommPutChar(port,*buf++);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ $FG,2$Clip$FG$ Clipboard
|
|||||||
$FG,2$Clus$FG$ Cluster
|
$FG,2$Clus$FG$ Cluster
|
||||||
$FG,2$Cmd$FG$ Command
|
$FG,2$Cmd$FG$ Command
|
||||||
$FG,2$Comp$FG$ Compiler
|
$FG,2$Comp$FG$ Compiler
|
||||||
$FG,2$Cnt$FG$ Count
|
$FG,2$Count$FG$ Count
|
||||||
$FG,2$Const$FG$ Consant
|
$FG,2$Const$FG$ Consant
|
||||||
$FG,2$Cont$FG$ Continue
|
$FG,2$Cont$FG$ Continue
|
||||||
$FG,2$Ctrl$FG$ Control. The ctrl key is indicated with "$FG,2$^$FG$" in documentation.
|
$FG,2$Ctrl$FG$ Control. The ctrl key is indicated with "$FG,2$^$FG$" in documentation.
|
||||||
|
@ -1 +1 @@
|
|||||||
$WW,1$Intel/AMD have an inst that returns the num of CPU cycles since boot. This is not a steady, calibrated real time value. ZenithOS measures it and you can convert with $LK,"cnts.time_stamp_freq",A="MN:CCntsGlobals"$, a value continuously calibrated from other cnts.
|
$WW,1$Intel/AMD have an inst that returns the num of CPU cycles since boot. This is not a steady, calibrated real time value. ZenithOS measures it and you can convert with $LK,"counts.time_stamp_freq",A="MN:CCountsGlobals"$, a value continuously calibrated from other counts.
|
@ -1 +1 @@
|
|||||||
$WW,1$The HPET, high precision event timer, is read with $LK,"HPET",A="MN:HPET"$() and has a frequency of $LK,"cnts.HPET_freq",A="MN:CCntsGlobals"$. A typical freq value is 14.3 Mhz It might not be available on all systems.
|
$WW,1$The HPET, high precision event timer, is read with $LK,"HPET",A="MN:HPET"$() and has a frequency of $LK,"counts.HPET_freq",A="MN:CCountsGlobals"$. A typical freq value is 14.3 Mhz It might not be available on all systems.
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
$WW,1$One jiffy is one time slice. $LK,"cnts.jiffies",A="MN:CCntsGlobals"$ returns time slices since boot.
|
$WW,1$One jiffy is one time slice. $LK,"counts.jiffies",A="MN:CCountsGlobals"$ returns time slices since boot.
|
||||||
|
|
||||||
$LK,"SysTimerRead",A="MN:SysTimerRead"$ reads the timer ticks since boot. It's not as fast as $LK,"GetTSC",A="MN:GetTSC"$.
|
$LK,"SysTimerRead",A="MN:SysTimerRead"$ reads the timer ticks since boot. It's not as fast as $LK,"GetTSC",A="MN:GetTSC"$.
|
||||||
|
|
||||||
Use $LK,"JIFFY_FREQ",A="MN:JIFFY_FREQ"$ to convert $LK,"cnts.jiffies",A="MN:CCntsGlobals"$.
|
Use $LK,"JIFFY_FREQ",A="MN:JIFFY_FREQ"$ to convert $LK,"counts.jiffies",A="MN:CCountsGlobals"$.
|
||||||
|
|
||||||
Use $LK,"SYS_TIMER_FREQ",A="MN:SYS_TIMER_FREQ"$ to convert $LK,"SysTimerRead",A="MN:SysTimerRead"$.
|
Use $LK,"SYS_TIMER_FREQ",A="MN:SYS_TIMER_FREQ"$ to convert $LK,"SysTimerRead",A="MN:SysTimerRead"$.
|
||||||
|
@ -125,7 +125,7 @@ $FG,2$Merge(\"C:/*\",\"D:/*\",\"+r+d\");$FG$ to check my changes.
|
|||||||
|
|
||||||
* The editor's sel-text mechanism allows for disjoint portions of sel text. This is a feature, not a bug -- you can cut-and-paste disjoint text.
|
* The editor's sel-text mechanism allows for disjoint portions of sel text. This is a feature, not a bug -- you can cut-and-paste disjoint text.
|
||||||
|
|
||||||
* $LK,"cnts.time_stamp_freq",A="MN:CCntsGlobals"$ is continuously calibrated. Be careful because expressions might decrease. Take a snap-shot, like this: $FG,2$timeout=$LK,"GetTSC",A="MN:GetTSC"$+$LK,"cnts.time_stamp_freq",A="MN:CCntsGlobals"$ x seconds;$FG$ and compare against $LK,"GetTSC",A="MN:GetTSC"$(). I recommend just using $LK,"tS",A="MN:tS"$ or $LK,"cnts.jiffies",A="MN:CCntsGlobals"$.
|
* $LK,"counts.time_stamp_freq",A="MN:CCountsGlobals"$ is continuously calibrated. Be careful because expressions might decrease. Take a snap-shot, like this: $FG,2$timeout=$LK,"GetTSC",A="MN:GetTSC"$+$LK,"counts.time_stamp_freq",A="MN:CCountsGlobals"$ x seconds;$FG$ and compare against $LK,"GetTSC",A="MN:GetTSC"$(). I recommend just using $LK,"tS",A="MN:tS"$ or $LK,"counts.jiffies",A="MN:CCountsGlobals"$.
|
||||||
|
|
||||||
* Use $LK,"HeapLog",A="MN:HeapLog"$(), $LK,"HeapLogAddrRep",A="MN:HeapLogAddrRep"$() and $LK,"HeapLogSizeRep",A="MN:HeapLogSizeRep"$() to find leaks. Don't be confused by $LK,"CDoc",A="MN:CDoc"$ allocations. Those are generated when text is written to the cmd line buffer.
|
* Use $LK,"HeapLog",A="MN:HeapLog"$(), $LK,"HeapLogAddrRep",A="MN:HeapLogAddrRep"$() and $LK,"HeapLogSizeRep",A="MN:HeapLogSizeRep"$() to find leaks. Don't be confused by $LK,"CDoc",A="MN:CDoc"$ allocations. Those are generated when text is written to the cmd line buffer.
|
||||||
|
|
||||||
|
BIN
src/Kernel.BIN.C
BIN
src/Kernel.BIN.C
Binary file not shown.
@ -1,19 +1,19 @@
|
|||||||
U0 ATABlkSel(CBlkDev *bd,I64 blk,I64 cnt)
|
U0 ATABlkSel(CBlkDev *bd,I64 blk,I64 count)
|
||||||
{
|
{
|
||||||
if (bd->type!=BDT_ATAPI && bd->base1)
|
if (bd->type!=BDT_ATAPI && bd->base1)
|
||||||
OutU8(bd->base1+ATAR1_CTRL,0x8);
|
OutU8(bd->base1+ATAR1_CTRL,0x8);
|
||||||
if (bd->flags & BDF_EXT_SIZE) { //48 Bit LBA?
|
if (bd->flags & BDF_EXT_SIZE) { //48 Bit LBA?
|
||||||
OutU8(bd->base0+ATAR0_NSECT,cnt.u8[1]);
|
OutU8(bd->base0+ATAR0_NSECT,count.u8[1]);
|
||||||
OutU8(bd->base0+ATAR0_SECT,blk.u8[3]);
|
OutU8(bd->base0+ATAR0_SECT,blk.u8[3]);
|
||||||
OutU8(bd->base0+ATAR0_LCYL,blk.u8[4]);
|
OutU8(bd->base0+ATAR0_LCYL,blk.u8[4]);
|
||||||
OutU8(bd->base0+ATAR0_HCYL,blk.u8[5]);
|
OutU8(bd->base0+ATAR0_HCYL,blk.u8[5]);
|
||||||
OutU8(bd->base0+ATAR0_NSECT,cnt);
|
OutU8(bd->base0+ATAR0_NSECT,count);
|
||||||
OutU8(bd->base0+ATAR0_SECT,blk);
|
OutU8(bd->base0+ATAR0_SECT,blk);
|
||||||
OutU8(bd->base0+ATAR0_LCYL,blk.u8[1]);
|
OutU8(bd->base0+ATAR0_LCYL,blk.u8[1]);
|
||||||
OutU8(bd->base0+ATAR0_HCYL,blk.u8[2]);
|
OutU8(bd->base0+ATAR0_HCYL,blk.u8[2]);
|
||||||
OutU8(bd->base0+ATAR0_SEL,0xEF|bd->unit<<4);
|
OutU8(bd->base0+ATAR0_SEL,0xEF|bd->unit<<4);
|
||||||
} else { //28 Bit LBA
|
} else { //28 Bit LBA
|
||||||
OutU8(bd->base0+ATAR0_NSECT,cnt);
|
OutU8(bd->base0+ATAR0_NSECT,count);
|
||||||
OutU8(bd->base0+ATAR0_SECT,blk);
|
OutU8(bd->base0+ATAR0_SECT,blk);
|
||||||
OutU8(bd->base0+ATAR0_LCYL,blk.u8[1]);
|
OutU8(bd->base0+ATAR0_LCYL,blk.u8[1]);
|
||||||
OutU8(bd->base0+ATAR0_HCYL,blk.u8[2]);
|
OutU8(bd->base0+ATAR0_HCYL,blk.u8[2]);
|
||||||
@ -64,13 +64,13 @@ U0 ATACmd(CBlkDev *bd,U8 cmd)
|
|||||||
PortNop;
|
PortNop;
|
||||||
}
|
}
|
||||||
|
|
||||||
Bool ATAGetRes(CBlkDev *bd,F64 timeout,U8 *buf,I64 cnt,
|
Bool ATAGetRes(CBlkDev *bd,F64 timeout,U8 *buf,I64 count,
|
||||||
I64 _avail,Bool one_read)
|
I64 _avail,Bool one_read)
|
||||||
{
|
{
|
||||||
I64 avail,overflow;
|
I64 avail,overflow;
|
||||||
bd->flags&=~BDF_LAST_WAS_WRITE;
|
bd->flags&=~BDF_LAST_WAS_WRITE;
|
||||||
MemSet(buf,0,cnt);
|
MemSet(buf,0,count);
|
||||||
while (cnt>0) {
|
while (count>0) {
|
||||||
if (!ATAWaitDRQ(bd,timeout))
|
if (!ATAWaitDRQ(bd,timeout))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
if (_avail)
|
if (_avail)
|
||||||
@ -78,16 +78,16 @@ Bool ATAGetRes(CBlkDev *bd,F64 timeout,U8 *buf,I64 cnt,
|
|||||||
else
|
else
|
||||||
avail=InU8(bd->base0+ATAR0_HCYL)<<8+InU8(bd->base0+ATAR0_LCYL);
|
avail=InU8(bd->base0+ATAR0_HCYL)<<8+InU8(bd->base0+ATAR0_LCYL);
|
||||||
if (avail) {
|
if (avail) {
|
||||||
if (avail>cnt) {
|
if (avail>count) {
|
||||||
overflow=avail-cnt;
|
overflow=avail-count;
|
||||||
avail=cnt;
|
avail=count;
|
||||||
} else
|
} else
|
||||||
overflow=0;
|
overflow=0;
|
||||||
if (avail&2)
|
if (avail&2)
|
||||||
RepInU16(buf,avail>>1,bd->base0+ATAR0_DATA);
|
RepInU16(buf,avail>>1,bd->base0+ATAR0_DATA);
|
||||||
else
|
else
|
||||||
RepInU32(buf,avail>>2,bd->base0+ATAR0_DATA);
|
RepInU32(buf,avail>>2,bd->base0+ATAR0_DATA);
|
||||||
cnt-=avail;
|
count-=avail;
|
||||||
buf+=avail;
|
buf+=avail;
|
||||||
while (overflow>0) {
|
while (overflow>0) {
|
||||||
InU16(bd->base0+ATAR0_DATA);
|
InU16(bd->base0+ATAR0_DATA);
|
||||||
@ -350,18 +350,18 @@ Bool ATAPIWaitReady(CBlkDev *bd,F64 timeout)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
U0 ATAReadBlks(CBlkDev *bd,U8 *buf, I64 blk, I64 cnt)
|
U0 ATAReadBlks(CBlkDev *bd,U8 *buf, I64 blk, I64 count)
|
||||||
{
|
{
|
||||||
I64 retries=3;
|
I64 retries=3;
|
||||||
Bool unlock=BlkDevLock(bd);
|
Bool unlock=BlkDevLock(bd);
|
||||||
|
|
||||||
retry:
|
retry:
|
||||||
ATABlkSel(bd,blk,cnt);
|
ATABlkSel(bd,blk,count);
|
||||||
if (bd->flags & BDF_EXT_SIZE)
|
if (bd->flags & BDF_EXT_SIZE)
|
||||||
ATACmd(bd,ATA_READ_MULTI_EXT);
|
ATACmd(bd,ATA_READ_MULTI_EXT);
|
||||||
else
|
else
|
||||||
ATACmd(bd,ATA_READ_MULTI);
|
ATACmd(bd,ATA_READ_MULTI);
|
||||||
if (!ATAGetRes(bd,tS+1.0,buf,cnt*bd->blk_size,BLK_SIZE,FALSE)) {
|
if (!ATAGetRes(bd,tS+1.0,buf,count*bd->blk_size,BLK_SIZE,FALSE)) {
|
||||||
if (retries--) {
|
if (retries--) {
|
||||||
ATAWaitNotBUSY(bd,0);
|
ATAWaitNotBUSY(bd,0);
|
||||||
goto retry;
|
goto retry;
|
||||||
@ -369,7 +369,7 @@ U0 ATAReadBlks(CBlkDev *bd,U8 *buf, I64 blk, I64 cnt)
|
|||||||
throw('BlkDev');
|
throw('BlkDev');
|
||||||
}
|
}
|
||||||
|
|
||||||
blkdev.read_cnt+=(cnt*bd->blk_size)>>BLK_SIZE_BITS;
|
blkdev.read_count+=(count*bd->blk_size)>>BLK_SIZE_BITS;
|
||||||
if (unlock) BlkDevUnlock(bd);
|
if (unlock) BlkDevUnlock(bd);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -386,10 +386,10 @@ I64 ATAProbe(I64 base0,I64 base1,I64 unit)
|
|||||||
}
|
}
|
||||||
|
|
||||||
Bool ATAPIReadBlks2(CBlkDev *bd,F64 timeout,U8 *buf,
|
Bool ATAPIReadBlks2(CBlkDev *bd,F64 timeout,U8 *buf,
|
||||||
I64 native_blk, I64 cnt,Bool lock)
|
I64 native_blk, I64 count,Bool lock)
|
||||||
{
|
{
|
||||||
Bool res=FALSE,unlock;
|
Bool res=FALSE,unlock;
|
||||||
if (cnt<=0)
|
if (count<=0)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
if (lock)
|
if (lock)
|
||||||
unlock=BlkDevLock(bd);
|
unlock=BlkDevLock(bd);
|
||||||
@ -402,9 +402,9 @@ Bool ATAPIReadBlks2(CBlkDev *bd,F64 timeout,U8 *buf,
|
|||||||
OutU8(bd->base0+ATAR0_HCYL,bd->blk_size.u8[1]);
|
OutU8(bd->base0+ATAR0_HCYL,bd->blk_size.u8[1]);
|
||||||
ATACmd(bd,ATA_PACKET);
|
ATACmd(bd,ATA_PACKET);
|
||||||
if (ATAPIWritePktWord(bd,timeout,0xA800,
|
if (ATAPIWritePktWord(bd,timeout,0xA800,
|
||||||
native_blk.u16[1],native_blk,cnt.u16[1],cnt,0) &&
|
native_blk.u16[1],native_blk,count.u16[1],count,0) &&
|
||||||
ATAGetRes(bd,timeout,buf,cnt*bd->blk_size,0,FALSE)) {
|
ATAGetRes(bd,timeout,buf,count*bd->blk_size,0,FALSE)) {
|
||||||
blkdev.read_cnt+=(cnt*bd->blk_size)>>BLK_SIZE_BITS;
|
blkdev.read_count+=(count*bd->blk_size)>>BLK_SIZE_BITS;
|
||||||
res=TRUE;
|
res=TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -413,13 +413,13 @@ Bool ATAPIReadBlks2(CBlkDev *bd,F64 timeout,U8 *buf,
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
U0 ATAPIReadBlks(CBlkDev *bd,U8 *buf, I64 blk, I64 cnt)
|
U0 ATAPIReadBlks(CBlkDev *bd,U8 *buf, I64 blk, I64 count)
|
||||||
{
|
{
|
||||||
CDrive *dv=Letter2Drive(bd->first_drv_let);
|
CDrive *dv=Letter2Drive(bd->first_drv_let);
|
||||||
I64 retry,spc=bd->blk_size>>BLK_SIZE_BITS,n,blk2,
|
I64 retry,spc=bd->blk_size>>BLK_SIZE_BITS,n,blk2,
|
||||||
l2=bd->max_reads<<1+spc<<1;
|
l2=bd->max_reads<<1+spc<<1;
|
||||||
U8 *dvd_buf=MAlloc(l2<<BLK_SIZE_BITS);
|
U8 *dvd_buf=MAlloc(l2<<BLK_SIZE_BITS);
|
||||||
if (cnt>0) {
|
if (count>0) {
|
||||||
if (blk<=bd->max_reads)
|
if (blk<=bd->max_reads)
|
||||||
blk2=0;
|
blk2=0;
|
||||||
else
|
else
|
||||||
@ -437,17 +437,17 @@ U0 ATAPIReadBlks(CBlkDev *bd,U8 *buf, I64 blk, I64 cnt)
|
|||||||
ATAPIReadBlks2(bd,0,dvd_buf,blk2/spc,n,TRUE);
|
ATAPIReadBlks2(bd,0,dvd_buf,blk2/spc,n,TRUE);
|
||||||
if (bd->flags & BDF_READ_CACHE)
|
if (bd->flags & BDF_READ_CACHE)
|
||||||
DiskCacheAdd(dv,dvd_buf,blk2,n*spc);
|
DiskCacheAdd(dv,dvd_buf,blk2,n*spc);
|
||||||
MemCpy(buf,dvd_buf+(blk-blk2)<<BLK_SIZE_BITS,cnt<<BLK_SIZE_BITS);
|
MemCpy(buf,dvd_buf+(blk-blk2)<<BLK_SIZE_BITS,count<<BLK_SIZE_BITS);
|
||||||
}
|
}
|
||||||
Free(dvd_buf);
|
Free(dvd_buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
Bool ATARBlks(CDrive *dv,U8 *buf, I64 blk, I64 cnt)
|
Bool ATARBlks(CDrive *dv,U8 *buf, I64 blk, I64 count)
|
||||||
{
|
{
|
||||||
I64 n;
|
I64 n;
|
||||||
CBlkDev *bd=dv->bd;
|
CBlkDev *bd=dv->bd;
|
||||||
while (cnt>0) {
|
while (count>0) {
|
||||||
n=cnt;
|
n=count;
|
||||||
if (n>bd->max_reads)
|
if (n>bd->max_reads)
|
||||||
n=bd->max_reads;
|
n=bd->max_reads;
|
||||||
if (bd->type==BDT_ATAPI)
|
if (bd->type==BDT_ATAPI)
|
||||||
@ -456,25 +456,25 @@ Bool ATARBlks(CDrive *dv,U8 *buf, I64 blk, I64 cnt)
|
|||||||
ATAReadBlks(bd,buf,blk,n);
|
ATAReadBlks(bd,buf,blk,n);
|
||||||
buf+=n<<BLK_SIZE_BITS;
|
buf+=n<<BLK_SIZE_BITS;
|
||||||
blk+=n;
|
blk+=n;
|
||||||
cnt-=n;
|
count-=n;
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
U0 ATAWriteBlks(CBlkDev *bd,U8 *buf, I64 blk, I64 cnt)
|
U0 ATAWriteBlks(CBlkDev *bd,U8 *buf, I64 blk, I64 count)
|
||||||
{//For low level disk access.
|
{//For low level disk access.
|
||||||
//Use BlkWrite() instead.
|
//Use BlkWrite() instead.
|
||||||
I64 i,U32s_avail,sects_avail,retries=3;
|
I64 i,U32s_avail,sects_avail,retries=3;
|
||||||
F64 timeout;
|
F64 timeout;
|
||||||
Bool unlock=BlkDevLock(bd);
|
Bool unlock=BlkDevLock(bd);
|
||||||
retry:
|
retry:
|
||||||
ATABlkSel(bd,blk,cnt);
|
ATABlkSel(bd,blk,count);
|
||||||
if (bd->flags&BDF_EXT_SIZE)
|
if (bd->flags&BDF_EXT_SIZE)
|
||||||
ATACmd(bd,ATA_WRITE_MULTI_EXT);
|
ATACmd(bd,ATA_WRITE_MULTI_EXT);
|
||||||
else
|
else
|
||||||
ATACmd(bd,ATA_WRITE_MULTI);
|
ATACmd(bd,ATA_WRITE_MULTI);
|
||||||
bd->flags|=BDF_LAST_WAS_WRITE;
|
bd->flags|=BDF_LAST_WAS_WRITE;
|
||||||
while (cnt>0) {
|
while (count>0) {
|
||||||
timeout=tS+1.0;
|
timeout=tS+1.0;
|
||||||
while (TRUE) {
|
while (TRUE) {
|
||||||
i=InU8(bd->base0+ATAR0_STAT);
|
i=InU8(bd->base0+ATAR0_STAT);
|
||||||
@ -494,7 +494,7 @@ retry:
|
|||||||
U32s_avail=sects_avail<<BLK_SIZE_BITS>>2;
|
U32s_avail=sects_avail<<BLK_SIZE_BITS>>2;
|
||||||
RepOutU32(buf,U32s_avail,bd->base0+ATAR0_DATA);
|
RepOutU32(buf,U32s_avail,bd->base0+ATAR0_DATA);
|
||||||
buf+=U32s_avail<<2;
|
buf+=U32s_avail<<2;
|
||||||
cnt-=sects_avail;
|
count-=sects_avail;
|
||||||
retries=3;
|
retries=3;
|
||||||
}
|
}
|
||||||
ATAWaitNotBUSY(bd,0);
|
ATAWaitNotBUSY(bd,0);
|
||||||
@ -535,7 +535,7 @@ U0 ATAPIClose(CBlkDev *bd,I64 close_field=0x200,I64 track=0)
|
|||||||
ATAWaitNotBUSY(bd,0);
|
ATAWaitNotBUSY(bd,0);
|
||||||
}
|
}
|
||||||
|
|
||||||
U0 ATAPIWriteBlks(CBlkDev *bd,U8 *buf, I64 native_blk, I64 cnt)
|
U0 ATAPIWriteBlks(CBlkDev *bd,U8 *buf, I64 native_blk, I64 count)
|
||||||
{
|
{
|
||||||
I64 U32s_avail;
|
I64 U32s_avail;
|
||||||
U8 *buf2;
|
U8 *buf2;
|
||||||
@ -550,7 +550,7 @@ U0 ATAPIWriteBlks(CBlkDev *bd,U8 *buf, I64 native_blk, I64 cnt)
|
|||||||
else
|
else
|
||||||
OutU8(bd->base0+ATAR0_SEL,0xE0|bd->unit<<4);
|
OutU8(bd->base0+ATAR0_SEL,0xE0|bd->unit<<4);
|
||||||
OutU8(bd->base0+ATAR0_CMD,ATA_PACKET);
|
OutU8(bd->base0+ATAR0_CMD,ATA_PACKET);
|
||||||
ATAPIWritePktWord(bd,0,0x0400,native_blk.u16[1],native_blk,cnt.u16[1],cnt,0);
|
ATAPIWritePktWord(bd,0,0x0400,native_blk.u16[1],native_blk,count.u16[1],count,0);
|
||||||
bd->flags|=BDF_LAST_WAS_WRITE;
|
bd->flags|=BDF_LAST_WAS_WRITE;
|
||||||
ATAWaitNotBUSY(bd,0);
|
ATAWaitNotBUSY(bd,0);
|
||||||
|
|
||||||
@ -563,8 +563,8 @@ U0 ATAPIWriteBlks(CBlkDev *bd,U8 *buf, I64 native_blk, I64 cnt)
|
|||||||
OutU8(bd->base0+ATAR0_LCYL,bd->blk_size);
|
OutU8(bd->base0+ATAR0_LCYL,bd->blk_size);
|
||||||
OutU8(bd->base0+ATAR0_HCYL,bd->blk_size.u8[1]);
|
OutU8(bd->base0+ATAR0_HCYL,bd->blk_size.u8[1]);
|
||||||
ATACmd(bd,ATA_PACKET);
|
ATACmd(bd,ATA_PACKET);
|
||||||
ATAPIWritePktWord(bd,0,0xAA00,native_blk.u16[1],native_blk,cnt.u16[1],cnt,0);
|
ATAPIWritePktWord(bd,0,0xAA00,native_blk.u16[1],native_blk,count.u16[1],count,0);
|
||||||
buf2=buf+bd->blk_size*cnt;
|
buf2=buf+bd->blk_size*count;
|
||||||
while (buf<buf2) {
|
while (buf<buf2) {
|
||||||
ATAWaitDRQ(bd,0);
|
ATAWaitDRQ(bd,0);
|
||||||
U32s_avail=(InU8(bd->base0+ATAR0_HCYL)<<8+InU8(bd->base0+ATAR0_LCYL))>>2;
|
U32s_avail=(InU8(bd->base0+ATAR0_HCYL)<<8+InU8(bd->base0+ATAR0_LCYL))>>2;
|
||||||
@ -573,13 +573,13 @@ U0 ATAPIWriteBlks(CBlkDev *bd,U8 *buf, I64 native_blk, I64 cnt)
|
|||||||
if (U32s_avail) {
|
if (U32s_avail) {
|
||||||
RepOutU32(buf,U32s_avail,bd->base0+ATAR0_DATA);
|
RepOutU32(buf,U32s_avail,bd->base0+ATAR0_DATA);
|
||||||
buf+=U32s_avail<<2;
|
buf+=U32s_avail<<2;
|
||||||
blkdev.write_cnt+=U32s_avail>>(BLK_SIZE_BITS-2);
|
blkdev.write_count+=U32s_avail>>(BLK_SIZE_BITS-2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ATAWaitNotBUSY(bd,0);
|
ATAWaitNotBUSY(bd,0);
|
||||||
}
|
}
|
||||||
|
|
||||||
Bool ATAWBlks(CDrive *dv,U8 *buf, I64 blk, I64 cnt)
|
Bool ATAWBlks(CDrive *dv,U8 *buf, I64 blk, I64 count)
|
||||||
{
|
{
|
||||||
I64 n,spc;
|
I64 n,spc;
|
||||||
CBlkDev *bd=dv->bd;
|
CBlkDev *bd=dv->bd;
|
||||||
@ -589,8 +589,8 @@ Bool ATAWBlks(CDrive *dv,U8 *buf, I64 blk, I64 cnt)
|
|||||||
unlock=BlkDevLock(bd);
|
unlock=BlkDevLock(bd);
|
||||||
ATAPIWaitReady(bd,0);
|
ATAPIWaitReady(bd,0);
|
||||||
}
|
}
|
||||||
while (cnt>0) {
|
while (count>0) {
|
||||||
n=cnt;
|
n=count;
|
||||||
if (n>bd->max_writes)
|
if (n>bd->max_writes)
|
||||||
n=bd->max_writes;
|
n=bd->max_writes;
|
||||||
if (bd->type==BDT_ATAPI)
|
if (bd->type==BDT_ATAPI)
|
||||||
@ -599,8 +599,8 @@ Bool ATAWBlks(CDrive *dv,U8 *buf, I64 blk, I64 cnt)
|
|||||||
ATAWriteBlks(bd,buf,blk,n);
|
ATAWriteBlks(bd,buf,blk,n);
|
||||||
buf+=n<<BLK_SIZE_BITS;
|
buf+=n<<BLK_SIZE_BITS;
|
||||||
blk+=n;
|
blk+=n;
|
||||||
cnt-=n;
|
count-=n;
|
||||||
blkdev.write_cnt+=n;
|
blkdev.write_count+=n;
|
||||||
}
|
}
|
||||||
if (bd->type==BDT_ATAPI) {
|
if (bd->type==BDT_ATAPI) {
|
||||||
ATAPISync(bd);
|
ATAPISync(bd);
|
||||||
|
@ -133,7 +133,7 @@ Bool ATARepExitAllApplications()
|
|||||||
|
|
||||||
public I64 ATARep(Bool pmt=TRUE,Bool just_ide=FALSE,CATARep **_head=NULL)
|
public I64 ATARep(Bool pmt=TRUE,Bool just_ide=FALSE,CATARep **_head=NULL)
|
||||||
{//Report possible ATA devices by probing. Hard disks and CD/DVDs.
|
{//Report possible ATA devices by probing. Hard disks and CD/DVDs.
|
||||||
I64 d1,d2,i,j,k,cnt=0,unlock_flags=0,num_hints=0;
|
I64 d1,d2,i,j,k,count=0,unlock_flags=0,num_hints=0;
|
||||||
#assert BLKDEVS_NUM<=64
|
#assert BLKDEVS_NUM<=64
|
||||||
if (_head) *_head=NULL;
|
if (_head) *_head=NULL;
|
||||||
|
|
||||||
@ -154,7 +154,7 @@ public I64 ATARep(Bool pmt=TRUE,Bool just_ide=FALSE,CATARep **_head=NULL)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
"\nSubcode:0x%X Bus:0x%X Dev:0x%X Fun:0x%X\n",k,j.u8[2],j.u8[1],j.u8[0];
|
"\nSubcode:0x%X Bus:0x%X Dev:0x%X Fun:0x%X\n",k,j.u8[2],j.u8[1],j.u8[0];
|
||||||
cnt++;
|
count++;
|
||||||
|
|
||||||
d1=PCIReadU32(j.u8[2],j.u8[1],j.u8[0],0x10);
|
d1=PCIReadU32(j.u8[2],j.u8[1],j.u8[0],0x10);
|
||||||
d2=PCIReadU32(j.u8[2],j.u8[1],j.u8[0],0x14);
|
d2=PCIReadU32(j.u8[2],j.u8[1],j.u8[0],0x14);
|
||||||
@ -178,7 +178,7 @@ public I64 ATARep(Bool pmt=TRUE,Bool just_ide=FALSE,CATARep **_head=NULL)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!cnt) {
|
if (!count) {
|
||||||
d1=0x1F0; d2=0x3F6;
|
d1=0x1F0; d2=0x3F6;
|
||||||
ATARepEntry(d1,d2,0,"Primary IDE",_head,&num_hints);
|
ATARepEntry(d1,d2,0,"Primary IDE",_head,&num_hints);
|
||||||
ATARepEntry(d1,d2,1,"Primary IDE",_head,&num_hints);
|
ATARepEntry(d1,d2,1,"Primary IDE",_head,&num_hints);
|
||||||
@ -288,6 +288,6 @@ I64 MountIDEAuto()
|
|||||||
tmpha=tmpha->next;
|
tmpha=tmpha->next;
|
||||||
}
|
}
|
||||||
LinkedLstDel(head);
|
LinkedLstDel(head);
|
||||||
blkdev.mount_ide_auto_cnt=res;
|
blkdev.mount_ide_auto_count=res;
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
@ -1,22 +1,22 @@
|
|||||||
#define ZERO_BUF_SIZE 2048
|
#define ZERO_BUF_SIZE 2048
|
||||||
U0 BlkWriteZero(CDrive *dv,I64 blk,I64 cnt)
|
U0 BlkWriteZero(CDrive *dv,I64 blk,I64 count)
|
||||||
{//Fill blk cnt with zeros in Drive.
|
{//Fill blk count with zeros in Drive.
|
||||||
I64 n;
|
I64 n;
|
||||||
U8 *z=CAlloc(ZERO_BUF_SIZE<<BLK_SIZE_BITS);
|
U8 *z=CAlloc(ZERO_BUF_SIZE<<BLK_SIZE_BITS);
|
||||||
Bool show_progress;
|
Bool show_progress;
|
||||||
if (cnt>ZERO_BUF_SIZE && dv->bd->type!=BDT_RAM) {
|
if (count>ZERO_BUF_SIZE && dv->bd->type!=BDT_RAM) {
|
||||||
progress1=0; progress1_max=cnt;
|
progress1=0; progress1_max=count;
|
||||||
StrCpy(progress1_desc,"Zeroing");
|
StrCpy(progress1_desc,"Zeroing");
|
||||||
show_progress=TRUE;
|
show_progress=TRUE;
|
||||||
} else
|
} else
|
||||||
show_progress=FALSE;
|
show_progress=FALSE;
|
||||||
while (cnt>0) {
|
while (count>0) {
|
||||||
n=cnt;
|
n=count;
|
||||||
if (n>ZERO_BUF_SIZE)
|
if (n>ZERO_BUF_SIZE)
|
||||||
n=ZERO_BUF_SIZE;
|
n=ZERO_BUF_SIZE;
|
||||||
BlkWrite(dv,z,blk,n);
|
BlkWrite(dv,z,blk,n);
|
||||||
blk+=n;
|
blk+=n;
|
||||||
cnt-=n;
|
count-=n;
|
||||||
if (show_progress)
|
if (show_progress)
|
||||||
progress1+=n;
|
progress1+=n;
|
||||||
Yield; //Prevent locking
|
Yield; //Prevent locking
|
||||||
@ -28,37 +28,37 @@ U0 BlkWriteZero(CDrive *dv,I64 blk,I64 cnt)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Bool BlkRead(CDrive *dv,U8 *buf, I64 blk, I64 cnt)
|
Bool BlkRead(CDrive *dv,U8 *buf, I64 blk, I64 count)
|
||||||
{//Read blk cnt from Drive to buf.
|
{//Read blk count from Drive to buf.
|
||||||
Bool res=TRUE,unlock;
|
Bool res=TRUE,unlock;
|
||||||
CBlkDev *bd=dv->bd;
|
CBlkDev *bd=dv->bd;
|
||||||
if (cnt<=0) return TRUE;
|
if (count<=0) return TRUE;
|
||||||
DriveCheck(dv);
|
DriveCheck(dv);
|
||||||
try {
|
try {
|
||||||
unlock=DriveLock(dv);
|
unlock=DriveLock(dv);
|
||||||
BlkDevInit(bd);
|
BlkDevInit(bd);
|
||||||
if (dv->drv_offset && blk<dv->drv_offset ||
|
if (dv->drv_offset && blk<dv->drv_offset ||
|
||||||
blk+cnt>dv->drv_offset+dv->size)
|
blk+count>dv->drv_offset+dv->size)
|
||||||
throw('Drive');
|
throw('Drive');
|
||||||
if (bd->flags & BDF_READ_CACHE)
|
if (bd->flags & BDF_READ_CACHE)
|
||||||
RCache(dv,&buf,&blk,&cnt);
|
RCache(dv,&buf,&blk,&count);
|
||||||
if (cnt>0) {
|
if (count>0) {
|
||||||
switch (bd->type) {
|
switch (bd->type) {
|
||||||
case BDT_RAM:
|
case BDT_RAM:
|
||||||
MemCpy(buf,bd->RAM_dsk+blk<<BLK_SIZE_BITS,cnt<<BLK_SIZE_BITS);
|
MemCpy(buf,bd->RAM_dsk+blk<<BLK_SIZE_BITS,count<<BLK_SIZE_BITS);
|
||||||
break;
|
break;
|
||||||
case BDT_ISO_FILE_READ:
|
case BDT_ISO_FILE_READ:
|
||||||
case BDT_ISO_FILE_WRITE:
|
case BDT_ISO_FILE_WRITE:
|
||||||
FBlkRead(bd->file_dsk,buf,blk,cnt);
|
FBlkRead(bd->file_dsk,buf,blk,count);
|
||||||
break;
|
break;
|
||||||
case BDT_ATA:
|
case BDT_ATA:
|
||||||
case BDT_ATAPI:
|
case BDT_ATAPI:
|
||||||
res=ATARBlks(dv,buf,blk,cnt);
|
res=ATARBlks(dv,buf,blk,count);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
bd->last_time=tS;
|
bd->last_time=tS;
|
||||||
if (bd->flags & BDF_READ_CACHE)
|
if (bd->flags & BDF_READ_CACHE)
|
||||||
DiskCacheAdd(dv,buf,blk,cnt);
|
DiskCacheAdd(dv,buf,blk,count);
|
||||||
}
|
}
|
||||||
if (unlock)
|
if (unlock)
|
||||||
DriveUnlock(dv);
|
DriveUnlock(dv);
|
||||||
@ -68,11 +68,11 @@ Bool BlkRead(CDrive *dv,U8 *buf, I64 blk, I64 cnt)
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
Bool BlkWrite(CDrive *dv,U8 *buf, I64 blk, I64 cnt)
|
Bool BlkWrite(CDrive *dv,U8 *buf, I64 blk, I64 count)
|
||||||
{//Write blk cnt from buf to Drive.
|
{//Write blk count from buf to Drive.
|
||||||
Bool res=TRUE,unlock;
|
Bool res=TRUE,unlock;
|
||||||
CBlkDev *bd=dv->bd;
|
CBlkDev *bd=dv->bd;
|
||||||
if (cnt<=0) return TRUE;
|
if (count<=0) return TRUE;
|
||||||
DriveCheck(dv);
|
DriveCheck(dv);
|
||||||
try {
|
try {
|
||||||
unlock=DriveLock(dv);
|
unlock=DriveLock(dv);
|
||||||
@ -80,25 +80,25 @@ Bool BlkWrite(CDrive *dv,U8 *buf, I64 blk, I64 cnt)
|
|||||||
if (bd->flags&BDF_READ_ONLY && !(bd->flags & BDF_READ_ONLY_OVERRIDE))
|
if (bd->flags&BDF_READ_ONLY && !(bd->flags & BDF_READ_ONLY_OVERRIDE))
|
||||||
throw('BlkDev');
|
throw('BlkDev');
|
||||||
if (dv->drv_offset && blk<dv->drv_offset ||
|
if (dv->drv_offset && blk<dv->drv_offset ||
|
||||||
blk+cnt>dv->drv_offset+dv->size)
|
blk+count>dv->drv_offset+dv->size)
|
||||||
throw('Drive');
|
throw('Drive');
|
||||||
if (cnt>0) {
|
if (count>0) {
|
||||||
switch (bd->type) {
|
switch (bd->type) {
|
||||||
case BDT_RAM:
|
case BDT_RAM:
|
||||||
MemCpy(bd->RAM_dsk+blk<<BLK_SIZE_BITS,buf,cnt<<BLK_SIZE_BITS);
|
MemCpy(bd->RAM_dsk+blk<<BLK_SIZE_BITS,buf,count<<BLK_SIZE_BITS);
|
||||||
break;
|
break;
|
||||||
case BDT_ISO_FILE_READ:
|
case BDT_ISO_FILE_READ:
|
||||||
case BDT_ISO_FILE_WRITE:
|
case BDT_ISO_FILE_WRITE:
|
||||||
FBlkWrite(bd->file_dsk,buf,blk,cnt);
|
FBlkWrite(bd->file_dsk,buf,blk,count);
|
||||||
break;
|
break;
|
||||||
case BDT_ATA:
|
case BDT_ATA:
|
||||||
case BDT_ATAPI:
|
case BDT_ATAPI:
|
||||||
res=ATAWBlks(dv,buf,blk,cnt);
|
res=ATAWBlks(dv,buf,blk,count);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
bd->last_time=tS;
|
bd->last_time=tS;
|
||||||
if (bd->flags & BDF_READ_CACHE)
|
if (bd->flags & BDF_READ_CACHE)
|
||||||
DiskCacheAdd(dv,buf,blk,cnt);
|
DiskCacheAdd(dv,buf,blk,count);
|
||||||
}
|
}
|
||||||
if (unlock)
|
if (unlock)
|
||||||
DriveUnlock(dv);
|
DriveUnlock(dv);
|
||||||
|
@ -69,18 +69,18 @@ U0 DVDImageRead(U8 dvd_drv_let,U8 *out_name)
|
|||||||
U8 *buf=MAlloc(COPY_BUF_BLKS<<BLK_SIZE_BITS),
|
U8 *buf=MAlloc(COPY_BUF_BLKS<<BLK_SIZE_BITS),
|
||||||
*out_name2=ExtDft(out_name,"ISO");
|
*out_name2=ExtDft(out_name,"ISO");
|
||||||
CFile *f=FOpen(out_name2,"w");
|
CFile *f=FOpen(out_name2,"w");
|
||||||
I64 n,spc=bd->blk_size>>BLK_SIZE_BITS,blk=0,cnt,retry;
|
I64 n,spc=bd->blk_size>>BLK_SIZE_BITS,blk=0,count,retry;
|
||||||
BlkDevInit(bd);
|
BlkDevInit(bd);
|
||||||
if (bd->type!=BDT_ATAPI)
|
if (bd->type!=BDT_ATAPI)
|
||||||
throw('BlkDev');
|
throw('BlkDev');
|
||||||
if (!out_name)
|
if (!out_name)
|
||||||
out_name=blkdev.dft_iso_filename;
|
out_name=blkdev.dft_iso_filename;
|
||||||
cnt=CeilU64(dv->size,spc);
|
count=CeilU64(dv->size,spc);
|
||||||
while (cnt>0) {
|
while (count>0) {
|
||||||
if (cnt>COPY_BUF_BLKS)
|
if (count>COPY_BUF_BLKS)
|
||||||
n=COPY_BUF_BLKS;
|
n=COPY_BUF_BLKS;
|
||||||
else
|
else
|
||||||
n=cnt;
|
n=count;
|
||||||
if (n>bd->max_reads)
|
if (n>bd->max_reads)
|
||||||
n=bd->max_reads;
|
n=bd->max_reads;
|
||||||
|
|
||||||
@ -94,7 +94,7 @@ U0 DVDImageRead(U8 dvd_drv_let,U8 *out_name)
|
|||||||
ATAPIReadBlks2(bd,0,buf,blk/spc,n/spc,TRUE);
|
ATAPIReadBlks2(bd,0,buf,blk/spc,n/spc,TRUE);
|
||||||
|
|
||||||
FBlkWrite(f,buf,blk,n);
|
FBlkWrite(f,buf,blk,n);
|
||||||
cnt-=n;
|
count-=n;
|
||||||
blk+=n;
|
blk+=n;
|
||||||
}
|
}
|
||||||
FClose(f);
|
FClose(f);
|
||||||
@ -105,7 +105,7 @@ U0 DVDImageRead(U8 dvd_drv_let,U8 *out_name)
|
|||||||
class CDualBuf
|
class CDualBuf
|
||||||
{
|
{
|
||||||
U8 *buf0,*buf1;
|
U8 *buf0,*buf1;
|
||||||
I64 in_buf,out_buf,cnt;
|
I64 in_buf,out_buf,count;
|
||||||
U8 *filename;
|
U8 *filename;
|
||||||
CBlkDev *dvd_bd;
|
CBlkDev *dvd_bd;
|
||||||
};
|
};
|
||||||
@ -113,17 +113,17 @@ class CDualBuf
|
|||||||
U0 DVDImageWriteTask(CDualBuf *d)
|
U0 DVDImageWriteTask(CDualBuf *d)
|
||||||
{
|
{
|
||||||
U8 *buf;
|
U8 *buf;
|
||||||
I64 n,blk=0,cnt=d->cnt;
|
I64 n,blk=0,count=d->count;
|
||||||
CFile *f;
|
CFile *f;
|
||||||
if (FileAttr(d->filename)&RS_ATTR_CONTIGUOUS)
|
if (FileAttr(d->filename)&RS_ATTR_CONTIGUOUS)
|
||||||
f=FOpen(d->filename,"rc");
|
f=FOpen(d->filename,"rc");
|
||||||
else
|
else
|
||||||
f=FOpen(d->filename,"r");
|
f=FOpen(d->filename,"r");
|
||||||
while (cnt>0) {
|
while (count>0) {
|
||||||
if (cnt>COPY_BUF_BLKS)
|
if (count>COPY_BUF_BLKS)
|
||||||
n=COPY_BUF_BLKS;
|
n=COPY_BUF_BLKS;
|
||||||
else
|
else
|
||||||
n=cnt;
|
n=count;
|
||||||
if (n>d->dvd_bd->max_writes)
|
if (n>d->dvd_bd->max_writes)
|
||||||
n=d->dvd_bd->max_writes;
|
n=d->dvd_bd->max_writes;
|
||||||
if (d->in_buf&1)
|
if (d->in_buf&1)
|
||||||
@ -134,7 +134,7 @@ U0 DVDImageWriteTask(CDualBuf *d)
|
|||||||
Yield;
|
Yield;
|
||||||
FBlkRead(f,buf,blk,n);
|
FBlkRead(f,buf,blk,n);
|
||||||
d->in_buf++;
|
d->in_buf++;
|
||||||
cnt-=n;
|
count-=n;
|
||||||
blk+=n;
|
blk+=n;
|
||||||
}
|
}
|
||||||
FClose(f);
|
FClose(f);
|
||||||
@ -144,7 +144,7 @@ U0 DVDImageWrite(U8 dvd_drv_let,U8 *in_name=NULL,I64 media_type=MT_DVD)
|
|||||||
{//Write CD/DVD ISO file to disk.
|
{//Write CD/DVD ISO file to disk.
|
||||||
CDualBuf *d=CAlloc(sizeof(CDualBuf));
|
CDualBuf *d=CAlloc(sizeof(CDualBuf));
|
||||||
U8 *buf,*in_name2,*in_name3;
|
U8 *buf,*in_name2,*in_name3;
|
||||||
I64 i,n,spc,blk=0,cnt;
|
I64 i,n,spc,blk=0,count;
|
||||||
CDrive *dv=Letter2Drive(dvd_drv_let);
|
CDrive *dv=Letter2Drive(dvd_drv_let);
|
||||||
CBlkDev *bd=dv->bd,*bd2;
|
CBlkDev *bd=dv->bd,*bd2;
|
||||||
CTask *task;
|
CTask *task;
|
||||||
@ -159,7 +159,7 @@ U0 DVDImageWrite(U8 dvd_drv_let,U8 *in_name=NULL,I64 media_type=MT_DVD)
|
|||||||
Free(d);
|
Free(d);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
cnt=(FSize(f)+BLK_SIZE-1)>>BLK_SIZE_BITS;
|
count=(FSize(f)+BLK_SIZE-1)>>BLK_SIZE_BITS;
|
||||||
FClose(f);
|
FClose(f);
|
||||||
if (bd->type!=BDT_ATAPI)
|
if (bd->type!=BDT_ATAPI)
|
||||||
throw('BlkDev');
|
throw('BlkDev');
|
||||||
@ -175,14 +175,14 @@ U0 DVDImageWrite(U8 dvd_drv_let,U8 *in_name=NULL,I64 media_type=MT_DVD)
|
|||||||
bd->flags|=BDF_READ_ONLY_OVERRIDE;
|
bd->flags|=BDF_READ_ONLY_OVERRIDE;
|
||||||
BlkDevInit(bd);
|
BlkDevInit(bd);
|
||||||
spc=bd->blk_size>>BLK_SIZE_BITS;
|
spc=bd->blk_size>>BLK_SIZE_BITS;
|
||||||
if (dv->size<cnt)
|
if (dv->size<count)
|
||||||
dv->size=cnt;
|
dv->size=count;
|
||||||
|
|
||||||
d->filename=in_name2;
|
d->filename=in_name2;
|
||||||
d->dvd_bd=bd;
|
d->dvd_bd=bd;
|
||||||
d->buf0=MAlloc(COPY_BUF_BLKS<<BLK_SIZE_BITS);
|
d->buf0=MAlloc(COPY_BUF_BLKS<<BLK_SIZE_BITS);
|
||||||
d->buf1=MAlloc(COPY_BUF_BLKS<<BLK_SIZE_BITS);
|
d->buf1=MAlloc(COPY_BUF_BLKS<<BLK_SIZE_BITS);
|
||||||
d->cnt=cnt;
|
d->count=count;
|
||||||
|
|
||||||
task=Spawn(&DVDImageWriteTask,d,"Write CD/DVD");
|
task=Spawn(&DVDImageWriteTask,d,"Write CD/DVD");
|
||||||
while (d->in_buf<=d->out_buf)
|
while (d->in_buf<=d->out_buf)
|
||||||
@ -191,13 +191,13 @@ U0 DVDImageWrite(U8 dvd_drv_let,U8 *in_name=NULL,I64 media_type=MT_DVD)
|
|||||||
BlkDevLock(bd);
|
BlkDevLock(bd);
|
||||||
ATAPIWaitReady(bd,0);
|
ATAPIWaitReady(bd,0);
|
||||||
|
|
||||||
progress1=0; progress1_max=cnt;
|
progress1=0; progress1_max=count;
|
||||||
StrCpy(progress1_desc,"Writing");
|
StrCpy(progress1_desc,"Writing");
|
||||||
while (cnt>0) {
|
while (count>0) {
|
||||||
if (cnt>COPY_BUF_BLKS)
|
if (count>COPY_BUF_BLKS)
|
||||||
n=COPY_BUF_BLKS;
|
n=COPY_BUF_BLKS;
|
||||||
else
|
else
|
||||||
n=cnt;
|
n=count;
|
||||||
if (n>bd->max_writes)
|
if (n>bd->max_writes)
|
||||||
n=bd->max_writes;
|
n=bd->max_writes;
|
||||||
if (d->out_buf&1)
|
if (d->out_buf&1)
|
||||||
@ -208,7 +208,7 @@ U0 DVDImageWrite(U8 dvd_drv_let,U8 *in_name=NULL,I64 media_type=MT_DVD)
|
|||||||
Yield;
|
Yield;
|
||||||
ATAPIWriteBlks(bd,buf,blk/spc,(n+spc-1)/spc);
|
ATAPIWriteBlks(bd,buf,blk/spc,(n+spc-1)/spc);
|
||||||
d->out_buf++;
|
d->out_buf++;
|
||||||
cnt-=n;
|
count-=n;
|
||||||
blk+=n;
|
blk+=n;
|
||||||
progress1+=n;
|
progress1+=n;
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@ I64 FSize(CFile *f)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
CFile *FOpen(U8 *filename,U8 *flags,I64 cnt=0)
|
CFile *FOpen(U8 *filename,U8 *flags,I64 count=0)
|
||||||
{//Allows flags "r","w","w+". "c" for contiguous.
|
{//Allows flags "r","w","w+". "c" for contiguous.
|
||||||
//(It uses $LK,"StrOcc",A="MN:StrOcc"$() for 'w', 'r', '+', 'c')
|
//(It uses $LK,"StrOcc",A="MN:StrOcc"$() for 'w', 'r', '+', 'c')
|
||||||
CFile *f=CAlloc(sizeof(CFile));
|
CFile *f=CAlloc(sizeof(CFile));
|
||||||
@ -16,8 +16,8 @@ CFile *FOpen(U8 *filename,U8 *flags,I64 cnt=0)
|
|||||||
|
|
||||||
f->clus=INVALID_CLUS;
|
f->clus=INVALID_CLUS;
|
||||||
f->fblk_num=0;
|
f->fblk_num=0;
|
||||||
if (cnt>0)
|
if (count>0)
|
||||||
f->max_blk=cnt-1;
|
f->max_blk=count-1;
|
||||||
else
|
else
|
||||||
f->max_blk=I64_MAX;
|
f->max_blk=I64_MAX;
|
||||||
f->file_clus_num=INVALID_CLUS;
|
f->file_clus_num=INVALID_CLUS;
|
||||||
@ -47,10 +47,10 @@ CFile *FOpen(U8 *filename,U8 *flags,I64 cnt=0)
|
|||||||
f->flags|=FF_NEW_FILE;
|
f->flags|=FF_NEW_FILE;
|
||||||
if (dirc=DirContextNew(full_name)) {
|
if (dirc=DirContextNew(full_name)) {
|
||||||
StrCpy(f->de.name,dirc->mask);
|
StrCpy(f->de.name,dirc->mask);
|
||||||
if (cnt>0) {//We pre-alloc the whole thing.
|
if (count>0) {//We pre-alloc the whole thing.
|
||||||
f->de.clus=ClusAlloc(f->dv,0,
|
f->de.clus=ClusAlloc(f->dv,0,
|
||||||
(cnt+f->dv->spc-1)/f->dv->spc,contiguous);
|
(count+f->dv->spc-1)/f->dv->spc,contiguous);
|
||||||
f->de.size=cnt<<BLK_SIZE_BITS;
|
f->de.size=count<<BLK_SIZE_BITS;
|
||||||
DirNew(dirc->dv,Fs->cur_dir,&f->de,TRUE);
|
DirNew(dirc->dv,Fs->cur_dir,&f->de,TRUE);
|
||||||
f->flags&=~FF_NEW_FILE;
|
f->flags&=~FF_NEW_FILE;
|
||||||
}
|
}
|
||||||
@ -126,20 +126,20 @@ I64 FSetClus(CFile *f,I64 c,I64 blk,Bool read)
|
|||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
Bool FBlkRead(CFile *f,U8 *buf,I64 blk=FFB_NEXT_BLK,I64 cnt=1)
|
Bool FBlkRead(CFile *f,U8 *buf,I64 blk=FFB_NEXT_BLK,I64 count=1)
|
||||||
{//Read [nth,n+cnt) blks of file.
|
{//Read [nth,n+count) blks of file.
|
||||||
CDrive *dv=f->dv;
|
CDrive *dv=f->dv;
|
||||||
I64 spc=dv->spc,i,j,c=f->de.clus;
|
I64 spc=dv->spc,i,j,c=f->de.clus;
|
||||||
if (!f || !dv) return FALSE;
|
if (!f || !dv) return FALSE;
|
||||||
if (blk==FFB_NEXT_BLK)
|
if (blk==FFB_NEXT_BLK)
|
||||||
blk=f->fblk_num;
|
blk=f->fblk_num;
|
||||||
if (blk+cnt-1>f->max_blk)
|
if (blk+count-1>f->max_blk)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
if (cnt<=0) return TRUE;
|
if (count<=0) return TRUE;
|
||||||
|
|
||||||
if (f->flags & FF_CONTIGUOUS) {
|
if (f->flags & FF_CONTIGUOUS) {
|
||||||
BlkRead(dv,buf,Clus2Blk(dv,c)+blk,cnt);
|
BlkRead(dv,buf,Clus2Blk(dv,c)+blk,count);
|
||||||
blk+=cnt;
|
blk+=count;
|
||||||
} else {
|
} else {
|
||||||
i=blk/spc;
|
i=blk/spc;
|
||||||
if (0<=f->file_clus_num<=i) {
|
if (0<=f->file_clus_num<=i) {
|
||||||
@ -151,48 +151,48 @@ Bool FBlkRead(CFile *f,U8 *buf,I64 blk=FFB_NEXT_BLK,I64 cnt=1)
|
|||||||
|
|
||||||
if (i=blk%spc) {
|
if (i=blk%spc) {
|
||||||
c=FSetClus(f,c,blk,TRUE);
|
c=FSetClus(f,c,blk,TRUE);
|
||||||
if (cnt<spc-i)
|
if (count<spc-i)
|
||||||
j=cnt;
|
j=count;
|
||||||
else
|
else
|
||||||
j=spc-i;
|
j=spc-i;
|
||||||
MemCpy(buf,f->clus_buf+i<<BLK_SIZE_BITS,j<<BLK_SIZE_BITS);
|
MemCpy(buf,f->clus_buf+i<<BLK_SIZE_BITS,j<<BLK_SIZE_BITS);
|
||||||
buf+=j<<BLK_SIZE_BITS;
|
buf+=j<<BLK_SIZE_BITS;
|
||||||
cnt-=j;
|
count-=j;
|
||||||
blk+=j;
|
blk+=j;
|
||||||
}
|
}
|
||||||
while (cnt>=spc) {
|
while (count>=spc) {
|
||||||
c=FSetClus(f,c,blk,TRUE);
|
c=FSetClus(f,c,blk,TRUE);
|
||||||
MemCpy(buf,f->clus_buf,spc<<BLK_SIZE_BITS);
|
MemCpy(buf,f->clus_buf,spc<<BLK_SIZE_BITS);
|
||||||
buf+=spc<<BLK_SIZE_BITS;
|
buf+=spc<<BLK_SIZE_BITS;
|
||||||
cnt-=spc;
|
count-=spc;
|
||||||
blk+=spc;
|
blk+=spc;
|
||||||
}
|
}
|
||||||
if (cnt>0) {
|
if (count>0) {
|
||||||
c=FSetClus(f,c,blk,TRUE);
|
c=FSetClus(f,c,blk,TRUE);
|
||||||
MemCpy(buf,f->clus_buf,cnt<<BLK_SIZE_BITS);
|
MemCpy(buf,f->clus_buf,count<<BLK_SIZE_BITS);
|
||||||
buf+=cnt<<BLK_SIZE_BITS;
|
buf+=count<<BLK_SIZE_BITS;
|
||||||
blk+=cnt;
|
blk+=count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
f->fblk_num=blk;
|
f->fblk_num=blk;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
Bool FBlkWrite(CFile *f,U8 *buf,I64 blk=FFB_NEXT_BLK,I64 cnt=1)
|
Bool FBlkWrite(CFile *f,U8 *buf,I64 blk=FFB_NEXT_BLK,I64 count=1)
|
||||||
{//Write [nth,n+cnt) blks of file.
|
{//Write [nth,n+count) blks of file.
|
||||||
CDrive *dv=f->dv;
|
CDrive *dv=f->dv;
|
||||||
I64 spc=dv->spc,i,j,c=f->de.clus,c1;
|
I64 spc=dv->spc,i,j,c=f->de.clus,c1;
|
||||||
if (!f || !dv) return FALSE;
|
if (!f || !dv) return FALSE;
|
||||||
if (blk==FFB_NEXT_BLK)
|
if (blk==FFB_NEXT_BLK)
|
||||||
blk=f->fblk_num;
|
blk=f->fblk_num;
|
||||||
if (blk+cnt-1>f->max_blk)
|
if (blk+count-1>f->max_blk)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
if (!(f->flags & FF_WRITE))
|
if (!(f->flags & FF_WRITE))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
if (cnt<=0) return TRUE;
|
if (count<=0) return TRUE;
|
||||||
if (f->flags & FF_CONTIGUOUS) {
|
if (f->flags & FF_CONTIGUOUS) {
|
||||||
BlkWrite(dv,buf,Clus2Blk(dv,c)+blk,cnt);
|
BlkWrite(dv,buf,Clus2Blk(dv,c)+blk,count);
|
||||||
blk+=cnt;
|
blk+=count;
|
||||||
} else {
|
} else {
|
||||||
if (!c) {
|
if (!c) {
|
||||||
c=ClusAlloc(dv,0,1,FALSE);
|
c=ClusAlloc(dv,0,1,FALSE);
|
||||||
@ -220,42 +220,42 @@ Bool FBlkWrite(CFile *f,U8 *buf,I64 blk=FFB_NEXT_BLK,I64 cnt=1)
|
|||||||
|
|
||||||
if (i=blk%spc) {
|
if (i=blk%spc) {
|
||||||
FSetClus(f,c,blk,TRUE);
|
FSetClus(f,c,blk,TRUE);
|
||||||
if (cnt<spc-i)
|
if (count<spc-i)
|
||||||
j=cnt;
|
j=count;
|
||||||
else
|
else
|
||||||
j=spc-i;
|
j=spc-i;
|
||||||
MemCpy(f->clus_buf+BLK_SIZE*i,buf,j<<BLK_SIZE_BITS);
|
MemCpy(f->clus_buf+BLK_SIZE*i,buf,j<<BLK_SIZE_BITS);
|
||||||
f->flags|=FF_BUF_DIRTY;
|
f->flags|=FF_BUF_DIRTY;
|
||||||
buf+=j<<BLK_SIZE_BITS;
|
buf+=j<<BLK_SIZE_BITS;
|
||||||
cnt-=j;
|
count-=j;
|
||||||
blk+=j;
|
blk+=j;
|
||||||
if (cnt>0) {
|
if (count>0) {
|
||||||
c1=c;
|
c1=c;
|
||||||
c=ClusNumNext(dv,c1,1);
|
c=ClusNumNext(dv,c1,1);
|
||||||
if (c==INVALID_CLUS)
|
if (c==INVALID_CLUS)
|
||||||
c=ClusAlloc(dv,c1,1,FALSE);
|
c=ClusAlloc(dv,c1,1,FALSE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while (cnt>=spc) {
|
while (count>=spc) {
|
||||||
FSetClus(f,c,blk,FALSE);
|
FSetClus(f,c,blk,FALSE);
|
||||||
MemCpy(f->clus_buf,buf,spc<<BLK_SIZE_BITS);
|
MemCpy(f->clus_buf,buf,spc<<BLK_SIZE_BITS);
|
||||||
f->flags|=FF_BUF_DIRTY;
|
f->flags|=FF_BUF_DIRTY;
|
||||||
buf+=spc<<BLK_SIZE_BITS;
|
buf+=spc<<BLK_SIZE_BITS;
|
||||||
cnt-=spc;
|
count-=spc;
|
||||||
blk+=spc;
|
blk+=spc;
|
||||||
if (cnt>0) {
|
if (count>0) {
|
||||||
c1=c;
|
c1=c;
|
||||||
c=ClusNumNext(dv,c1,1);
|
c=ClusNumNext(dv,c1,1);
|
||||||
if (c==INVALID_CLUS)
|
if (c==INVALID_CLUS)
|
||||||
c=ClusAlloc(dv,c1,1,FALSE);
|
c=ClusAlloc(dv,c1,1,FALSE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (cnt>0) {
|
if (count>0) {
|
||||||
FSetClus(f,c,blk,TRUE);
|
FSetClus(f,c,blk,TRUE);
|
||||||
MemCpy(f->clus_buf,buf,cnt<<BLK_SIZE_BITS);
|
MemCpy(f->clus_buf,buf,count<<BLK_SIZE_BITS);
|
||||||
f->flags|=FF_BUF_DIRTY;
|
f->flags|=FF_BUF_DIRTY;
|
||||||
buf+=cnt<<BLK_SIZE_BITS;
|
buf+=count<<BLK_SIZE_BITS;
|
||||||
blk+=cnt;
|
blk+=count;
|
||||||
}
|
}
|
||||||
if (f->de.size<blk<<BLK_SIZE_BITS)
|
if (f->de.size<blk<<BLK_SIZE_BITS)
|
||||||
f->de.size=blk<<BLK_SIZE_BITS;
|
f->de.size=blk<<BLK_SIZE_BITS;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
U0 DiskCacheInit(I64 size_in_U8s)
|
U0 DiskCacheInit(I64 size_in_U8s)
|
||||||
{
|
{
|
||||||
CCacheBlk *tmpc;
|
CCacheBlk *tmpc;
|
||||||
I64 i,cnt;
|
I64 i,count;
|
||||||
|
|
||||||
while (LBts(&sys_semas[SEMA_DSK_CACHE],0))
|
while (LBts(&sys_semas[SEMA_DSK_CACHE],0))
|
||||||
Yield;
|
Yield;
|
||||||
@ -17,9 +17,9 @@ U0 DiskCacheInit(I64 size_in_U8s)
|
|||||||
blkdev.cache_base=AMAlloc(size_in_U8s);
|
blkdev.cache_base=AMAlloc(size_in_U8s);
|
||||||
QueueInit(blkdev.cache_ctrl);
|
QueueInit(blkdev.cache_ctrl);
|
||||||
|
|
||||||
cnt=MSize(blkdev.cache_base)/sizeof(CCacheBlk);
|
count=MSize(blkdev.cache_base)/sizeof(CCacheBlk);
|
||||||
blkdev.cache_size=cnt*BLK_SIZE;
|
blkdev.cache_size=count*BLK_SIZE;
|
||||||
for (i=0;i<cnt;i++) {
|
for (i=0;i<count;i++) {
|
||||||
tmpc=blkdev.cache_base+i;
|
tmpc=blkdev.cache_base+i;
|
||||||
QueueInsert(tmpc,blkdev.cache_ctrl->last_lru);
|
QueueInsert(tmpc,blkdev.cache_ctrl->last_lru);
|
||||||
tmpc->next_hash=tmpc->last_hash=tmpc;
|
tmpc->next_hash=tmpc->last_hash=tmpc;
|
||||||
@ -73,13 +73,13 @@ CCacheBlk *DiskCacheFind(CDrive *dv,I64 blk)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
U0 DiskCacheAdd(CDrive *dv,U8 *buf, I64 blk, I64 cnt)
|
U0 DiskCacheAdd(CDrive *dv,U8 *buf, I64 blk, I64 count)
|
||||||
{
|
{
|
||||||
CCacheBlk *tmpc;
|
CCacheBlk *tmpc;
|
||||||
if (blkdev.cache_base) {
|
if (blkdev.cache_base) {
|
||||||
while (LBts(&sys_semas[SEMA_DSK_CACHE],0))
|
while (LBts(&sys_semas[SEMA_DSK_CACHE],0))
|
||||||
Yield;
|
Yield;
|
||||||
while (cnt-->0) {
|
while (count-->0) {
|
||||||
if (!(tmpc=DiskCacheFind(dv,blk)))
|
if (!(tmpc=DiskCacheFind(dv,blk)))
|
||||||
tmpc=blkdev.cache_ctrl->next_lru;
|
tmpc=blkdev.cache_ctrl->next_lru;
|
||||||
DiskCacheQueueRemove(tmpc);
|
DiskCacheQueueRemove(tmpc);
|
||||||
@ -116,27 +116,27 @@ U0 DiskCacheInvalidate2(CDrive *dv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
U0 RCache(CDrive *dv,U8 **_buf, I64 *_blk, I64 *_cnt)
|
U0 RCache(CDrive *dv,U8 **_buf, I64 *_blk, I64 *_count)
|
||||||
{
|
{
|
||||||
CCacheBlk *tmpc;
|
CCacheBlk *tmpc;
|
||||||
if (blkdev.cache_base) {
|
if (blkdev.cache_base) {
|
||||||
while (LBts(&sys_semas[SEMA_DSK_CACHE],0))
|
while (LBts(&sys_semas[SEMA_DSK_CACHE],0))
|
||||||
Yield;
|
Yield;
|
||||||
//fetch leading blks from cache
|
//fetch leading blks from cache
|
||||||
while (*_cnt>0) {
|
while (*_count>0) {
|
||||||
if (tmpc=DiskCacheFind(dv,*_blk)) {
|
if (tmpc=DiskCacheFind(dv,*_blk)) {
|
||||||
MemCpy(*_buf,&tmpc->body,BLK_SIZE);
|
MemCpy(*_buf,&tmpc->body,BLK_SIZE);
|
||||||
*_cnt-=1;
|
*_count-=1;
|
||||||
*_buf+=BLK_SIZE;
|
*_buf+=BLK_SIZE;
|
||||||
*_blk+=1;
|
*_blk+=1;
|
||||||
} else
|
} else
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
//fetch trailing blks from cache
|
//fetch trailing blks from cache
|
||||||
while (*_cnt>0) {
|
while (*_count>0) {
|
||||||
if (tmpc=DiskCacheFind(dv,*_blk+*_cnt-1)) {
|
if (tmpc=DiskCacheFind(dv,*_blk+*_count-1)) {
|
||||||
MemCpy(*_buf+(*_cnt-1)<<BLK_SIZE_BITS,&tmpc->body,BLK_SIZE);
|
MemCpy(*_buf+(*_count-1)<<BLK_SIZE_BITS,&tmpc->body,BLK_SIZE);
|
||||||
*_cnt-=1;
|
*_count-=1;
|
||||||
} else
|
} else
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1,16 +1,16 @@
|
|||||||
I64 ClusNumNext(CDrive *dv,I64 c,I64 cnt=1)
|
I64 ClusNumNext(CDrive *dv,I64 c,I64 count=1)
|
||||||
{//Return next cnt'th clus in chain.
|
{//Return next count'th clus in chain.
|
||||||
Bool unlock;
|
Bool unlock;
|
||||||
DriveCheck(dv);
|
DriveCheck(dv);
|
||||||
if (cnt<=0) return c;
|
if (count<=0) return c;
|
||||||
try {
|
try {
|
||||||
unlock=DriveLock(dv);
|
unlock=DriveLock(dv);
|
||||||
switch (dv->fs_type) {
|
switch (dv->fs_type) {
|
||||||
case FSt_REDSEA:
|
case FSt_REDSEA:
|
||||||
c+=cnt;
|
c+=count;
|
||||||
break;
|
break;
|
||||||
case FSt_FAT32:
|
case FSt_FAT32:
|
||||||
while (cnt-->0 && 0<c<0x0FFFFFF8) {
|
while (count-->0 && 0<c<0x0FFFFFF8) {
|
||||||
DriveFATBlkSet(dv,c);
|
DriveFATBlkSet(dv,c);
|
||||||
c=dv->cur_fat_blk[c & (BLK_SIZE/4-1)];
|
c=dv->cur_fat_blk[c & (BLK_SIZE/4-1)];
|
||||||
}
|
}
|
||||||
@ -78,9 +78,9 @@ I64 ClusBlkRead(CDrive *dv,U8 *buf,I64 c,I64 blks)
|
|||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
I64 ClusRead(CDrive *dv,U8 *buf,I64 c,I64 cnt)
|
I64 ClusRead(CDrive *dv,U8 *buf,I64 c,I64 count)
|
||||||
{//Read clus cnt from drv to buf.
|
{//Read clus count from drv to buf.
|
||||||
return ClusBlkRead(dv,buf,c,cnt*dv->spc);
|
return ClusBlkRead(dv,buf,c,count*dv->spc);
|
||||||
}
|
}
|
||||||
|
|
||||||
I64 ClusBlkWrite(CDrive *dv,U8 *buf,I64 c,I64 blks)
|
I64 ClusBlkWrite(CDrive *dv,U8 *buf,I64 c,I64 blks)
|
||||||
@ -120,25 +120,25 @@ I64 ClusBlkWrite(CDrive *dv,U8 *buf,I64 c,I64 blks)
|
|||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
I64 ClusWrite(CDrive *dv,U8 *buf,I64 c,I64 cnt)
|
I64 ClusWrite(CDrive *dv,U8 *buf,I64 c,I64 count)
|
||||||
{//Write clus cnt from buf to drv.
|
{//Write clus count from buf to drv.
|
||||||
return ClusBlkWrite(dv,buf,c,cnt*dv->spc);
|
return ClusBlkWrite(dv,buf,c,count*dv->spc);
|
||||||
}
|
}
|
||||||
|
|
||||||
I64 ClusAlloc(CDrive *dv,I64 c=0,I64 cnt=1,Bool contiguous=FALSE)
|
I64 ClusAlloc(CDrive *dv,I64 c=0,I64 count=1,Bool contiguous=FALSE)
|
||||||
{//Alloc clus cnt into chain.
|
{//Alloc clus count into chain.
|
||||||
//c=0 means first clus in chain
|
//c=0 means first clus in chain
|
||||||
DriveCheck(dv);
|
DriveCheck(dv);
|
||||||
if (cnt<=0) return c;
|
if (count<=0) return c;
|
||||||
switch (dv->fs_type) {
|
switch (dv->fs_type) {
|
||||||
case FSt_REDSEA:
|
case FSt_REDSEA:
|
||||||
return RedSeaAllocClus(dv,cnt);
|
return RedSeaAllocClus(dv,count);
|
||||||
case FSt_FAT32:
|
case FSt_FAT32:
|
||||||
if (contiguous) {
|
if (contiguous) {
|
||||||
if (c) throw('File');
|
if (c) throw('File');
|
||||||
return FAT32AllocContiguousClus(dv,cnt);
|
return FAT32AllocContiguousClus(dv,count);
|
||||||
} else
|
} else
|
||||||
return FAT32AllocClus(dv,c,cnt);
|
return FAT32AllocClus(dv,c,count);
|
||||||
default:
|
default:
|
||||||
throw('Drive');
|
throw('Drive');
|
||||||
}
|
}
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user