// File: ys1998[P]spsim/src/issuer.cpp
// Function: Issuer::tock()
void Issuer::tock(void){
	for(int j=0; j < NUM_ALU; ++j){
		if(!l[j]->valid() && i[j].is_valid()){		// write only when previous data has been read
			auto regs = i[j].physical_regs();
			if(j == addrescal_latch){
				int immediate = i[j].get_immediate();
				l[j]->write(std::make_tuple(i[j], immediate, rf->read(std::get<1>(regs))));
				i[j] = Instruction();
			}else if(j == memory_latch){
				l[j]->write(std::make_tuple(i[j], mem_address, rf->read(std::get<0>(regs))));
				i[j] = Instruction();
			}else{
				l[j]->write(std::make_tuple(i[j], rf->read(std::get<0>(regs)), rf->read(std::get<1>(regs))));
				i[j] = Instruction();
			}
		}
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x3b0, %rsp            # imm = 0x3B0
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x338(%rbp)
movl $0x0, -0xc(%rbp)
cmpl $0x4, -0xc(%rbp)
jge 0x120d2
movq -0x338(%rbp), %rax
movslq -0xc(%rbp), %rcx
movq 0x1e8(%rax,%rcx,8), %rdi
callq 0x6310
testb $0x1, %al
jne 0x120c2
movq -0x338(%rbp), %rdi
addq $0x8, %rdi
movslq -0xc(%rbp), %rax
imulq $0x78, %rax, %rax
addq %rax, %rdi
callq 0x6280
testb $0x1, %al
jne 0x11d0f
jmp 0x120c2
movq -0x338(%rbp), %rsi
addq $0x8, %rsi
movslq -0xc(%rbp), %rax
imulq $0x78, %rax, %rax
addq %rax, %rsi
leaq -0x1c(%rbp), %rdi
callq 0x10520
movq -0x338(%rbp), %rcx
movl -0xc(%rbp), %eax
cmpl 0x220(%rcx), %eax
jne 0x11e5f
movq -0x338(%rbp), %rax
movslq -0xc(%rbp), %rcx
imulq $0x78, %rcx, %rcx
leaq 0x8(%rax,%rcx), %rdi
callq 0x6250
movl %eax, %ecx
movq -0x338(%rbp), %rax
movl %ecx, -0x20(%rbp)
movslq -0xc(%rbp), %rcx
movq 0x1e8(%rax,%rcx,8), %rdx
movq %rdx, -0x348(%rbp)
imulq $0x78, %rcx, %rcx
leaq 0x8(%rax,%rcx), %rcx
movq %rcx, -0x350(%rbp)
movq 0x218(%rax), %rax
movq %rax, -0x358(%rbp)
leaq -0x1c(%rbp), %rdi
callq 0x10ad0
movq -0x358(%rbp), %rdi
movl (%rax), %esi
callq 0x125f0
movq -0x350(%rbp), %rsi
movl %eax, -0xa4(%rbp)
leaq -0xa0(%rbp), %rdi
movq %rdi, -0x340(%rbp)
leaq -0x20(%rbp), %rdx
leaq -0xa4(%rbp), %rcx
callq 0x125b0
movq -0x348(%rbp), %rdi
movq -0x340(%rbp), %rsi
callq 0x6330
jmp 0x11df1
leaq -0xa0(%rbp), %rdi
callq 0x62f0
leaq -0x130(%rbp), %rdi
callq 0xe8a0
movq -0x338(%rbp), %rdi
addq $0x8, %rdi
movslq -0xc(%rbp), %rax
imulq $0x78, %rax, %rax
addq %rax, %rdi
leaq -0x130(%rbp), %rsi
callq 0xd230
leaq -0x130(%rbp), %rdi
callq 0x61d0
jmp 0x120c0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xb0(%rbp)
movl %eax, -0xb4(%rbp)
leaq -0xa0(%rbp), %rdi
callq 0x62f0
jmp 0x120db
movq -0x338(%rbp), %rcx
movl -0xc(%rbp), %eax
cmpl 0x224(%rcx), %eax
jne 0x11f86
movq -0x338(%rbp), %rax
movslq -0xc(%rbp), %rcx
movq 0x1e8(%rax,%rcx,8), %rdx
movq %rdx, -0x368(%rbp)
imulq $0x78, %rcx, %rcx
leaq 0x8(%rax,%rcx), %rcx
movq %rcx, -0x378(%rbp)
movq %rax, %rcx
addq $0x230, %rcx            # imm = 0x230
movq %rcx, -0x370(%rbp)
movq 0x218(%rax), %rax
movq %rax, -0x380(%rbp)
leaq -0x1c(%rbp), %rdi
callq 0x10b30
movq -0x380(%rbp), %rdi
movl (%rax), %esi
callq 0x125f0
movq -0x378(%rbp), %rsi
movq -0x370(%rbp), %rdx
movl %eax, -0x1b4(%rbp)
leaq -0x1b0(%rbp), %rdi
movq %rdi, -0x360(%rbp)
leaq -0x1b4(%rbp), %rcx
callq 0x125b0
movq -0x368(%rbp), %rdi
movq -0x360(%rbp), %rsi
callq 0x6330
jmp 0x11f18
leaq -0x1b0(%rbp), %rdi
callq 0x62f0
leaq -0x230(%rbp), %rdi
callq 0xe8a0
movq -0x338(%rbp), %rdi
addq $0x8, %rdi
movslq -0xc(%rbp), %rax
imulq $0x78, %rax, %rax
addq %rax, %rdi
leaq -0x230(%rbp), %rsi
callq 0xd230
leaq -0x230(%rbp), %rdi
callq 0x61d0
jmp 0x120be
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xb0(%rbp)
movl %eax, -0xb4(%rbp)
leaq -0x1b0(%rbp), %rdi
callq 0x62f0
jmp 0x120db
movq -0x338(%rbp), %rax
movslq -0xc(%rbp), %rcx
movq 0x1e8(%rax,%rcx,8), %rdx
movq %rdx, -0x390(%rbp)
imulq $0x78, %rcx, %rcx
leaq 0x8(%rax,%rcx), %rcx
movq %rcx, -0x398(%rbp)
movq 0x218(%rax), %rax
movq %rax, -0x3b0(%rbp)
leaq -0x1c(%rbp), %rdi
movq %rdi, -0x3a8(%rbp)
callq 0x10b30
movq -0x3b0(%rbp), %rdi
movl (%rax), %esi
callq 0x125f0
movq -0x3a8(%rbp), %rdi
movl %eax, %ecx
movq -0x338(%rbp), %rax
movl %ecx, -0x2b4(%rbp)
movq 0x218(%rax), %rax
movq %rax, -0x3a0(%rbp)
callq 0x10ad0
movq -0x3a0(%rbp), %rdi
movl (%rax), %esi
callq 0x125f0
movq -0x398(%rbp), %rsi
movl %eax, -0x2b8(%rbp)
leaq -0x2b0(%rbp), %rdi
movq %rdi, -0x388(%rbp)
leaq -0x2b4(%rbp), %rdx
leaq -0x2b8(%rbp), %rcx
callq 0x12610
movq -0x390(%rbp), %rdi
movq -0x388(%rbp), %rsi
callq 0x6330
jmp 0x12056
leaq -0x2b0(%rbp), %rdi
callq 0x62f0
leaq -0x330(%rbp), %rdi
callq 0xe8a0
movq -0x338(%rbp), %rdi
addq $0x8, %rdi
movslq -0xc(%rbp), %rax
imulq $0x78, %rax, %rax
addq %rax, %rdi
leaq -0x330(%rbp), %rsi
callq 0xd230
leaq -0x330(%rbp), %rdi
callq 0x61d0
jmp 0x120be
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xb0(%rbp)
movl %eax, -0xb4(%rbp)
leaq -0x2b0(%rbp), %rdi
callq 0x62f0
jmp 0x120db
jmp 0x120c0
jmp 0x120c2
jmp 0x120c4
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x11cc1
addq $0x3b0, %rsp            # imm = 0x3B0
popq %rbp
retq
movq -0xb0(%rbp), %rdi
callq 0x3480
nopw (%rax,%rax)