[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details

PEP8 Expert Help on Translation

Asked by Rookie101 in Assembly Programming Language

Tags: Machine Language Pep 8

Are there experts on PEP8 assmbly language here?   I am stuck.  I believe I have gone as far as I can on the problem.  I'm translating a C++ program to pep 8 Assembly language.  

Where am I going wrong on my code??  I think I'm going wrong on my call statement?

All the help is greatly appreciated!!!  
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
#include <iostream>
using namespace std;
int fib(int num)
{
      if (num < 1) /*if number is less than or equal to 1*/
      {
		return 1; /* return number */
      }
		else 
      {
		return 2*(fib(num-1))+fib(num-2); /* return fibonacci formula */
      }
}
 
void main()
 
{
            int num;    /* The fibonacci number selected */
            cout << "Which Fibonacci number?  ";
            cin >> num; /* input */
		cout<<"The number is:  " << fib(num) << endl; /*outputs the fibonacci sum*/
}
 
BR    main      
 
num:     .EQUATE 0           ;formal paramter #2,d
 
;
;*****************************main()
main:    STRO  msg1,d      ;cout<<"Which Fibonacci Number?  "
         DECI  num,d       ;cin >> num 
         CHARO '\n',i   ; << endl
         
         STRO  msg2,d      ;cout<< "The number is: "           
         ;STA -2,s
         ;SUBSP 2,i 
         CALL  fib
 
;
;******************** int fib (int num)
num:   .EQUATE 0             ;formal paramter #2h
   
fib:     SUBSP 2,i           ;allocate #num 
if:      LDA  num,d          ;if (num < 1)      
         BRLE else           
then:    LDA  1,i            ; return 1
         STA retVal,s
         RET2
         
else:    ASLA                ; 2* 
         
         LDA  num,d         
         SUBA 1,i            ;(num-1)
         STA num,d
         
         ADDA num,d          ; +
 
         LDA num,d
         SUBA 2,i            ;(num-2)
         STA num,d 
         
         RET2                ;deallocate #num, pop retAdd
 
         BR endIf        
  
                
         endIf:   STOP
                 
 
msg1:    .ASCII  "Which Fibonacci Number? \x00"
msg2:    .ASCII  "The number is:  \x00"
.END
 
Related Solutions
Keywords: PEP8 Expert Help on Translation
 
Loading Advertisement...
 
[+][-]10/29/09 06:43 AM, ID: 25693536Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10/29/09 08:04 AM, ID: 25694458Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10/30/09 06:56 AM, ID: 25702954Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091111-EE-VQP-92 - Hierarchy / EE_QW_3_20080625