title: Accidental overwrite of general register
body: <p>I am working on a homework assignment where we have to write comments to describe what some assembly code is doing. I am new to assembly so I can't really tell if the following code has a mistake.</p>
  
  <p>I am using i686 architecture (not entirely sure what that means TBH)</p>
  
  <p>This program determineGrade.s is being called by another program cs3843p3Driver.o</p>
  
  <pre><code>############################## determineGrade #####################
  # Purpose:
  #   determineGrade determines the grade of a student based on a
  #   1000 pt scale.
  # Parameters:
  #   i 8(%ebp)  int iG1       Grade 1
  #   i 12(%ebp) int iG2       Grade 2
  #   i 16(%ebp) int iG3       Grade 3
  #   i 20(%ebp) int iG4       Grade 4
  #   i 24(%ebp) int iG5       Grade 5
  #   i 28(%ebp) int iG6       Grade 6
  #   i 32(%ebp) int iG7       Grade 7
  #   i 36(%ebp) int iG8       Grade 8
  #   i 40(%ebp) int iG9       Grade 9
  #   i 44(%ebp) int iG10      Grade 10
  # Locals:
  #   -4(%ebp)  int iqTot
  #   -8(%ebp)  int iTot
  # Notes:
  #   Grade is determined by
  #       ??
  # Return Value:
  #   total grade on a 1000 pt scale
  # Register Usage
  #   %eax - mostly working register until after .L7 then ??
    .file "determineGrade.s"
    .text
  .globl determineGrade
    .type determineGrade, @function
  determineGrade:
    pushl %ebp
    movl  %esp, %ebp
      pushl %ebx                # Save the caller's %ebx since we are using %ebx
    subl  $20, %esp
    movl  $0, -4(%ebp)          # Overrides the caller's %ebx?
  </code></pre>
  
  <p>It looks as if the caller's <code>%ebx</code> value is stored in the same place as <code>iqTot</code>, which is defined as <code>-4(%ebp)</code>. Was the caller's <code>%ebx</code> value overwritten by accident?</p>