Ch6b

1 / 83

# Ch6b - PowerPoint PPT Presentation

Ch6b. // File: prob0616.cpp // Computer Systems // Problem 6.16 #include &lt;iostream&gt; using namespace std; int myAge ; void putNext ( int age) { int nextYr ; nextYr = age + 1; cout &lt;&lt; &quot;Age: &quot; &lt;&lt; age &lt;&lt; endl ; cout &lt;&lt; &quot;Age next year: &quot; &lt;&lt; nextYr &lt;&lt; endl ; } int main () {

I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.

## PowerPoint Slideshow about 'Ch6b' - karli

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

### Ch6b

// File: prob0616.cpp

// Computer Systems

// Problem 6.16

#include <iostream>

using namespace std;

intmyAge;

void putNext (int age) {

intnextYr;

nextYr = age + 1;

cout << "Age: " << age << endl;

cout << "Age next year: " << nextYr << endl;

}

int main () {

cin >> myAge;

putNext (myAge);

putNext (64);

return 0;

}

Problem 6.16

0000 040024 BR main

0003 0000 myAge: .BLOCK 2 ;global varaible #2d

;

;******* void putNext (int age)

age: .EQUATE 4 ;formal parameter #2d

nextYr: .EQUATE 0 ;local variable #2d

0005 680002 putNext: SUBSP 2,i ;allocate #nextYr

0008 C30004 LDA age,s ;nextYr = age + 1

000E E30000 STA nextYr,s

0011 410046 STRO msg1,d ;cout << "Age: "

0014 3B0004 DECO age,s ; << age

0017 50000A CHARO '\n',i ; << endl

001A 41004C STRO msg2,d ;cout << Age next year: "

001D 3B0000 DECO nextYr,s ; << nextYr

0020 50000A CHARO '\n',i ; << endl

0023 5A RET2 ;deallocate #nextYr, pop retAddr

inta,b;

• void swap(int&r, int& s) {
• int temp;
• temp = r;
• r = s;
• s = temp; }
• void order (int &x, int& y) {
• If (x < y) {
• swap(x,y); } }//ra2
• int main() {
• order(a,b);
• cout ….