2 ms·
this could be easy or hard depending on what you had to write in assembly on the test. like it wouldn't be that hard to write a subroutine to add up an array o
by kragen 2y ago
this could be easy or hard depending on what you had to write in assembly on the test. like it wouldn't be that hard to write a subroutine to add up an array of integers or something
addem: xor eax, eax
loop:
test ecx, ecx
jnz ok
ret
ok: add eax, [ebx + ecx * 4]
dec ecx
jmp loop
(i haven't tested this, it'd be hilarious if i got it wrong)
- gus_massa 2y agoAssuming ebx is the pointer to the array and ecx is the length, doesn't this sum the slots from 1 to ecx (incusive) instead of 0 to ecx-1 (inclusive)?
- kragen 2y agohahaha, yes! i guess it wasn't as trivial as i thought. that's what i get for trying to be clever — guess i wouldn't have done that well on that exam ;)
- hirvi74 2y agoThe assembly on the test was much larger than the snippet you provided. I wish a kept a copy of the old test so I could just copy and example problem. Honestly though, that wasn't the worst part of the tests. It was the most dangerous though because many of the questions/instructions relied on previously completed questions/instruction to be correct. So, like if you passed a wrong value to a certain register, then downstream, every problem that used that register would be off. The tests were often 4 pages front and back with the handwritten assembly, definition matching, word problems, essay responses, etc.. We had like 75 minutes to take the test too. This was all at a public, no-name state university too. I was no MIT student or anything. Anyway, I'll never forget the first day of class. Our professor said we were to have 4 tests and a final and some labs. My friend in the class: "If we make a 100 on all 4 tests, do we have to take the final?" The professor: "Hell, if you make 100 on 4 test, then I will let you write the final." My friend: "Why? Has no one ever done that before?" Professor: "No, in fact, in the 20 years I have taught this class, no one has ever scored a 100 on any test." We all knew we were in for hell after that.
- kragen 2y agothat's awesome! i wish you'd kept a copy too