Skip to content
TheChatArchiveThe Chat Archive
Human-written demonstration (OpenAssistant volunteers)· OpenAssistant (human-written)Hugging Face OpenAssistant Conversations (oasst2)

Create a MIPS assembly program that can solve a quadratic equation.

In OpenAssistant data, “assistant” turns were written by human volunteers as demonstrations. They are not model outputs.
  1. User

    Create a MIPS assembly program that can solve a quadratic equation.

  2. Assistant

    .data a: .float 1.0 b: .float -3.0 c: .float 2.0 result1: .float 0.0 result2: .float 0.0 four: .float 4.0 two: .float 2.0

    .text .globl main main: # Load values of a, b, and c lwc1 f0,alwc1f0, a lwc1 f1, b lwc1 $f2, c

    # Calculate discriminant (b^2 - 4ac)
    mul.s $f3, $f1, $f1
    mul.s $f4, $f0, $f2
    lwc1 $f5, four
    mul.s $f4, $f4, $f5
    sub.s $f3, $f3, $f4
    
    # Calculate sqrt(discriminant)
    sqrt.s $f3, $f3
    
    # Calculate the two results: (-b ± sqrt(discriminant)) / 2a
    neg.s $f1, $f1
    lwc1 $f5, two
    div.s $f5, $f1, $f5
    add.s $f6, $f1, $f3
    sub.s $f7, $f1, $f3
    div.s $f6, $f6, $f0
    div.s $f7, $f7, $f0
    
    # Store the results in memory
    swc1 $f6, result1
    swc1 $f7, result2
    
    # Exit the program
    li $v0, 10
    syscall
    

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.