Inserting and Running Your Code

To run code that you have written for the x86-64 processor, you must run the simulator with the provided bsd file, snippet.bsd, located in the /usr/local/share/simnow/images/ directory. Then, you must manually insert that code in the file start64.ram. This file can also can be found in the images/ directory. The first part of this file contains code that sets up the processor to run in 64 bit mode, but starting at position AD in the file, you can insert instructions to be run on the processor. Currently, the following instructions are in start64.ram. These 6 instructions calculate the Fibonacci numbers in the 64 bit register, AX:
mov rax, 0000000000000001h ; initialize AX (64 bits)
mov rbx, 0000000000000000h ; initialize BX (64 bits)
mov ecx, eax ; Save off AX
add rax, rbx ; Calculate next Fibonacci number
mov ebx, ecx ; Move old Fib into BX
jmp $-07h ; Jump back to continue algorithm
When you change this code, be sure to leave the last 4 bytes as they are:
33 C0 F1 F4
Once you're finished editing start64.ram, run SimNow and set a breakpoint at the address AD. The breakpoint dialog box to do this is shown below.

Note that you need to uncheck the "Use segment portion of address" check box.

Once you have the breakpoint set, you can click "Start" on the SimNow main window. Returning to the "Core" tab on the debugger, you'll see the instruction at AD listed first. You can then "Single Step" through your instructions, observing the values of the registers to verify the correctness of your code. Below are pictures of the SimNow main window and the "Core" tab of the debugger right before execution of the instruction at AD.