// File: /workspace/github_cpp_makefile_star2_O1/QFSW[P]MIPS1-Simulator/src/MemoryMap.hpp
// Function: void Clarkitechture::MIPS::MemoryMap::write<unsigned short>(unsigned long, unsigned short)
void write(size_t address, T data)
            {
                if (address % sizeof(T) > 0) { throw BadMemoryAccess(address, "write data address was misaligned"); }
                else if (address >= ADDR_PUTC && address < ADDR_PUTC + 4)
                {
                    T val = address == ADDR_PUTC + 4 - sizeof(T) ? data : 0;
                    int ret = std::putchar(val);
                    if (ret == EOF)
                    {
                        int error = ferror(stdin);
                        if (error) { throw BadIO("stdout", error); }
                    }
                }
                else if (address >= ADDR_DATA && address < ADDR_DATA + ADDR_DATA_LENGTH)
                {
                    size_t memLocation = address - ADDR_DATA;
                    for (int i = 0; i < sizeof(T); i++)
                    {
                        int shamt = 8 * (sizeof(T) - i - 1);
                        memory[memLocation + i] = data >> shamt;
                    } 
                }
                else { throw BadMemoryAccess(address, "address was outside of the valid R/W memory range."); }
            }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rsi, %r14
testb $0x1, %r14b
jne 0x8d64
movq %r14, %rax
andq $-0x4, %rax
cmpq $0x30000004, %rax       # imm = 0x30000004
jne 0x8d05
xorl %eax, %eax
cmpq $0x30000006, %r14       # imm = 0x30000006
movzwl %dx, %edi
cmovnel %eax, %edi
callq 0x62e0
cmpl $-0x1, %eax
jne 0x8d55
movq 0x9334(%rip), %rax      # 0x11fc8
movq (%rax), %rdi
callq 0x63e0
testl %eax, %eax
je 0x8d55
movl %eax, %ebp
movl $0x50, %edi
callq 0x6100
movq %rax, %rbx
leaq 0x38(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x3798(%rip), %rsi      # 0xc45c
leaq 0x3797(%rip), %rdx      # 0xc462
leaq 0x28(%rsp), %rdi
callq 0x8e9a
movb $0x1, %r15b
leaq 0x28(%rsp), %rsi
movq %rbx, %rdi
movl %ebp, %edx
callq 0x6ef2
xorl %r15d, %r15d
leaq 0x80bf(%rip), %rsi      # 0x10db0
leaq -0x1494(%rip), %rdx     # 0x7864
movq %rbx, %rdi
callq 0x6380
jmp 0x8e18
movq %r14, %rax
andq $-0x4000000, %rax       # imm = 0xFC000000
cmpq $0x20000000, %rax       # imm = 0x20000000
jne 0x8dbf
movq %rdi, %rbx
movzwl %dx, %r12d
addl $0xe0000000, %r14d      # imm = 0xE0000000
movl $0x8, %ebp
leaq 0x4(%rsp), %r15
movl %r12d, %r13d
movl %ebp, %ecx
shrl %cl, %r13d
movl %r14d, 0x4(%rsp)
movq %rbx, %rdi
movq %r15, %rsi
callq 0x8f2a
movb %r13b, (%rax)
incl %r14d
addl $-0x8, %ebp
je 0x8d32
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x50, %edi
callq 0x6100
movq %rax, %rbx
leaq 0x58(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x36b9(%rip), %rsi      # 0xc43a
leaq 0x36d3(%rip), %rdx      # 0xc45b
leaq 0x48(%rsp), %rdi
callq 0x8e9a
movb $0x1, %bpl
leaq 0x48(%rsp), %rdx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x68ea
xorl %ebp, %ebp
leaq 0x7fba(%rip), %rsi      # 0x10d68
leaq -0x1761(%rip), %rdx     # 0x7654
movq %rbx, %rdi
callq 0x6380
jmp 0x8e18
movl $0x50, %edi
callq 0x6100
movq %rax, %rbx
leaq 0x18(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x362b(%rip), %rsi      # 0xc407
leaq 0x3656(%rip), %rdx      # 0xc439
leaq 0x8(%rsp), %rdi
callq 0x8e9a
movb $0x1, %bpl
leaq 0x8(%rsp), %rdx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x68ea
xorl %ebp, %ebp
leaq 0x7f5f(%rip), %rsi      # 0x10d68
leaq -0x17bc(%rip), %rdx     # 0x7654
movq %rbx, %rdi
callq 0x6380
movq %rax, %r14
movq 0x28(%rsp), %rdi
cmpq %r12, %rdi
je 0x8e3a
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x6210
jmp 0x8e3a
movq %rax, %r14
movb $0x1, %r15b
testb %r15b, %r15b
jne 0x8e7e
jmp 0x8e86
movq %rax, %r14
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
je 0x8e79
movq 0x18(%rsp), %rsi
jmp 0x8e69
jmp 0x8e73
movq %rax, %r14
movq 0x48(%rsp), %rdi
cmpq %r15, %rdi
je 0x8e79
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x6210
jmp 0x8e79
movq %rax, %r14
movb $0x1, %bpl
testb %bpl, %bpl
je 0x8e86
movq %rbx, %rdi
callq 0x6190
movq %r14, %rdi
callq 0x63a0