Presentation is loading. Please wait.

Presentation is loading. Please wait.

Pseudo-ops, Debugging, etc.

Similar presentations


Presentation on theme: "Pseudo-ops, Debugging, etc."— Presentation transcript:

1 Pseudo-ops, Debugging, etc.
CS/COE 0447 Jarrett Billingsley

2 Class announcements CS447

3 Pseudo-ops (pseudo-instructions)
CS447

4 I lied. move li la mul a, b, c blt/gt/le/ge lw _, (t0) lw _, var
many of the instructions you've learned so far do not really exist. these are pseudo-ops. they're convenient shorthand for common operations, for our squishy human brains why did we learn these? they're useful they hide some of the confusing ugliness of the "real" instruction set they let me teach things in a better order move li la mul a, b, c blt/gt/le/ge lw _, (t0) lw _, var CS447

5 What's really going on here?
they're translated by the assembler into real MIPS instructions never touch the 'at' register – it's used by the assembler for this you can see the real instructions in the Execute tab's code view - you will see some online resources where they don't use any pseudoinstructions and I don't really know why - but doing e.g. "add a0, zero, t0" is longer and doesn't convey intent like "move a0, t0" so CS447

6 Do we have to know what the real instructions are??
nnnooooooooooooo (dumb details you will never use) but you'll notice that sometimes, "one" instruction is more than one. this illustrates an important concept: abstraction is about hiding details… but it always incurs a cost. abstraction makes it easier to understand a program's behavior, but harder to predict its performance. also, it's way easier to improve the performance of abstract code than it is to abstract high-performance code. - performance isn't always the goal – it rarely is – but if it is a goal, keep this in mind. CS447

7 Why have pseudo-ops at all?
changing hardware is hard, changing software is easy rather than embedding all these instructions in hardware… we make software (the assembler) that handles it for us what if we could make our own pseudo-ops? (you can!) (look up macros in the MARS help) - macros are NOT functions, they're smart copy-and-paste - doing complicated things with macros is difficult because you have to hard-code registers into them – not great CS447

8 Debugging CS447

9 What is debugging? How many perfect, 100% correct programs have you written? How about on the first try? Guess what: no one does. Debugging is not just "fixing bugs." It helps you… …understand your program more deeply. …question your assumptions about how the computer works. …consider possible cases you had forgotten to handle. - and it helps you realize that although you fixed this one bug, oh no, you made the same mistake in 300 places throughout your code D: CS447

10 "printf debugging" System.out.println("got here4");
it's a little trickier in assembly, but… well, check out print_str_macro.asm on the examples page. hey, this might be useful for more than just debugging… CS447

11 Breakpoints see this "Bkpt" column on the left?
a breakpoint makes the program pause when that line is about to be run. a lot of "I got here" prints can be replaced by these. you can resume running after it pauses. CS447

12 Well, that's… MIPS CS447

13 Wait, really? yeah. assembly is not a complex language.
but that's what makes it so hard to use. now gaze into the project 1 abyss and scream no okay let's do some practice and answer questions CS447


Download ppt "Pseudo-ops, Debugging, etc."

Similar presentations


Ads by Google