CS1104 Written Assignment unit6 PDF

Title CS1104 Written Assignment unit6
Course Computer Systems
Institution University of the People
Pages 7
File Size 278.4 KB
File Type PDF
Total Downloads 21
Total Views 117

Summary

CS1104 Written Assignment unit6...


Description

Written Assignment Unit 6 *If you have trouble viewing instructions/images below, please refer to the "Assignment" chapter in Unit 6's Learning Guide For the Unit 6 assignment, hand compile the following two assembly language programs into machine language that can be loaded into an executed on the Hack computer. Chapter 4 of the Nisan and Schocken text describes the machine language instructions that are supported by the Hack computer system. It is important to understand that different computer architectures will support different capabilities and of course this translates into differences in both the machine language instructions of the computer and the assembler language that supports the system. In the Hack computer platform, there are essentially two types of machine language instructions the A instruction (see below)

And the C instruction as follows. ALL Hack computer programs can be developed using these two instructions.

The C instruction allows the programmer to interact with the CPU(and in particular the ALU) to perform computations against the values in the registers. If you recall, in Unit 2 we presented the ALU for the Hack computer as follows:

Each of the instructions that the Hack ALU is capable of running can be specified to the ALU through a set of control bits. These control bits or the C bits in the instruction and their associated functions are listed below.

IT IS IMPORTANT TO COMPLETE THIS EXERCISE. I caution you not to take any shortcuts. The best way to really gain an understanding of how machine language and assembler language works is by learning how to convert assembler into machine language. We will gain an understanding of the relationship between hardware and software in this process. As such I urge you to NOT be tempted to cheat and use a compiler for this task. Once you have been able to translate each of the following two programs written in Hack Assembler into binary machine code, Load your machine language program into the cpu simulator and execute it. For your assignment post a description of YOUR process to convert the assembler symbols into machine language and what you learned in the process. Also include both your assembler program and corresponding machine language program in your assignment. //Program 1 to convert to machine language // Computes R0 = 2 + 3 @2 D=A @3 D=D+A @0 M=D

// Program 2 to convert to machine language // Symbol-less version of the Max.asm program. @0 D=M @1 D=D-M @10 D;JGT @1 D=M @12 0;JMP @0 D=M @2 M=D @14 0;JMP

Program 1 Assignment 6 Assembly language @2 D=A @3 D=D+A @0 M=D

Machine Language translation 0000000000000010 1110110000010000 0000000000000011 1110000010010000 0000000000000000 1110001100001000

Program 2 Assignment 6 @0

D=M @1 D=D-M @10 D;JGT @1 D=M @12 0;JMP @0 D=M @2 M=D @14 0;JMP

The Machine language translation 0000000000000000 1111110000010000

0000000000000001 1111010011010000 0000000000001010 1110001100000001 0000000000000001 1111110000010000 0000000000001100 1110101010000111 0000000000000000 1111110000010000 0000000000000010 1110001100001000 0000000000001110 1110101010000111

Translation Process To manually translate assembly language into machine language there is a set of guidelines that need to be followed. The @ sign implies that a value is to be loaded into the 16-bit A-register. For example @2 will load the value 2 (binary 10) into the A-register which will result in the address 0000000000000010. When the instruction does not begin with the @ sign then the instruction is a C-instruction. The C-instruction is made of several parts (computation, destination and jump) which are modified based on the instruction. For example, the C-instruction D=D+M means to load the D-register (Data register) the resulting value of whatever is in the D-register plus the content of the M-register (memory register). This assembly code will translate into 111 0000010 010000. The computation bits are the ones highlighted (4 -10 ). th

th

The three bits following the computation bits are the destination bits which indicate the register location to load the value. In the above example (010) will send the value of 2 into the D-register. The final three bits are the Jump bits which indicate whether the code will be jumping somewhere in code or proceed normally. Example of a jump instruction is JGT which it will translate into 001 (the final three bits of the C- instruction)....


Similar Free PDFs