830 likes | 977 Views
Ch6b. // File: prob0616.cpp // Computer Systems // Problem 6.16 #include <iostream> using namespace std; int myAge ; void putNext ( int age) { int nextYr ; nextYr = age + 1; cout << "Age: " << age << endl ; cout << "Age next year: " << nextYr << endl ; } int main () {
E N D
// 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 000B 700001 ADDA 1,i 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 ….