It is currently Tue Sep 24, 2019 9:41 am

 All times are UTC

 Page 1 of 1 [ 2 posts ]
 Print view Previous topic | Next topic
Author Message
 Post subject: How constants workPosted: Wed Mar 09, 2016 11:08 pm

Joined: Wed Mar 09, 2016 10:42 pm
Posts: 1
Was wondering how am I able to assign a certain constant I declared a integer.
For example I have 10 constants and I want to list them from 1-10. I am trying to write a code where I type a integer then prints out the constant that is dedicated to that.

Top

 Post subject: Re: How constants workPosted: Sat Mar 12, 2016 12:24 am

Joined: Sat Jan 09, 2016 9:58 pm
Posts: 22
Let me preface this by saying that I have not tried this. I've only been reading a disassembly, so I am not perfectly sure how conventional notation is used, nor have I practiced what I will say. Based on my understanding, there are many ways to load up a constant value to then be displayed. I believe that some of the Trap (TRAP #15 ;??) exceptions in EASy68k may be linked to print functions as well, but I cannot be sure. You could try copying some of the example code to get printing and inputs to work.

As far as linking an index number to a stored constant, perhaps you could use a move command to store a constant in memory (choose a memory address which is higher than your code or which does not coincide with your instruction addresses).

Code:
MOVEA.L (\$4,A2),A3   ;a displacement of 4 (one long word) beyond HexAddress defines the address in A3
MOVE.L #constantNumber,A3

In this example, constantNumber is a decimal that is your storable constant and HexAddress is a hexadecimal memory address (something between 0x400 and 0xFFFFFF).

Then, in order to load up the constant based on input, move the input value (this is your number, 1-10) into a register, say D0, and use another effective addressing mode (indexed indirect) to load the stored constant onto a different register which can be passed to the printing function (by calling the TRAP exception command?).

Code:
;assuming that D0 is a long word index value which specifies the
;displacement from \$HexAddress (in long words, hence the "*4") where your constant is stored
MOVE.L (\$0,A2,D0.L*4),D2   ;moves your stored value onto D2

Again, I am only answering in spite of the cricket noise on this forum. I have not practiced this, but would like to participate in conversation. So when my advice inevitably fails, post again and let me know what you're thinking.

Top

 Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending
 Page 1 of 1 [ 2 posts ]

 All times are UTC

#### Who is online

Users browsing this forum: Google [Bot] and 4 guests

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

Search for:
 Jump to:  Select a forum ------------------ EASy68K Forum    FAQ    Latest Features    EASy68K Questions    68000 Programming Questions    Wish List    Wishes Granted    Undocumented Features    Documented Features    General Discussion    EASy68K Projects