Question: Unit Tests. For this task we will be practicing assembly language programming using the Simple Instruction Architecture. Simple Instruction Architecture Built a set of unit
Unit Tests.
For this task we will be practicing assembly language programming using the Simple Instruction Architecture. Simple Instruction Architecture Built a set of unit tests to ensure that our assembler and virtual machine function correctly. Build an understanding of how assembly language instructions are mapped into machine language.
Definition: Unit testing is a software development process in which the smallest testable parts of an application, called units, are individually and independently scrutinized for proper operation. A complete unit test would consist of a few items: Assembly language code to complete some task. This task may be useful (for example, converting meters to feet) or arbitrary (for example, adding two numbers and subtracting the sum from the second number and ensuring that you get the first number). The machine language (hand assembled) representation of the assembly language code.
The expected result from running the code. For our unit tests let's make a few assumptions: All registers start at zero. All code begins in instruction zero. Interrupt 0 prints all of the registers. Interrupt 1 prints all of memory. Generally when creating a unit test it is better to introduce as few dependencies as possible. By testing as small of a chunk as possible we can be confident we know where the bug is when the unit test fails. if we unit test the entire assembler or the entire virtual machine by using a single long assembly language program, if there is an issue it will be hard to track down. It can be difficult, however, to do this with assembly language - sometimes we need to use more than one instruction. Let's consider an example: Our test: We want to test to make sure that AND works. Our assembly lanuage snippet: addimmediate r1 10 addimmediate r2 8 and r1 r2 r3 interrupt 0 We use the addimmediate instructions to populate r1 and r2 with values.We then execute the instruction that we are trying to test (and).Finally, interrupt 0 prints out the registers. Hand assembling: addimmediate r1 10 ( 91 0A ) addimmediate r2 8 (92 08) and r1 r2 r3 (21 23) interrupt 0 (8000) Our expected values: R1 == 10 R2 == 8 R3 == 8 (10 == 0000 0000 0000 1010, 8 == 0000 0000 0000 1000) so the and of those is 8
---------------------------------------------------------------------------------------------
set of unit tests in a format like this:
addimmediate r1 10 ( 91 0A )
addimmediate r2 8 (92 08) and
r1 r2 r3 (21 23) interrupt 0 (8000) R1 == 10 R2 == 8 R3 == 8
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
