Loading ...
Sorry, an error occurred while loading the content.

Wrong hex code with new mnemonic.

Expand Messages
  • Javier Martínez
    Hi all, I m trying to implement new 18F core mnemonics, but I ve problems with one on them. The mnemonic is LFSR f,k where f=0..2 and K it s a 12bit
    Message 1 of 1 , Aug 30, 2003
    • 0 Attachment
      Hi all,

      I'm trying to implement new 18F core mnemonics, but I've problems with
      one on them.

      The mnemonic is "LFSR f,k" where f=0..2 and K it's a 12bit literal.
      This loads the K value into the desired fsr (we have 3 FSRs), and it's a
      2 words mnemonic:

      LFSR f, k

      1rst word: 1110 1110 00ff kkkk ; "kkkk" is k11,k10,k9,k8
      2nd word: 1111 0000 kkkk kkkk ; "kkkk kkkk" is k7..k0

      Currently JAl compiles OK and makes the asm and hex file. The asm code
      it's ok:

      ;; 008 : LFSR 1,0x0200
      lfsr 1,H'200'

      ... but the hex code it's partially wrong. First word it's OK but not
      the second one:

      Should be: EE12 F000
      but makes: EE12 F0C8

      Here's the source code, if someone see what I can't see...

      - This code is only manages the K constant (field_flabel).
      - opcode_f2nd it's for the 2nd word, (here's the mistake).

      if ( (code_has(p->opcode, field_flabel) )) {
      tree qq = p->next;
      assert_pointer(NULL, qq->value);
      qq = qq->value;
      if (target_cpu != pic_16) {
      opcode |= (qq->x & 0x7FF);
      } else {
      ; ****** this goes bad (2nd word).
      if (p->opcode == opcode_f2nd) {
      opcode |= (qq->x & 0x0FF ) ;
      } else {
      ; ****** this goes OK (1rst word).
      sprintf(dest, ",H'%03X'", qq->x);
      opcode |= ((qq->x & 0xF00) >> 8) ;

      The second word declaration:

      if (target_cpu == pic_16) {
      if (opcode == opcode_lfsr) {
      p = new_chain2(p, new_asm(loc, opcode_f2nd, arg1, arg2));

      The flabel declaration:

      if (code_has(p->opcode, field_flabel)) {
      assert_pointer(NULL, arg2);
      p->next = new_const(new_value(type_universal, arg2));

      In opcode_value_16 array (starting opcode):

      LFSR = 0xEE00
      f2nd = 0xF000

      Thanks in advantage,
    Your message has been successfully submitted and would be delivered to recipients shortly.