Adding support for Immediate add mode

The masking in immediate mode might not be proper. I could understand that you had masked 12bits and then 8bits to get the displacement in place for 20-bit displacement ( cp[-2] |= n&0xfff;          cp[-1] |= (n>>4)&0xff00;)  But in my case I need all the 32bits, so not sure how to go about it. Currently I have just used "n" since no point in "and with 0xffff" But I am getting core dump. Please Let me know your comments on these.
This commit is contained in:
niravthakkar 2016-12-02 17:37:20 +05:30 committed by GitHub
parent b97a7f7b44
commit f0dd40dc50

View File

@ -233,7 +233,10 @@ void dasm_put(Dst_DECL, int start, ...)
break; break;
case DASM_IMM16: case DASM_IMM16:
case DASM_IMM32: case DASM_IMM32:
fprintf(stderr, "not implemented\n"); CK((n>>32) == 0, RANGE_I);
b[pos++]=n;
break;
//fprintf(stderr, "not implemented\n");
case DASM_DISP20: case DASM_DISP20:
CK(-(1<<19) <= n && n < (1<<19), RANGE_I); CK(-(1<<19) <= n && n < (1<<19), RANGE_I);
b[pos++] = n; b[pos++] = n;
@ -368,7 +371,9 @@ int dasm_encode(Dst_DECL, void *buffer)
case DASM_LABEL_PC: break; case DASM_LABEL_PC: break;
case DASM_IMM16: case DASM_IMM16:
case DASM_IMM32: case DASM_IMM32:
fprintf(stderr, "not implemented\n"); //pintf(stderr, "not implemented\n");
cp[-1] |= n
cp[-2] |= n
break; break;
case DASM_DISP20: case DASM_DISP20:
cp[-2] |= n&0xfff; cp[-2] |= n&0xfff;