Double-click the Jasmin-1.5.8.jar file you downloaded.双击下载的Jasmin-1.5.8.jar文件。
Jasmin launches, with a cringe-worthy pinup on it.茉莉发布了一个令人生畏的海报。
Click the " New File " button.点击“ 新建文件 ”按钮。
Look over the window, referring to the diagram below:查看窗口,参考下图:
Find and examine these sections:查找并检查这些部分:
The ESP (Extended Stack Pointer) contains the address of the top of the Stack. ESP (扩展堆栈指针)包含堆栈顶部的地址。
The EIP (Extended Instruction Pointer) contains the address of the the next instruction to be processed. EIP (扩展指令指针)包含要处理的下一条指令的地址。
With the Memory pane scrolled to the top, as shown in the image above, you see memory that the program will use to store data during processing.当Memory窗格滚动到顶部时,如上图所示,您会看到程序在处理过程中将用于存储数据的内存。
Scroll this pane to the bottom to see the Stack, which starts at address 0x1000 and grows downward.将此窗格滚动到底部可查看从地址0x1000开始并向下增长的堆栈。
These instructions move the number 4 into eax, and the number 6 into ebx.这些指令将数字4移入eax,数字6移入ebx。mov eax, 4 mov eax,4 mov ebx, 6 mov ebx,6
At the top of the Jasmin window, click the green Run button, as shown below.在Jasmin窗口的顶部,点击绿色的运行按钮,如下所示。
The program runs.程序运行。 When it stops, notice these things, as shown below:当它停止时,注意这些事情,如下所示:
Troubleshooting故障排除
If you make an error in an instruction, the program will stop prematurely.如果在指令中发生错误,程序将提前停止。 Fix the instruction, and click the Reset button.修复指令,然后单击重置按钮。 Then you can run it again.然后你可以再次运行它。
Here's what these instructions do:以下是这些说明的作用:mov eax, 4 mov eax,4 mov ebx, 6 mov ebx,6 mov [eax], ebx mov [eax],ebx mov ecx, eax mov ecx,eax add ecx, ebx添加ecx,ebx mov [eax+4], ecx mov [eax + 4],ecx
Run the program.运行该程序。 When it completes, you should see these results, as shown below:完成后,您应该看到这些结果,如下所示:
mov eax, 4
Move the value 4 into eax将值4移至eax mov ebx, 6
Move the value 6 into ebx将值6移至ebx mov [eax], ebx
Move the value in ebx (which is 6) into the memory location pointed to by eax (memory location 4)将ebx中的值(即6)移入由eax指向的内存位置(内存位置4) mov ecx, eax
Move the value in eax (which is 4) into ecx将eax中的值(它是4)移到ecx中 add ecx, ebx
Add the value in ebx (which is 6) to the value in ecx (which is 4), and put the result into ecx (the result is 10)将ebx中的值(它是6)添加到ecx(它是4)中的值,并将结果放入ecx(结果为10) mov [eax+4], ecx
Move the value in ecx (which is 10) into the memory location four past the location pointed to by eax (memory location 8)将ecx中的值(10)移到eax指向的位置(内存位置8)之后的四个存储单元中,
In the Code section, type in these instructions.在代码部分,输入这些说明。
Before running the program, notice the ESP: it contains 4096, as shown below.在运行程序之前,请注意ESP:它包含4096,如下所示。mov eax, 4 mov eax,4 mov ebx, 6 mov ebx,6 push eax推eax push ebx推ebx
4096 is 0x1000 in hexadecimal--this is where the Stack ends. 4096是十六进制的0x1000 - 这是堆栈结束的地方。
Scroll down in the Memory pane to see the last values.在“内存”窗格中向下滚动以查看最后的值。 As show above, the last location is at 0xFFC.如上所示,最后一个位置是0xFFC。 This value is 32 bits long, so it contains four bytes, at locations 0xFFC, 0xFFD, 0xFFE, and 0xFFF.该值为32位长,因此它包含4个字节,位置为0xFFC,0xFFD,0xFFE和0xFFF。 The ESP points to the next byte, 0x1000. ESP指向下一个字节0x1000。
These instructions move the number 4 into eax, and the number 6 into ebx.这些指令将数字4移入eax,数字6移入ebx。 Then both values are pushed onto the stack.然后将这两个值推入堆栈。
Notice these things, as shown below:注意这些事情,如下所示:
Run the code.运行代码。mov eax, 4 mov eax,4 mov ebx, 6 mov ebx,6 push eax推eax push ebx推ebx pop ecx pop ecx
Notice these things, as shown below:注意这些事情,如下所示:
In the Code section, type in these instructions.在代码部分,输入这些说明。
These instructions load values into the four registers, push them onto the stack in order, and pop them off the stack in order.这些指令将值加载到四个寄存器中,按顺序将它们推入堆栈,然后按顺序将它们从堆栈中弹出。mov eax, 1 mov eax,1 mov ebx, 2 mov ebx,2 mov ecx, 3 mov ecx,3 mov edx, 4 mov edx,4 push eax推eax push ebx推ebx push ecx推ecx push edx推edx pop eax流行eax pop ebx流行ebx pop ecx pop ecx pop edx流行edx
However, since the stack is a FILO (First In, Last Out) structure, this reverses the order of the values.但是,由于堆栈是一个FILO(先入先出)结构,这会颠倒这些值的顺序。
Push the Step four times to execute only the first four instructions, as shown below:按下这个步骤四次只执行前四条指令,如下所示:
You see the values 1, 2, 3, and 4 loaded into the EAX, EBX, ECX, and EDX registers, as shown below.您可以看到EAX,EBX,ECX和EDX寄存器中加载的值1,2,3和4,如下所示。
Push the Step four more times to execute only the next four instructions.再推四步 ,只执行下四条指令。
You see the values 1, 2, 3, and 4 pushed onto the stack, as shown below.您会看到将值1,2,3,和4推入堆栈,如下所示。
Push the Step four more times to execute the remaining four instructions.再推四步执行其余四条指令。
Now the registers contain these values:现在寄存器包含这些值: