EASy68K  
It is currently Thu Mar 23, 2017 2:07 am

All times are UTC




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: How constants work
PostPosted: Wed Mar 09, 2016 11:08 pm 
Offline

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
 Profile  
Reply with quote  
 Post subject: Re: How constants work
PostPosted: Sat Mar 12, 2016 12:24 am 
Offline

Joined: Sat Jan 09, 2016 9:58 pm
Posts: 11
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 ($HexAddress).L,A2
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:
MOVEA.L ($HexAddress).L,A2  ;puts the base address where your constants are stored into a register
       ;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
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC


Who is online

Users browsing this forum: Bing [Bot] and 1 guest


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