Month: October 2010

Assembly Code

Another look at C++ vs. Assembly

This little program is written in both C++ ans MIPS assembly code. It asks the user for their name and age, then repeats the info back to the screen. Notice the manual adjustment of the runtime stack in the assembly version. ######################################### #### C++ CODE ######################################### # void GetInfo(string& name, int& age); # void DisplayInfo(string name, int age); # int main() { # string name; # int age; # GetInfo(name, age); # DisplayInfo(name, age); # return (0); # } # void GetInfo(string& name, int& age) { # cout << "Enter your name: "; # cin >> name; # cout << […]

Assembly Code

C++ and Assembly side by side

These small pieces of code demonstrate the differences between high and low level programming languages. ###################################################### ####      Origional C++ Code ###################################################### # #include <iostream> # using namespace std; # # int main() { #    int lo,hi; #    cout << "Enter lower bound ascii value: "; #    cin >> lo; #    cout << "Enter upper bound ascii value: "; #    cin >> hi; #    for (int i = lo; i <= hi; i++) { #      cout << char(i) << endl; #    } #    return (0); # } ###################################################### #####       Begin MIPS Assembly ###################################################### .data LoPrompt: .asciiz "Enter lower ascii value: " […]