(Solved Homework): MIPS assembly code for adding (addition of) and subtracting (subtraction of) two signed numbers (positive and

MIPS assembly code for adding (addition of) and subtracting (subtraction of) two signed numbers (positive and negative numbers) . Need code for both methods. Using registers and hardware only aka “logical operations”. Cannot use just MIPS add and sub. Need to use bit operations.

Expert Answer

 For addition:
.file   1 ""
        .section .mdebug.abi32
        .previous
        .gnu_attribute 4, 1
        .abicalls
        .rdata
        .align  2
$LC0:
        .ascii  "%d %d00"
        .align  2
$LC1:
        .ascii  "%d00"
        .text
        .align  2
        .globl  main
$LFB0 = .
        .set    nomips16
        .ent    main
        .type   main, @function
main:
        .frame  $fp,48,$31              # vars= 16, regs= 2/0, args= 16, gp= 8
        .mask   0xc0000000,-4
        .fmask  0x00000000,0
        .set    noreorder
        .cpload $25
        .set    nomacro
        
        addiu   $sp,$sp,-48
$LCFI0:
        sw      $31,44($sp)
$LCFI1:
        sw      $fp,40($sp)
        movz    $31,$31,$0
$LCFI2:
        move    $fp,$sp
$LCFI3:
        .cprestore      16
        addiu   $3,$fp,28
        addiu   $2,$fp,32
        lw      $4,%got($LC0)($28)
        nop
        addiu   $4,$4,%lo($LC0)
        move    $5,$3
        move    $6,$2
        lw      $2,%call16(scanf)($28)
        nop
        move    $25,$2
        jalr    $25
        nop

        lw      $28,16($fp)
        lw      $3,28($fp)
        lw      $2,32($fp)
        move    $4,$3
        move    $5,$2
        lw      $2,%got(_Z3sumii)($28)
        nop
        move    $25,$2
        jalr    $25
        nop

        lw      $28,16($fp)
        sw      $2,24($fp)
        lw      $2,%got($LC1)($28)
        nop
        addiu   $4,$2,%lo($LC1)
        lw      $5,24($fp)
        lw      $2,%call16(printf)($28)
        nop
        move    $25,$2
        jalr    $25
        nop

        lw      $28,16($fp)
        move    $2,$0
        move    $sp,$fp
        lw      $31,44($sp)
        lw      $fp,40($sp)
        addiu   $sp,$sp,48
        j       $31
        nop

        .set    macro
        .set    reorder
        .end    main
$LFE0:
        .size   main, .-main
        .align  2
        .globl  _Z3sumii
$LFB1 = .
        .set    nomips16
        .ent    _Z3sumii
        .type   _Z3sumii, @function
_Z3sumii:
        .frame  $fp,8,$31               # vars= 0, regs= 1/0, args= 0, gp= 0
        .mask   0x40000000,-4
        .fmask  0x00000000,0
        .set    noreorder
        .set    nomacro
        
        addiu   $sp,$sp,-8
$LCFI4:
        sw      $fp,4($sp)
$LCFI5:
        move    $fp,$sp
        movz    $31,$31,$0
$LCFI6:
        sw      $4,8($fp)
        sw      $5,12($fp)
        lw      $3,8($fp)
        lw      $2,12($fp)
        nop
        addu    $2,$3,$2
        move    $sp,$fp
        lw      $fp,4($sp)
        addiu   $sp,$sp,8
        j       $31
        nop

        .set    macro
        .set    reorder
        .end    _Z3sumii
$LFE1:
        .size   _Z3sumii, .-_Z3sumii
        .section        .eh_frame,"aw",@progbits
$Lframe1:
        .4byte  $LECIE1-$LSCIE1
$LSCIE1:
        .4byte  0x0
        .byte   0x1
        .globl  __gxx_personality_v0
        .ascii  "zP00"
        .uleb128 0x1
        .sleb128 -4
        .byte   0x1f
        .uleb128 0x5
        .byte   0x0
        .4byte  __gxx_personality_v0
        .byte   0xc
        .uleb128 0x1d
        .uleb128 0x0
        .align  2
$LECIE1:
$LSFDE1:
        .4byte  $LEFDE1-$LASFDE1
$LASFDE1:
        .4byte  $LASFDE1-$Lframe1
        .4byte  $LFB0
        .4byte  $LFE0-$LFB0
        .uleb128 0x0
        .byte   0x4
        .4byte  $LCFI0-$LFB0
        .byte   0xe
        .uleb128 0x30
        .byte   0x4
        .4byte  $LCFI2-$LCFI0
        .byte   0x11
        .uleb128 0x1e
        .sleb128 2
        .byte   0x11
        .uleb128 0x1f
        .sleb128 1
        .byte   0x4
        .4byte  $LCFI3-$LCFI2
        .byte   0xd
        .uleb128 0x1e
        .align  2
$LEFDE1:
        .ident  "GCC: (Debian 4.4.5-8) 4.4.5"

For Substraction

.file   1 ""
        .section .mdebug.abi32
        .previous
        .gnu_attribute 4, 1
        .abicalls
        .rdata
        .align  2
$LC0:
        .ascii  "%d %d00"
        .align  2
$LC1:
        .ascii  "%d00"
        .text
        .align  2
        .globl  main
$LFB0 = .
        .set    nomips16
        .ent    main
        .type   main, @function
main:
        .frame  $fp,48,$31              # vars= 16, regs= 2/0, args= 16, gp= 8
        .mask   0xc0000000,-4
        .fmask  0x00000000,0
        .set    noreorder
        .cpload $25
        .set    nomacro
        
        addiu   $sp,$sp,-48
$LCFI0:
        sw      $31,44($sp)
$LCFI1:
        sw      $fp,40($sp)
        movz    $31,$31,$0
$LCFI2:
        move    $fp,$sp
$LCFI3:
        .cprestore      16
        addiu   $3,$fp,28
        addiu   $2,$fp,32
        lw      $4,%got($LC0)($28)
        nop
        addiu   $4,$4,%lo($LC0)
        move    $5,$3
        move    $6,$2
        lw      $2,%call16(scanf)($28)
        nop
        move    $25,$2
        jalr    $25
        nop

        lw      $28,16($fp)
        lw      $3,28($fp)
        lw      $2,32($fp)
        move    $4,$3
        move    $5,$2
        lw      $2,%got(_Z4diffii)($28)
        nop
        move    $25,$2
        jalr    $25
        nop

        lw      $28,16($fp)
        sw      $2,24($fp)
        lw      $2,%got($LC1)($28)
        nop
        addiu   $4,$2,%lo($LC1)
        lw      $5,24($fp)
        lw      $2,%call16(printf)($28)
        nop
        move    $25,$2
        jalr    $25
        nop

        lw      $28,16($fp)
        move    $2,$0
        move    $sp,$fp
        lw      $31,44($sp)
        lw      $fp,40($sp)
        addiu   $sp,$sp,48
        j       $31
        nop

        .set    macro
        .set    reorder
        .end    main
$LFE0:
        .size   main, .-main
        .align  2
        .globl  _Z4diffii
$LFB1 = .
        .set    nomips16
        .ent    _Z4diffii
        .type   _Z4diffii, @function
_Z4diffii:
        .frame  $fp,8,$31               # vars= 0, regs= 1/0, args= 0, gp= 0
        .mask   0x40000000,-4
        .fmask  0x00000000,0
        .set    noreorder
        .set    nomacro
        
        addiu   $sp,$sp,-8
$LCFI4:
        sw      $fp,4($sp)
$LCFI5:
        move    $fp,$sp
        movz    $31,$31,$0
$LCFI6:
        sw      $4,8($fp)
        sw      $5,12($fp)
        lw      $3,8($fp)
        lw      $2,12($fp)
        nop
        subu    $2,$3,$2
        move    $sp,$fp
        lw      $fp,4($sp)
        addiu   $sp,$sp,8
        j       $31
        nop

        .set    macro
        .set    reorder
        .end    _Z4diffii
$LFE1:
        .size   _Z4diffii, .-_Z4diffii
        .section        .eh_frame,"aw",@progbits
$Lframe1:
        .4byte  $LECIE1-$LSCIE1
$LSCIE1:
        .4byte  0x0
        .byte   0x1
        .globl  __gxx_personality_v0
        .ascii  "zP00"
        .uleb128 0x1
        .sleb128 -4
        .byte   0x1f
        .uleb128 0x5
        .byte   0x0
        .4byte  __gxx_personality_v0
        .byte   0xc
        .uleb128 0x1d
        .uleb128 0x0
        .align  2
$LECIE1:
$LSFDE1:
        .4byte  $LEFDE1-$LASFDE1
$LASFDE1:
        .4byte  $LASFDE1-$Lframe1
        .4byte  $LFB0
        .4byte  $LFE0-$LFB0
        .uleb128 0x0
        .byte   0x4
        .4byte  $LCFI0-$LFB0
        .byte   0xe
        .uleb128 0x30
        .byte   0x4
        .4byte  $LCFI2-$LCFI0
        .byte   0x11
        .uleb128 0x1e
        .sleb128 2
        .byte   0x11
        .uleb128 0x1f
        .sleb128 1
        .byte   0x4
        .4byte  $LCFI3-$LCFI2
        .byte   0xd
        .uleb128 0x1e
        .align  2
$LEFDE1:
        .ident  "GCC: (Debian 4.4.5-8) 4.4.5"
iWriteHomework
Order NOW for a 10% Discount
Pages (550 words)
Approximate price: -

Why Us?

Top Quality and Well-Researched Papers

All ourbpapers are written from scratch. In fact, Clients who ask for paraphrasing services are highly discouraged. We have writers ready to craft any paper from scratch and deliver quality ahead of time.

Professional and Experienced Academic Writers

Our writers keeps you posted on your papers progress - providing you with paper outline/draft. You are also at liberty to communicate directly with your writer.

Free Unlimited Revisions

If you think we missed something, send your order for a free revision. You have 10 days to submit the order for review after you have received the final document. You can do this yourself after logging into your personal account or by contacting our support.

Prompt Delivery and 100% Money-Back-Guarantee

All papers are always delivered on time, in many cases quite ahead of time. In case we need more time to master your paper, we may contact you regarding the deadline extension. In case you cannot provide us with more time, a 100% refund is guaranteed.

Original & Confidential

We use several writing tools checks to ensure that all documents you receive are free from plagiarism. Our editors carefully review all quotations in the text. We also promise maximum confidentiality in all of our services.

24/7 Customer Support

Our support agents are available 24 hours a day 7 days a week and committed to providing you with the best customer experience. Get in touch whenever you need any assistance.

Try it now!

Calculate the price of your order

Total price:
$0.00

How it works?

Follow these simple steps to get your paper done

Place your order

Fill in the order form and provide all details of your assignment.

Proceed with the payment

Choose the payment system that suits you most.

Receive the final file

Once your paper is ready, we will email it to you.

Our Services

No need to work on your paper at night. Sleep tight, we will cover your back. We offer all kinds of writing services.

Essays

Essay Writing Service

No matter what kind of academic paper you need and how urgent you need it, you are welcome to choose your academic level and the type of your paper at an affordable price. We take care of all your paper needs and give a 24/7 customer care support system.

Admissions

Admission Essays & Business Writing Help

An admission essay is an essay or other written statement by a candidate, often a potential student enrolling in a college, university, or graduate school. You can be rest assurred that through our service we will write the best admission essay for you.

Reviews

Editing Support

Our academic writers and editors make the necessary changes to your paper so that it is polished. We also format your document by correctly quoting the sources and creating reference lists in the formats APA, Harvard, MLA, Chicago / Turabian.

Reviews

Revision Support

If you think your paper could be improved, you can request a review. In this case, your paper will be checked by the writer or assigned to an editor. You can use this option as many times as you see fit. This is free because we want you to be completely satisfied with the service offered.

× Contact Live Agents