Last active
December 9, 2015 19:10
-
-
Save asterwolf/15f6bcf0187d8a1e4516 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** 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) | |
jmp LOOP | |
DONE: | |
leave | |
ret | |
I like it!
Efficient too!
Mine was a bit longer, less efficient - but a fun program!
Thanks Craig! I fixed my small error. It was fun until I spent 2 hours to find 1 little mistake. 😄
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hell yeah.