@@ -959,6 +959,7 @@ E_POKER_CIPHER001=2,
959
959
E_POKER_CIPHER002=3,
960
960
E_POKER_CIPHER003=4,
961
961
E_POKER_CIPHER004=5,
962
+ E_POKER_SUM16=6,
962
963
E_POKER_END
963
964
};
964
965
@@ -969,6 +970,7 @@ char *strpoker[]={
969
970
"CIPHER002 running XOR initialised with memory location",
970
971
"CIPHER003 XOR with LSB of memory location",
971
972
"CIPHER004 XOR with key looping",
973
+ "SUM16",
972
974
NULL
973
975
};
974
976
@@ -20659,6 +20661,29 @@ void __SUMMEM(struct s_assenv *ae) {
20659
20661
}
20660
20662
}
20661
20663
20664
+ void __SUM16(struct s_assenv *ae) {
20665
+ struct s_poker poker={0};
20666
+
20667
+ if (!ae->wl[ae->idx].t && !ae->wl[ae->idx+1].t && ae->wl[ae->idx+2].t==1) {
20668
+ /* no poke in a NOCODE section */
20669
+ if (!ae->nocode) {
20670
+ poker.method=E_POKER_SUM16;
20671
+ poker.istart=ae->idx+1;
20672
+ poker.iend=ae->idx+2;
20673
+ ExpressionFastTranslate(ae,&ae->wl[ae->idx+1].w,1);
20674
+ ExpressionFastTranslate(ae,&ae->wl[ae->idx+2].w,1);
20675
+ poker.outputadr=ae->outputadr;
20676
+ poker.ibank=ae->activebank;
20677
+ poker.ipoker=ae->idx;
20678
+ ObjectArrayAddDynamicValueConcat((void**)&ae->poker,&ae->nbpoker,&ae->maxpoker,&poker,sizeof(poker));
20679
+ }
20680
+ ___output(ae,0);
20681
+ ___output(ae,0);
20682
+ } else {
20683
+ MakeError(ae,ae->idx,GetCurrentFile(ae),ae->wl[ae->idx].l,"usage is SUM16 start,end\n");
20684
+ }
20685
+ }
20686
+
20662
20687
void __XORMEM(struct s_assenv *ae) {
20663
20688
struct s_poker poker={0};
20664
20689
@@ -20996,6 +21021,7 @@ struct s_asm_keyword instruction[]={
20996
21021
{"ENDMODULE",0,0,__ENDMODULE},
20997
21022
{"TIMESTAMP",0,0,__TIMESTAMP},
20998
21023
{"SUMMEM",0,0,__SUMMEM},
21024
+ {"SUM16",0,0,__SUM16},
20999
21025
{"XORMEM",0,0,__XORMEM},
21000
21026
{"CIPHERMEM",0,0,__CIPHERMEM},
21001
21027
{"EXTERNAL",0,0,__EXTERNAL},
@@ -22285,6 +22311,7 @@ int Assemble(struct s_assenv *ae, unsigned char **dataout, int *lenout, struct s
22285
22311
for (i=0;i<ae->nbpoker;i++) {
22286
22312
int istart=-1,iend=-1;
22287
22313
unsigned char xorval,sumval;
22314
+ unsigned short int sum16;
22288
22315
22289
22316
/* start/end */
22290
22317
ae->idx=ae->poker[i].istart; /* exp hack */
@@ -22346,6 +22373,14 @@ int Assemble(struct s_assenv *ae, unsigned char **dataout, int *lenout, struct s
22346
22373
if (zekey) MemFree(zekey);
22347
22374
}
22348
22375
break;
22376
+ case E_POKER_SUM16:
22377
+ sum16=0;
22378
+ for (j=istart;j<iend;j++) {
22379
+ sum16+=ae->mem[ae->poker[i].ibank][j];
22380
+ }
22381
+ ae->mem[ae->poker[i].ibank][ae->poker[i].outputadr]=sum16&0xFF;
22382
+ ae->mem[ae->poker[i].ibank][ae->poker[i].outputadr+1]=sum16>>8;
22383
+ break;
22349
22384
default:printf("warning remover\n");break;
22350
22385
}
22351
22386
@@ -27168,6 +27203,8 @@ int RasmAssembleInfoParam(const char *datain, int lenin, unsigned char **dataout
27168
27203
#define AUTOTEST_GTILES_KO "incbin 'autotest_include.raw',GTILES,5"
27169
27204
#define AUTOTEST_ITILES_KO "incbin 'autotest_include.raw',ITILES,5"
27170
27205
27206
+ #define AUTOTEST_SUM16 " tot=0: repeat 256: v=rnd(256): defb v: tot+=v: rend: sum16 0,256: defw tot"
27207
+
27171
27208
27172
27209
struct s_autotest_keyword {
27173
27210
char *keywordtest;
@@ -28618,6 +28655,11 @@ printf("testing formula function for Plus color management OK\n");
28618
28655
if (!ret) {} else {printf("Autotest %03d ERROR (formula func FRAC)\n",cpt);exit(-1);}
28619
28656
if (opcode) MemFree(opcode);opcode=NULL;cpt++;
28620
28657
printf("testing formula FRAC function OK\n");
28658
+
28659
+ ret=RasmAssemble(AUTOTEST_SUM16,strlen(AUTOTEST_SUM16),&opcode,&opcodelen);
28660
+ if (!ret && opcodelen==260 && opcode[256]==opcode[258] && opcode[257]==opcode[259]) {} else {printf("Autotest %03d ERROR (SUMMEM16)\n",cpt);exit(-1);}
28661
+ if (opcode) MemFree(opcode);opcode=NULL;cpt++;
28662
+ printf("testing directive SUMMEM16 OK\n");
28621
28663
28622
28664
ret=RasmAssemble(AUTOTEST_RND,strlen(AUTOTEST_RND),&opcode,&opcodelen);
28623
28665
if (!ret) {} else {printf("Autotest %03d ERROR (formula func RND)\n",cpt);exit(-1);}
0 commit comments