What type of instruction set is this? - binary

In a class I am currently taking (Operating Systems), we needed to convert hexadecimal to binary and then split the binary into it's respective parts to get the Opcodes and likewise.
Here is an example of the process
0x4B010000
01001011000000010000000000000000
0000000000000000 001011 0000 0001
0000 MOVI 1 0
0000 MOVI R1 0
0x4C060001
01001100000001100000000000000001
0000000000000001 001100 0000 0110
0001 ADDI 6 0
0001 ADDI R6 0
0x10658000
00010000011001011000000000000000
000000000000 010000 0110 0101 1000
0000 SLT 8 6 5
0000 SLT R8 R6 R5
0x56810018
01010110100000010000000000011000
0000000000011000 010110 1000 0001
0018 BNE 1 8
0018 BNE R1 8
I have provided the GitHub that contains the files stating the instruction set and the instruction format, plus all the data values.
https://github.com/DavidClifford-Pro/InstructionsFormat
The instructions say to decode it like I have, and then to execute it. I just don't understand the instructions and how it's supposed to be executed. I believe it's all been decoded correctly.
EDIT:
The the instruction list is part of the project (the first line - the hex codes), we were given these codes to decode and then execute.

Related

Is there any way of inicializing a variable with a binary value in MIPS?

I need to initialize an register with an specific decimal value in order to extract the bits of another register (by doing this). The only problem is, since I need to do an andoperation with a very large decimal, it turns out to be very difficult to convert a binary number into a decimal number without a calculator to perform this operation.
So I am interested to know if there is any way of initializing a register with a binary value directly
If your assembler/simulator does not allow you to write binary constants but it allows you to write hexadecimal ones then you may easily encode a binary number in hexadecimal.
Starting from the least significand bit, every 4 bits you encode its hexadecimal value using the following table:
0000 - 0
0001 - 1
0010 - 2
0011 - 3
0100 - 4
0101 - 5
0110 - 6
0111 - 7
1000 - 8
1001 - 9
1010 - A
1011 - B
1100 - C
1101 - D
1110 - E
1111 - F
If the original binary number does not have a multiple of 4 bits you fill the most significand bits to 0 until it fills the last packet.
For example, you may encode this words in hexadecimal converting them from binary numbers:
myvar: .word 0x1234 # binary 1 0010 0011 0100
other: .word 0xCAFEBABE # binary 1100 1010 1111 1110 1011 1010 1011 1110

Understanding hex representation of binary file

I need some help understanding the format of looking at a binary file in hex so I get get the correct numbers out of a table using python to parse it
Example:
0000b50: 0400 0000 ffff 0900 0000 ffff 0900 0000 ................
0000b60: ffff 0900 0000 ffff 0900 0000 ffff 0900 ............0..#
When I need to find the start of an object at index 0x0b54 where would that be? Would it be [here]? 0000b50: 0400 [0]000 ffff 0900 0000 ffff 0900 0000
The object is 96 bytes long. is one set of four hex numbers one byte? ie. ffff? or since it is base 16 each individual spot contains 2 bytes? so ffff is 8 bytes? And I need to find 6 bytes for each entry into the table which would be fff?
What does the part at the end represent? ie. ............0..#
f = 16 = 1111 so ff is 16x16 = 11111111 = 256 = one 8 bit byte.
ffff = 2 bytes.
You need to translate the numbers into binary to figure out the byte count.

Store the top half and low half of a 32 bit number

Is there a way to store the 16 leftmost bits, and the 16 rightmost bits of a binary number in MIPS?
For example, let's say I have the binary number: 1111 1111 1111 0000 0011 1111 0011 1100. Now, I want to store 1111 1111 1111 0000 in $t0 and the other half in $t1. Is there a way to do that? Thanks!

resulting sum in binary 16

I have answered the question but i could not understand the part where its says get the resulting sum in 16-bit binary, check your answer by converting the sum into decimal.
1.Add ‘A’ and ‘B’ in binary to get the resulting sum in 16-bit binary, check your answer by converting the sum into decimal.
Decimal number = 58927634
A= 5892 to Binary 1011 1000 0010 0
B= 7634 to Binary 1110 1110 1001 0
a + b = 11010011010110
thanks alot
Regards
Let me explain:
A = 00005892
B = 00007634
in base 10 number system, with 8 decimals to represent it.
and...
A = 0001 0111 0000 0100
B = 0001 1101 1101 0010
in base 2 number system, with 16 bits to represent it.
I hope it makes sense to you now.
And the sum of A and B, in base 2 number system with 16 bits to represent it....
0011 0100 1101 0110
although, we needed just 14 bits....
Your answer is correct, but its width is 14 bits long.

Help understanding Binary Representation for Integers?

I'm trying to understand these illustrations but there are parts which I don't understand:
"But the computer had to count backwards for the negative numbers"
Why does adding a 1 to the front of a binary mean the computer has to count backwards?
"Flip the bits and add 1!"
What does that mean add 1?
woops: http://csillustrated.berkeley.edu/PDFs/integer-representations.pdf
This may be easiest to show by example. Here are the numbers from -4 to 4 represented in binary:
4 0000 0100
3 0000 0011
2 0000 0010
1 0000 0001
0 0000 0000
-1 1111 1111
-2 1111 1110
-3 1111 1101
-4 1111 1100
So say we want to go from 1 to -1. We first flip all the bits of 1
1 0000 0001
flip bits
-----------
1111 1110
Then we add a 1:
1111 1110
+ 1
-----------
1111 1111
We now have -1.
I'm not seeing the illustrations, but you're probably talking about Two's complement representation. (http://en.wikipedia.org/wiki/Two's_complement)
Why does adding a 1 to the front mean the computer has to count backwards?
Due to how carrying works, FFFFFFFFF + 1 == 0
and 0 - 1 == FFFFFFFF. All the bits get flipped, including the first bit.
If you simply define the negative numbers as those starting with a 1 bit (80000000 - FFFFFFFF) then you get a nice uniform behavior for addition with a natural overflow.
Flip the bits and add 1: in 2's complement, this negates a number
~x+1 == -x; // always true
What you're talking about is called signed integers.