The MIPS architecture supports byte and halfword 16bit memor

The MIPS architecture supports byte and halfword (16-bit) memory transfer operations. The instructions are load byte (lb), load byte unsigned (lbu), store byte (sb), load halfword (lh), load halfword unsigned (lbu) and store halfword (sh). Code: char a, b;//8-bit variables (a @ address 100) (b @ address 200) Assuming 8-bit operations are supported (lb, lbu, sb), write a code that swaps the variables. If MIPS doesn\'t support byte and halfword operations, then we can only use \'load word\' (lw) and \'store word\' (sw), which are 32-bit operations. Accordingly, rewrite the code above using only (lw, sw) as memory transfer instructions.

Solution

Answer-


The purpose of memory is to store groups of bits, and deliver them (to the processor for loading into registers) upon demand. Most present-day computers store information in multiples of 8 bits, called a byte (or octet). Most also assign a numeric address to each byte. This is convenient because characters can be stored in bytes.
Memory addresses are 32-bit numbers, ranging from 0x00000000 to 0xFFFFFFFF. This is a large amount of memory, most computers do not have actual memory for all of this \"address space.\"
Memory can hold both program instructions and data. One function of the operating system is to assign blocks of
memory for the instructions and data of each process (running program). Another thing a good operating system does is to allow many processes to run concurrently on the computer.


        .text           #directive identifying the start of instructions
        .globl __start

__start:

# ------------- print prompt on \"console\" --------------------
        la      $a0, prompt     # address of prompt goes in
        li      $v0, 4          # service code for print string
        syscall

# ------------- read in the integer --------------------------
        li      $v0, 5          # service code
        syscall
        sw      $v0, Num1       # store what was entered
# -------------- read another
        li      $v0, 5          # service code
        syscall
        sw      $v0, Num2       # store what was entered

# ------ Perfrom the addition, $a0 := Num1 + Num2
        lw      $t0, Num1
        add     $a0, $t0, $v0

# ------ print the sum, it is in $a0
        li      $v0, 1          # print integer service call
        syscall

# ------ print a final string identifying the result, and ending with a new line
        la      $a0, final
        li      $v0, 4
        syscall

        li      $v0, 10         # exit program service
        syscall

#------------------------------------------------------------------
#       Data segment
#------------------------------------------------------------------
        .data
Num1:   .word   0
Num2:   .word   0
prompt: .ascii \"Please type 2 integers, end each with the \"
        .asciiz \"Enter key:\ \"
final: .asciiz \" is the sum.\ \"

#------ end of file ADDNUMs.ASM

The SPIM simulator always assigns your program to these fixed, even numbered locations, for your convenience:

    0x00400000 - Text segment - program instructions
    0x10000000 - Data segment
    0x7FFFFFFF, and decreasing addresses - Stack segment

A word generally means the number of bits that can be transferred at one time on the data bus, and stored in a register. In the case of MIPS, a word is 32 bits, that is, 4 bytes.
Words are always stored in consecutive bytes, starting with an address that is divisible by 4. Caution: other processors, other definitions.
Some people refer to 16 bits as a word, to others it may mean 64 bits.

 The MIPS architecture supports byte and halfword (16-bit) memory transfer operations. The instructions are load byte (lb), load byte unsigned (lbu), store byte
 The MIPS architecture supports byte and halfword (16-bit) memory transfer operations. The instructions are load byte (lb), load byte unsigned (lbu), store byte

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site