// File: /workspace/github_cpp_makefile_star2_O1/czmccrory[P]ManchesterBaby/baby.cpp
// Function: ManchesterBaby::immediateEx(int, int)
void ManchesterBaby::immediateEx(int opcode, int operand){
  Line value = store.at(operand);
  clrscr();
  //Process the opcode
  switch(opcode){
    case 0: 
    //Set CI to content of Store location
      imjmp(value.getDecOperand());
      break;
    case 1:
    //Add content of Store location to CI
      imjrp(value.getDecOperand());
      break;
    case 2:
    //Load Accumulator with negative form of Store contents
      imldn(value.getDecVector());
      break;
    case 3:
    //Copy Accumulator to Store location
      imsto(value);
      break;
    case 4:
    //Subtract content of Store location from Accumulator
      imsub(value.getDecVector());
      break;
    case 5:
    //Subtract content of Store location from Accumulator
      imsub(value.getDecVector());
      break;
    case 6:
    //Increment CI if Accumulator value negative, otherwise do nothing
      cmp();
      break;
    case 7:
    //Halt the Baby and light the 'stop lamp'
      stp();
      break;
    case 8:
    //Multiply content of Store and Accumulator
      immul(value.getDecVector());
      break;
    case 9:
    //Load Accumulator with (positive form of) Store contents
      imldp(value.getDecVector());
      break;
    case 10:
    //Add content of Store and Accumulator
      imadd(value.getDecVector());
      break;
    case 11:
    //Copy negative form of Accumulator to Store location
      imnegsto(value);
      break;
    case 12:
    	inc();
    	break;
    case 13:
    	dec();
    	break;
    default:
      break;
  }
}

// Assembly:
pushq %rbp
pushq %rbx
subq $0x18, %rsp
movl %esi, %ebp
movslq %edx, %rsi
movq (%rdi), %rax
movq 0x8(%rdi), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
cmpq %rsi, %rdx
jbe 0x4871
movq %rdi, %rbx
movq (%rax,%rsi,8), %rax
movq %rax, (%rsp)
movq 0x68b2(%rip), %rdi      # 0xafc8
leaq 0x29c1(%rip), %rsi      # 0x70de
movl $0xa, %edx
callq 0x2200
movq 0x689a(%rip), %rdi      # 0xafc8
callq 0x2120
cmpl $0xd, %ebp
ja 0x4862
movl %ebp, %eax
leaq 0x28f7(%rip), %rcx      # 0x703c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %rsp, %rdi
callq 0x63a6
movq %rbx, %rdi
movl %eax, %esi
callq 0x35ca
jmp 0x4862
movq (%rsp), %rax
leaq 0x8(%rsp), %rsi
movq %rax, (%rsi)
movq %rbx, %rdi
callq 0x4384
leaq 0x8(%rsp), %rdi
jmp 0x47f9
movq %rbx, %rdi
callq 0x355a
jmp 0x4862
movq %rsp, %rdi
callq 0x63a6
movq %rbx, %rdi
movl %eax, %esi
callq 0x3cda
jmp 0x4862
movq %rsp, %rdi
callq 0x63a6
movq %rbx, %rdi
movl %eax, %esi
callq 0x2ec6
jmp 0x4862
leaq 0x38(%rbx), %rdi
movq 0x40(%rbx), %rdx
leaq 0x28dc(%rip), %rcx      # 0x70a6
movl $0x4, %r8d
xorl %esi, %esi
callq 0x2290
movb $0x1, 0x79(%rbx)
jmp 0x4862
movq (%rsp), %rax
leaq 0x10(%rsp), %rsi
movq %rax, (%rsi)
movq %rbx, %rdi
callq 0x3200
leaq 0x10(%rsp), %rdi
callq 0x6258
jmp 0x4862
movq %rsp, %rdi
callq 0x6396
movq %rbx, %rdi
movl %eax, %esi
callq 0x2852
jmp 0x4862
movq %rsp, %rdi
callq 0x6396
movq %rbx, %rdi
movl %eax, %esi
callq 0x2b86
jmp 0x4862
movq %rbx, %rdi
callq 0x3592
jmp 0x4862
movq %rbx, %rdi
callq 0x3764
jmp 0x4862
movq %rsp, %rdi
callq 0x63a6
movq %rbx, %rdi
movl %eax, %esi
callq 0x4032
jmp 0x4862
movq %rsp, %rdi
callq 0x63a6
movq %rbx, %rdi
movl %eax, %esi
callq 0x3988
movq %rsp, %rdi
callq 0x6258
addq $0x18, %rsp
popq %rbx
popq %rbp
retq
leaq 0x2afd(%rip), %rdi      # 0x7375
xorl %eax, %eax
callq 0x2270
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
jmp 0x4891
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x6258
jmp 0x489b
movq %rax, %rbx
movq %rsp, %rdi
callq 0x6258
movq %rbx, %rdi
callq 0x2300
nop