Add VM opcodes NOP, LANG, and SANG

- To simplify code generation genericizing, add three new opcodes
  * NOP: No-Operation
  * LANG: Load Angle - load a BAM angle into a float reg as degrees
  * SANG: Save Angle - store a float reg into a BEM angle, converting from degrees
This commit is contained in:
Randy Heit 2013-08-23 21:46:40 -05:00
commit 3ea0d1b444
3 changed files with 32 additions and 0 deletions

View file

@ -220,6 +220,16 @@ begin:
GETADDR(PB,RC,X_READ_NIL);
reg.f[a] = *(VM_SWORD *)ptr / 65536.0;
NEXTOP;
OP(LANG):
ASSERTF(a); ASSERTA(B); ASSERTKD(C);
GETADDR(PB,KC,X_READ_NIL);
reg.f[a] = (*(VM_UWORD *)ptr >> 1) * (180.0 / 0x40000000); // BAM -> deg
NEXTOP;
OP(LANG_R):
ASSERTF(a); ASSERTA(B); ASSERTD(C);
GETADDR(PB,RC,X_READ_NIL);
reg.f[a] = (*(VM_UWORD *)ptr >> 1) * (180.0 / 0x40000000);
NEXTOP;
OP(LBIT):
ASSERTD(a); ASSERTA(B);
GETADDR(PB,0,X_READ_NIL);
@ -326,6 +336,17 @@ begin:
GETADDR(PA,RC,X_WRITE_NIL);
*(VM_SWORD *)ptr = (VM_SWORD)(reg.f[B] * 65536.0);
NEXTOP;
OP(SANG):
ASSERTA(a); ASSERTF(B); ASSERTKD(C);
GETADDR(PA,KC,X_WRITE_NIL);
*(VM_UWORD *)ptr = (VM_UWORD)(reg.f[B] * ((1<<30) / 180.0)) << 1; // deg -> BAM
NEXTOP;
OP(SANG_R):
ASSERTA(a); ASSERTF(B); ASSERTD(C);
GETADDR(PA,RC,X_WRITE_NIL);
*(VM_UWORD *)ptr = (VM_UWORD)(reg.f[B] * ((1<<30) / 180.0)) << 1;
NEXTOP;
OP(SBIT):
ASSERTA(a); ASSERTD(B);
GETADDR(PA,0,X_WRITE_NIL);
@ -1301,6 +1322,9 @@ begin:
ASSERTA(B); ASSERTKA(C);
CMPJMP(reg.a[B] == konsta[C].v);
NEXTOP;
OP(NOP):
NEXTOP;
}
}
catch(VMException *exception)