CSE 230 solution to assignments

CSE 230 solution to assignments - ICS 233, Term 072...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
ICS 233, Term 072 Computer Architecture & Assembly Language HW# 2 Solution Q.1. Carry out resulting from addition of unsigned numbers can be used to check if the result of addition is incorrect. Write the shortest sequence of MIPS instructions to determine if there is a carry out from the addition of two registers $t1 and $t2. Place the carry out (0 or 1) in register $t0. When adding two numbers and there is a carryout this implies that the result must be smaller than each of the added operands. Thus, we can use the following sequence of instructions to check that we have a carry out: add $t0, $t1, $t2 sltu $t0, $t0, $t1 Q.2. Write a MIPS assembly program that asks the user to enter an integer, reads the integer and then displays the integer representation in both binary and hexadecimal, assuming 32-bit representation. A sample execution of the program is given below: Enter an integer: -5 Number representation in binary is: 11111111111111111111111111111011 Number representation in hexadecimal is: FFFFFFFB .DATA prompt: .asciiz "\n Enter an integer:" msg1: .asciiz "\n Number representation in binary is:" msg2: .asciiz "\n Number representation in hexadecimal is:" table: .asciiz "0123456789ABCDEF" .TEXT .GLOBL main main: li $t3, 32 # Printing prompt message to read an integer li $v0, 4 # system call code for print string la $a0, prompt # loads address of prompt into $a0 syscall # print the prompt message # Reading the integer. Read integer is stored $v0 li $v0, 5 # system call code for read integer
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 02/02/2010 for the course COMPUTER cse 230 taught by Professor Kevinburger during the Spring '10 term at ASU.

Page1 / 5

CSE 230 solution to assignments - ICS 233, Term 072...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online