Skip to content

Instantly share code, notes, and snippets.

@asterwolf
Last active December 9, 2015 19:10

Revisions

  1. asterwolf revised this gist Dec 9, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion twoDprocessFloat.s
    Original file line number Diff line number Diff line change
    @@ -36,7 +36,7 @@ LOOP:

    L2:
    movb %al, (%edx, %ecx)
    loop LOOP
    jmp LOOP

    DONE:
    leave
  2. asterwolf revised this gist Dec 4, 2015. 1 changed file with 5 additions and 1 deletion.
    6 changes: 5 additions & 1 deletion twoDprocessFloat.s
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,8 @@
    /** For this assignment you will write an assembly language function (in 32-bit *mode) to manipulate a 2-dimensional array that represents an image. The image *is a bitmapped image, where (at least for the images we will be working with) *each pixel is represented by 3 bytes that indicate how much red, green, and *blue there is at that location.
    /** For this assignment you will write an assembly language function (in 32-bit
    * mode) to manipulate a 2-dimensional array that represents an image. The image
    * is a bitmapped image, where (at least for the images we will be working with)
    * each pixel is represented by 3 bytes that indicate how much red, green, and
    * blue there is at that location.
    * @author: Diego Diaz
    * Course: COMP B13
    * Created on: Dec 4, 2015
  3. asterwolf created this gist Dec 4, 2015.
    40 changes: 40 additions & 0 deletions twoDprocessFloat.s
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,40 @@
    /** For this assignment you will write an assembly language function (in 32-bit *mode) to manipulate a 2-dimensional array that represents an image. The image *is a bitmapped image, where (at least for the images we will be working with) *each pixel is represented by 3 bytes that indicate how much red, green, and *blue there is at that location.
    * @author: Diego Diaz
    * Course: COMP B13
    * Created on: Dec 4, 2015
    * Source File: twoDprocessFloat.s
    */

    .globl _multiply2Dfloat
    _multiply2Dfloat:
    pushl %ebp
    movl %esp, %ebp
    subl $12, %esp

    flds 20(%ebp)
    movl 12(%ebp), %eax #stores rows into eax
    movl 16(%ebp), %ecx #stores cols into ecx
    imull %eax, %ecx #stores rows * cols into ecx
    movl 8(%ebp), %edx #stores array in edx

    LOOP:
    subl $1, %ecx #decrements 1 from array offset
    js DONE #if sign flag is set, array is done and jumps to DONE
    movzbl (%edx, %ecx), %eax #stores content of array in eax as a long
    movl %eax, (%esp)
    fild (%esp) #loads the content of the array onto the float stack
    fmul %st(1), %st(0) #multiplies to content by the factor and stores in %st
    fistpl (%esp) #pops the new value off the floating stack
    movl (%esp), %eax #stores the new value in eax
    cmpl $256, %eax #compares the new value to 256
    jl L2 # if less than 256, jumps to L2 to put in array
    movl $255, %eax #if greater than or equals to 256, places 255 instead

    L2:
    movb %al, (%edx, %ecx)
    loop LOOP

    DONE:
    leave
    ret