// File: 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
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x40(%rbp)
movslq -0x10(%rbp), %rsi
callq 0x5b60
movq (%rax), %rax
movq %rax, -0x18(%rbp)
callq 0x4770
jmp 0x47d1
movl -0xc(%rbp), %eax
movq %rax, -0x48(%rbp)
subq $0xd, %rax
ja 0x49bb
movq -0x48(%rbp), %rax
leaq 0x684f(%rip), %rcx      # 0xb03c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0x49cc
leaq -0x18(%rbp), %rdi
callq 0x7f40
movl %eax, -0x4c(%rbp)
jmp 0x4815
movl -0x4c(%rbp), %esi
movq -0x40(%rbp), %rdi
callq 0x3880
jmp 0x4823
jmp 0x49bd
leaq -0x18(%rbp), %rdi
callq 0x7f40
movl %eax, -0x50(%rbp)
jmp 0x4836
movl -0x50(%rbp), %esi
movq -0x40(%rbp), %rdi
callq 0x39c0
jmp 0x4844
jmp 0x49bd
leaq -0x18(%rbp), %rdi
callq 0x7f70
movl %eax, -0x54(%rbp)
jmp 0x4857
movl -0x54(%rbp), %esi
movq -0x40(%rbp), %rdi
callq 0x3b20
jmp 0x4865
jmp 0x49bd
movq -0x40(%rbp), %rdi
movq -0x18(%rbp), %rax
movq %rax, -0x30(%rbp)
leaq -0x30(%rbp), %rsi
callq 0x3c60
jmp 0x4881
leaq -0x30(%rbp), %rdi
callq 0x7ac0
jmp 0x49bd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x7ac0
jmp 0x49cc
leaq -0x18(%rbp), %rdi
callq 0x7f70
movl %eax, -0x58(%rbp)
jmp 0x48b7
movl -0x58(%rbp), %esi
movq -0x40(%rbp), %rdi
callq 0x3e80
jmp 0x48c5
jmp 0x49bd
leaq -0x18(%rbp), %rdi
callq 0x7f70
movl %eax, -0x5c(%rbp)
jmp 0x48d8
movl -0x5c(%rbp), %esi
movq -0x40(%rbp), %rdi
callq 0x3e80
jmp 0x48e6
jmp 0x49bd
movq -0x40(%rbp), %rdi
callq 0x3f40
jmp 0x48f6
jmp 0x49bd
movq -0x40(%rbp), %rdi
callq 0x3f90
jmp 0x4906
jmp 0x49bd
leaq -0x18(%rbp), %rdi
callq 0x7f70
movl %eax, -0x60(%rbp)
jmp 0x4919
movl -0x60(%rbp), %esi
movq -0x40(%rbp), %rdi
callq 0x40a0
jmp 0x4927
jmp 0x49bd
leaq -0x18(%rbp), %rdi
callq 0x7f70
movl %eax, -0x64(%rbp)
jmp 0x493a
movl -0x64(%rbp), %esi
movq -0x40(%rbp), %rdi
callq 0x4210
jmp 0x4948
jmp 0x49bd
leaq -0x18(%rbp), %rdi
callq 0x7f70
movl %eax, -0x68(%rbp)
jmp 0x4958
movl -0x68(%rbp), %esi
movq -0x40(%rbp), %rdi
callq 0x4380
jmp 0x4966
jmp 0x49bd
movq -0x40(%rbp), %rdi
movq -0x18(%rbp), %rax
movq %rax, -0x38(%rbp)
leaq -0x38(%rbp), %rsi
callq 0x44f0
jmp 0x497f
leaq -0x38(%rbp), %rdi
callq 0x7ac0
jmp 0x49bd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x7ac0
jmp 0x49cc
movq -0x40(%rbp), %rdi
callq 0x3de0
jmp 0x49ac
jmp 0x49bd
movq -0x40(%rbp), %rdi
callq 0x3e30
jmp 0x49b9
jmp 0x49bd
jmp 0x49bd
leaq -0x18(%rbp), %rdi
callq 0x7ac0
addq $0x70, %rsp
popq %rbp
retq
leaq -0x18(%rbp), %rdi
callq 0x7ac0
movq -0x20(%rbp), %rdi
callq 0x33e0
nop