Motivated #3
In Response to Motivated #2
I did it without falling asleep! It took me about 3 hours to learn enough assembly code to finish the assignment, about 20 minutes to actually solve the problems, and then about 1.5 hours to make my code look nice and confuse myself repeatedly in the process of trying to figure out why my compiler was using different registers than the ones used in the assignment's code. Eventually, I realized there was nothing I could do and that it was probably by teacher's stupid Mac compiler's fault.
Here is the assembly code, side by side:
Assignment code My code
movl 16(%ebp), %edx 16(%ebp), %eax
movl 12(%ebp), %eax 12(%ebp), %edx
addl 8(%ebp), %eax 8(%ebp), %edx
addl %eax, %eax %edx, %edx
leal (%edx,%edx,2), %edx (%eax,%eax,2), %eax
cmpl %edx, %eax %eax, %edx
setg %al %al
movzbl %al, %eax %al, %eax
Which is like saying
t1 = x t1 = y
t2 = y vs t2 = x
t1 > t2 t2 > t1
What this all means is basically:
2*(x + y) > 3*z;
tl;dr
MAC COMPILERS SUCK
MAC SUCKS
USE LINUX PLZ
(I don't actually know if it's Apple's fault, but I assume it is because Apple is stupid. I'll be pretty embarrassed if it's actually my computer's fault, but I don't think so, because my answer for the first problem matched the book's exactly.)
Friday, April 15, 2011
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment