EASy68K  
It is currently Mon Sep 23, 2019 12:06 pm

All times are UTC




Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Wed Apr 03, 2019 10:47 pm 
Offline

Joined: Wed Apr 03, 2019 10:40 pm
Posts: 1
Hello,

I am very new to Easy68k and I am still slowly learning the basics of how it works. I am having some trouble understanding the method of memory access using address registers. I understand that they are somewhat similar to the data registers, but I do not understand how to process and play around with data using only address registers.

For example, if i have a text string abc1234 and i wanted to store it into one address register; how would i go about performing operations on just the numerical part of the string?

Thanks in advance.


Top
 Profile  
 
PostPosted: Fri Apr 05, 2019 1:46 am 
Offline
User avatar

Joined: Thu Dec 16, 2004 6:42 pm
Posts: 1102
Address registers are used to point to memory. If an address register contains a memory address the contents of memory may be accessed via the address register by using one of several indirect addressing modes.

Here is some example code that reads 10 numbers from the keyboard, stores them into an array and then displays the array.

Code:
*-----------------------------------------------------------
* Program    : Array programming
* Written by : Charles Kelly
* Date       : April, 2009
* Description: Get 10 numbers from keyboard, store them in
*              an array then display them from the array.
*-----------------------------------------------------------
    ORG $1000
SIZE    equ     4   ; data size (4 bytes for long word)

START:              ; first instruction of program

    * read 10 numbers from keyboard and store in array
    lea array1,A0           ; pointer to array
   
    for D2 = #0 to #9*SIZE by #SIZE do.s  ; loop 10 times
        lea     prompt,A1   ; pointer to string
        move.b  #13,D0      ; display prompt
        trap    #15
       
        move.b  #4,D0       ; read number from keyboard into D1.L
        trap    #15
               
        move.l  D1,(A0,D2)  ; store number to array at index D2
    endf
   
    lea     result,A1       ; pointer to string
    move.b  #13,D0          ; display result
    trap    #15
   
    * display numbers from array
    for D2 = #0 to #9*SIZE by #SIZE do.s  ; loop 10 times
        move.l  (A0,D2),D1  ; get number from array at index D0
        move.b  #3,D0       ; display number in D1.L
        trap    #15
       
        lea     crlf,A1     ; pointer to string
        move.b  #14,D0      ; display cr lf
        trap    #15
    endf
       
    MOVE.B  #9,D0
    TRAP    #15     ; halt simulator

* Variables and Strings
array1  ds.l    10  ; 10 long word array
prompt  dc.b    'Enter a number: ',0    ; null terminated string
result  dc.b    'Your numbers are: ',0  ; null terminated string
crlf    dc.b    $d,$a,0                 ; carriage return, line feed, null

    END START       ; last line of source



_________________
Prof. Kelly


Top
 Profile  
 
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: No registered users and 3 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