Pages

Friday, 21 November 2014

LANGUAGES OF THE COMPUTER 2 PART 1 (DECODING MACHINE LANGUAGE)

Decoding Machine Language

-----> six machine language instructions in hexadecimal:
     00001025hex   

  0005402Ahex
                                                         
  11000003hex
                                                
  00441020hex

  20A5FFFFhex 

  08100001hex
1.Firstly we must  convert hex to binary

00001025hex   = 00000000000000000001000000100101
0005402Ahex  =   00000000000001010100000000101010
11000003hex    =  00010001000000000000000000000011 
00441020hex  =   00000000010001000001000000100000
20A5FFFFhex  = 00100000101001011111111111111111
08100001hex  =   00001000000100000000000000000001

2.Ok,after tahat we identify the  opcode and format


*** Here some tips to identify which format should we use ( ^ _ ^ )


 Look at opcode:

  ***which is first 6 bits  of the binary number

[ 000000] 00000000000001000000100101

[ 000000] 00000001010100000000101010

[ 000100] 01000000000000000000000011

[ 000000] 00010001000001000000100000

[ 001000] 00101001011111111111111111 

[ 000010] 00000100000000000000000001

 0   ------> R-Format

2 or 3 ------> J-Format

 otherwise------>  I-Format


0
rs
rt
rd
shamt
funct
    1,4-31
rs
rt
immediate
2 or 3
Target address
op = 6 bits
rs  = 5bits
rd = 5bits
shamt = 5 bits
funct = 6 bits
immediate = 16 bits
address = 26 bits

Ok , got it?Lets continue the next step!!!!

3.Translate  to MIPS assembly instructions.
        or $v0 , $0 , $0
loop :  $v0 , $0 ,$a1
         beq $t0  , $0 , Exit
         add $v0  ,$v0  , $a0
         addi $a1 , $a1 , -1
          j Loop
Exit




Ok done!!
post by; Nursyahirah Syafiqah binti Baharim

No comments:

Post a Comment