EASy68K  
It is currently Tue May 26, 2020 1:40 pm

All times are UTC




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: FOR statement from C
PostPosted: Fri Oct 08, 2010 2:48 pm 
Offline

Joined: Fri Oct 08, 2010 2:37 pm
Posts: 3
Location: MALAYSIA
this is my project. but i do not know how to change from C to EASy68K

Code:
void main (void)
{
    int i;
    int square[10];
    for(i=0; i<10; i++)
        square[i]=i*i;
    cout << "SQUARE TABLE\n";
    cout << " i      i*i\n";
    for(i=0; i<10; i++)
        cout << i << "    " << square[i] << "\n";
}

and the output should be in this form:


SQUARE TABLE

i i*i
1 1
2 4
3 9
4 16
5 25
6 36
7 49
8 64
9 81

Please help.. :( TQ

_________________
HEHE


Top
 Profile  
 
 Post subject:
PostPosted: Sun Oct 10, 2010 3:27 am 
Offline

Joined: Mon Jul 26, 2010 11:43 pm
Posts: 198
Location: Aurora, IL
Code:
        LEA     PWRTBL,A0
        MOVE.W  #0,D0
PWRLOOP:
        MOVE.W  D0,D1
        MULU.W  D1,D1
        MOVE.L  D1,(A0)+
        ADDQ    #1,D0
        CMP.W   #10,D0
        BLT     PWRLOOP

..

PWRTBL  DS.L    10


Top
 Profile  
 
 Post subject:
PostPosted: Sun Oct 10, 2010 9:56 am 
Offline

Joined: Fri Oct 08, 2010 2:37 pm
Posts: 3
Location: MALAYSIA
:roll: hmmm...i'd tried that without any error but i've got the blank screenshot..

Code:
    ORG    $1000
START:                ; first instruction of program

         LEA     PWRTBL,A0
        MOVE.W  #0,D0
PWRLOOP:
        MOVE.W  D0,D1
        MULU.W  D1,D1
        MOVE.L  D1,(A0)+
        ADDQ    #1,D0
        CMP.W   #10,D0
        BLT     PWRLOOP

PWRTBL  DS.L    10

    MOVE.B    #9,D0
    TRAP    #15        ; halt simulator

* Variables and Strings



    END    START        ; last line of source


is this right?

_________________
HEHE


Top
 Profile  
 
 Post subject:
PostPosted: Sun Oct 10, 2010 1:22 pm 
Offline

Joined: Mon Jul 26, 2010 11:43 pm
Posts: 198
Location: Aurora, IL
tensi wrote:
:roll: hmmm...i'd tried that without any error but i've got the blank screenshot..

Indeed, but I don't get paid to do your homework either.

You need the exit after the loop, but before the allocate space for the array. After you run the code examine the array of numbers PWRTBL, in memory, to confirm it contains the list on squared numbers.
Code:
        ORG    $1000
START:                ; first instruction of program

        LEA     PWRTBL,A0
        MOVE.W  #0,D0
PWRLOOP:
        MOVE.W  D0,D1
        MULU.W  D1,D1
        MOVE.L  D1,(A0)+
        ADDQ    #1,D0
        CMP.W   #10,D0
        BLT     PWRLOOP

        MOVE.B    #9,D0
        TRAP    #15        ; halt simulator

* Variables and Strings

PWRTBL  DS.L    10

    END    START        ; last line of source

This implements this portion of your homework.
Code:
void main (void)
{
    int i;
    int square[10];
    for(i=0; i<10; i++)
        square[i]=i*i;
}

Surely your class had some notes, examples, or other materials, to figure this problem out?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 11, 2010 1:40 am 
Offline

Joined: Fri Oct 08, 2010 2:37 pm
Posts: 3
Location: MALAYSIA
oic....my lecturer only provide slides and i didn't get it because everything is taught theoretically...

can u suggest any books that can help me more?

anyway thank u... :wink:

_________________
HEHE


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 11, 2010 2:35 am 
Offline

Joined: Mon Jul 26, 2010 11:43 pm
Posts: 198
Location: Aurora, IL
You're welcome.

As for books, there are a lot of choices, I learned 68K after using the 6502 and Z80 so the Motorola manuals were a good starting point for me. Some of the better books are listed below in preferred order. I provided Amazon links as they have good used sellers, you probably have more local sources, or library access.

I like Williams (the 68030 book has better coverage than the earlier 68000 one)
http://www.amazon.com/68030-Assembly-La ... t_ep_dpt_2

I like Wakerly
http://www.amazon.com/Microcomputer-Arc ... 55&sr=1-14

I like Hilf
http://www.amazon.com/M68000-Family-App ... 504&sr=1-2

I like Leventhal
http://www.amazon.com/Assembly-Language ... 73&sr=1-35

Ford/Topp is pretty good
http://www.amazon.com/Assembly-Language ... 005&sr=1-8


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group