Skip to content

Instantly share code, notes, and snippets.

@razielgn
Created June 25, 2011 16:39
Show Gist options
  • Save razielgn/1046644 to your computer and use it in GitHub Desktop.
Save razielgn/1046644 to your computer and use it in GitHub Desktop.

Istruzioni: linguaggio macchina

Formato istruzioni

  • op (6 bits) = operation code
  • rs (5 bits) = source register
  • rt (5 bits) = other source register
  • rd (5 bits) = destination register

R

000000 00000 00000 00000 00000 0000000
  op    rs    rt    rd   shamt  funct
  • shamt (5 bits) = shift amount (usato dalle istr di shift)
  • funct (6 bits) = additional opcode (per differ. le istr. sull'ALU [add, sll, ..] che hanno lo stesso opcode)

I

000000 00000 00000 0000000000000000
  op    rs    rt   offset/immediate
  • off/imm (16 bits) = immediate value / address offset

J

000000 0000000000000000000000000
  op         jump address
  • jmp addr (26 bits)

Grandi costanti

lui $t0, 1010101010101010
ori $t0, $t0, 1010101010101010

Indirizzamento

  • Register addressing

    operando = registro

  • Base addressing

    operando = cost($reg)

  • Immediate addressing

    operando = costante

  • PC relative addressing

    operando = PC + cost

  • Pseudodirect addressing

    operando = 4 bit PC + 26 istr.

Aritmetica del calcolatore

Operazioni logiche complesse

  • EXOR ⊕

    !x · y + x · !y

  • NOR

    !(x + y)

IEEE 754

  0     00000000     0000000000000000000000
segno  exp(8 bits)       mantissa (23 bits)

decimale = segno * 2^(exp - 127) * mantissa

mantissa = (1 + bit[22] * 1/2 + bit[21] * 1/4 + ... + bit[0] * 1/8388608)

Unità di controllo

Funzioni ALU

ALU control lines        function
       000                 and
       001                 or
       010                 add
       110               subtract
       111            set-on-less-than

Bit dei sorgenti ALU

  • 00: addition (load & store word)
  • 01: subtraction (branch on equal)
  • 10: operazioni a seconda del valore nel campo funct (istruzioni di tipo R)

Linee di controllo ALU

  • RegDest

    Sorgente del registro di dest. per l'operazioni

  • RegWrite

    Abilita la scrittura di un registro

  • ALUsrc

    Sorgente del secondo operatore nell'ALU, può essere un registro o parte dell'istruzione (tipo una costante)

  • PCsrc

    Sorgente del PC (se è un incremento normale o è risultato di un jump/branch)

  • MemRead/MemWrite

    Lettura/Scrittura dalla memoria

  • MemtoReg

    Sorgente dei contenuti da scrivere nel registro

Istruzione Jump

  • OP: 2
  • I 2 bit meno significativi sono sempre 0
  • Immediate field: bits 2-27
  • Current PC: bits 28-31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment