slide1
Download
Skip this Video
Download Presentation
Ch6b

Loading in 2 Seconds...

play fullscreen
1 / 83

Ch6b - PowerPoint PPT Presentation


  • 92 Views
  • Uploaded on

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 () {

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

PowerPoint Slideshow about ' Ch6b' - karli


An Image/Link below is provided (as is) to download presentation

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
slide24

// 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;

}

slide25

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

slide29

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 ….
ad