Lab #3 Report Procedure
Lab #3 Report Procedure
INFO 102
Sarora12
Lab Section- AB3
Lab #3 Report
Procedure:
In this lab, we used a x86 assembly language simulator called Asm86 which runs in a
web browser. First, we started exploring the simulator itself and brought up the register window.
There were 4 general purpose registers in x86, EAX, EBX, ECX, and EDX. All of these started
off with having the value 0x0. Another register, EIP, was the instruction pointer register. After
exploring these we started off by typing a couple x86 instructions into the editor and then clicked
run. First we typed the mov instruction which moves the value to the right into the register on the
left. Then we did the add instruction which adds the value on the right to the register on the left.
We only stored a single 32-bit value, we named it Memory with 4-bytes and the initial value set
to 0. This was able to add the space for a single 32-bit value at the memory address 0x400 with
the initial value of 0x0. Then we copy and pasted the code from the first.s file into the emulator.
Then we pressed run and step to see how it would change. I could see the sub and xor
instructions were performing subtraction and xor operations. The interesting part was the
brackets [ and ], they making the value surrounded by the brackets to be interpreted as a memory
address. We could use those brackets with the mov instruction in order to retrieve or store values
at that memory address. After completing this, we changed the first program by adding the
instruction given to us in the lab instruction (we added jmp). Once we got a hold of this we then
moved on to copy the code from the file fibbing.s into the simulator. This contained the out x86
instruction, which allowed the output value stored in a register to the I/O bus. In our simulator
the device connected to 0xE2 was a series of light bulbs and I saw them by opening the
Hardware window. I stepped through the program and saw the light bulbs flash in a certain
pattern.
Results:
At the end of this lab, I observed that one of our results were the light bulbs that were
created at the end and how they were flashing in a certain pattern while we ran the program and
stepped through the written instructions. I also later realized that the pattern the light bulbs were
flashing in was actually the fibonacci sequence. Moreover, I also learned about the x86 assembly
language simulator and was able to play around with the program. We were able to copy
different files of codes into the emulator and observe the different operations that were
happening by running through them step by step. This allowed us to get familiar with the
program itself while also running some of the codes and understanding their operations.
Furthermore, I observed that each of the steps ran some kind of operation and this ultimately
showed in the final file we put into the simulator, which was fibbing.s, created the lights flashing
in the fibonacci sequence. Below I have attached pictures from my lab of the different programs
we ran and the steps we took, as well as the ultimate outcome which was the light bulbs flashing
The word size of the processor is 4 and the register can hold 32 bits. The memory addresses are
also 32 bits.
2. Where is the first instruction of our programs stored in memory? How do you know this?
The first instruction of our programs is stored in the EIP register and we know this because it is
the only register in which the value changed after the first instruction. Moreover, the EIP register
The flag values at the end of part A, B, and C of the first program are sign, overflow, zero, and
carry. The sign flag shows that the operation produced a negative value. The overflow flag
shows the sign integer overflow. The the zero flag shows the outcome of the operation which is
zero. The carry flag shows the unsigned integer overflow. All of these flags indicate that the
The instructions in part D of our first program start off with shifting the value of EAX register to
equal 00000005. Then we move the value of the EBX register for it to equal 00000002. After
this it performed the bitwise XOR operation to both EBX and EAX. This places the result of this
XOR operation into the EAX register. When comparing the numbers, 00000101 and 00000010 it
5. After our first program finished running, what value ended up in memory address 0x400?
After our first program finished running the ECX register transferred to the 0x400 memory
address. It got there because line 4 of part E utilizes the mov operation to move the address to the
6. When our first program finishes running, why does it complain about an “Invalid instruction
address”?
After our first program finishes running it complains about an “invalid instruction address”
In our first program, the jmp instruction allows us to repeat that block of code that the program
tells it to jump into. This causes the instruction to be performed again created a kind of loop.
8. What does the program fibbing.s do? What is the role of register edx and the jnz instruction?
The program fibbing.s activates the light bulbs depending on what the values are in the EAX
register. The role of the EDX register is that it’s the conditional register that the JNZ statement is
evaluating. As long as the EDX register is not zero then the loop will continue to run in the
program. To clarify JNZ means jump if not zero, so the program will keep going in a loop if the
EDX loop is also not zero. The pattern of the lights flashing is in the fibonacci sequence.
Conclusions:
After completing this lab and analyzing the results, I was able to gain a much deeper
understanding of the concept of assembly languages and how a x86 assembly language simulator
works. Through this lab we were able to get hands on experience by running through the process
of creating our first assembly program. Moreover, we were able to copy more complex codes
into the simulator and see them step by step run through the operations. More specifically in
lecture we briefly discussed a x86 assembly language simulator and reviewed a few of the
operations that we used in the lab as well, such as, mov. The lab allowed us to clarify the
concepts we learned in lecture and explore them further. Doing this lab activity also further
reinforced the concepts of how registers and memory addresses worked, which is another subject
topic we covered in our course material and lecture. Overall, I really enjoyed this lab and was
fascinated to see how the codes worked in the x86 assembly language simulator. My favorite part
was in the end where after copying the coding file fibbing.s we were able to open the Hardware
window and step through the program to see the light bulbs flashing in a fibonacci sequence.
Ultimately, this lab activity cleared up a lot of the lecture concepts for me and it was very