Professional Documents
Culture Documents
Lab-Project 13 - Jasmin
Lab-Project 13 - Jasmin
Purpose
1. To practice writing and running basic x86 assembly code, using the Jasmin (Java
Assembler Interpreter).
Installing Java
14. The program runs. When it stops, notice these things, as shown below:
EAX contains 4
EBX contains 6
EIP contains 2, because instructions 0 and 1 have been executed
In the Code area, instruction 2 is highlighted in green, indicating that it is the next
instruction to be processed.
mov eax, 4
17. Run the program. When it completes, you should see these results, as shown
below:
EAX = 4
EBX = 6
ECX = 10
Memory location 0x4 contains 6
Memory location 0x8 contains 10
Reversing a Sequence
29. In Jasmin, click File, New.
30. In the Code section, type in these instructions:
mov eax, 1
mov ebx, 2
mov ecx, 3
mov edx, 4
push eax
push ebx
push ecx
push edx
pop eax
pop ebx
pop ecx
pop edx
31. These instructions load values into the four registers, push them onto the stack in
order, and pop them off the stack in order.
32. However, since the stack is a FILO (First In, Last Out) structure, this reverses the
order of the values.
33. Push the Step four times to execute only the first four instructions, as shown
below:
34. You see the values 1, 2, 3, and 4 loaded into the EAX, EBX, ECX, and EDX
registers, as shown below.
35. Push the Step four more times to execute the remaining four instructions.
36. Now the registers contain these values:
EAX = 4
EBX = 3
ECX = 2
EDX = 1
Find the Value
37. In Jasmin, click File, New.
38. In the Code section, type in the following instructions.
mov eax, 1
mov ebx, 9
mov ecx, 49
push eax
push ebx
push eax
push ecx
push ebx
push eax
pop eax
pop ebx
pop ecx
add eax, ebx
pop ecx
add eax, ecx
pop ebx
pop ecx
add eax, ebx
39. Run this program.
40. Find the value of eax covered by a green box in the image below.
Saving a screen image
41. Make sure the value is visible.
42. Save the image with the filename Lab-Proj13a-YOURNAME.png. Use your real
name, not the literal text YOURNAME.
Secret Message 1
43. Download this code and run it in Jasmin.
44. In the bottom-center pane of Jasmin, click Console to see the output. The
message is mostly X characters, as shown at the bottom of the image below.
45. Try to find the message in the Console.
Saving a screen image
46. Make sure the secret message is visible.
47. Save the image with the filename Lab-Proj13b-YOURNAME.png. Use your real
name, not the literal text YOURNAME.
Secret Message 2
48. Download this code and run it in Jasmin.
49. In the top center of the Jasmin window, click the leftmost green arrow to run the
code.
50. In the bottom-center pane of Jasmin, click Console to see the output. The console
is empty, as shown below.
51. Figure out how to make the message visible.
Saving a screen image
52. Make sure the secret message is visible.
53. Save the image with the filename Lab-Proj13c-YOURNAME.png. Use your real
name, not the literal text YOURNAME.