Assignment 6 - CS1104

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

Assignment 6 Part 1

For the Assembly code, we can convert it to binary by understanding the instruction type.
Whether it’s a type A or a type C. Depending on the code format as its broken down with the most
significant bit which indicate the type of an instruction. If a binary value starts with a zero, than this is an
A-Address code, however if it starts with 1, than this is a C-instruction. Regarding the breakdown of a C-
instruction, as given the values of a, c, d, j. Each can tell us what the CPU will do to the next instruction
and how the control bits control the ALU

@0 0000000000000000, This is an A-Instruction for a constant 0

D=A 1110110000010000, This a C-instruction, which use arth a=0, the des is D=010 and A=110000

@3 0000000000000011, This is an A-Instruction for a constant 3

D=D+A 1110000010010000, This a C-instruction, which use arth a=0, the des is D=010 and D+A=000010

@0 0000000000000000, This is an A-Instruction for a constant 0

M=D 1110001100001000, This a C-instruction, which use arth a=0, the des is M=001 and D=001100
Part 2

@0 0000000000000000, This is an A-Instruction for a constant 0

D=M 1111110000010000, This a C-instruction, which use arth a=1, the des is D=010 and M=110000

@1 0000000000000001, This is an A-Instruction for a constant 1

D=D-M 1111010011010000, This a C-instruction, which use arth a=1, the des is D=010 and D-M =010011

@10 0000000000001010, This is an A-Instruction for a constant 10

D;JGT 1110001100000001, This a C-instruction, which use arth a=0, the des is null=000 and JGT=D
=001100 and a jump of 001

@1 0000000000000001, This is an A-Instruction for a constant 1

D=M 1111110000010000, This a C-instruction, which use arth a=1, the des is D=010 and M=110000

@12 0000000000001100, This is an A-Instruction for a constant 12

0;JMP 1110101010000111, This a C-instruction, which use arth a=0, the des is null=000 and JMP=0
=101010 and a jump of 111

@0 0000000000000000, This is an A-Instruction for a constant 0

D=M 1111110000010000, This a C-instruction, which use arth a=1, the des is D=010 and M=110000

@2 0000000000000010, This is an A-Instruction for a constant 2

M=D 1110001100001000, This a C-instruction, which use arth a=0, the des is M=001 and D=001100

@14 0000000000001110, This is an A-Instruction for a constant 14

0;JMP 1110101010000111, This a C-instruction, which use arth a=0, the des is null=000 and JMP=0
=101010 and a jump of 111

You might also like