It is currently Mon Feb 24, 2020 8:35 pm

 All times are UTC

 Page 1 of 1 [ 3 posts ]
 Print view Previous topic | Next topic
Author Message
 Post subject: Programming codePosted: Fri Dec 13, 2019 10:40 am

Joined: Fri Dec 13, 2019 8:57 am
Posts: 2
Dear Mr Kelly, or any other kindness soul who whants to help.

I am working with this program to try to understand how the machine works, I am used to high level computational language so this is very confusing. I think I have read tons and tons of information but I think I am not progressing at all. So any help would be appreciated

Pd: Sorry if some words are "spanglish" but my english is a little bit rusty =P

So lets begin,

I have to make a program which the user enters a string and the program make a count about how many characters, numbers and spaces are in the string.

I made this pseudocode to figure it out the logic of the exercise,

Entorno
Variables
phrase: string
digit, space, character, i: int
Algorithm
START
space = 0
digit = 0
For i = 0 to string (i) = "/0", i = i + 1
Switch string (i)
string (i) = ""
space = space + 1
string (i) = 1
digit = digit + 1
string (i) = 2
digit = digit + 1
string (i) = 3
digit = digit + 1
string (i) = 4
digit = digit + 1
string (i) = 5
digit = digit + 1
string (i) = 6
digit = digit + 1
string (i) = 7
digit = digit + 1
string (i) = 8
digit = digit + 1
string (i) = 9
digit = digit + 1
string (i) = 0
digit = digit + 1
EndSwitch
EndFor

character = i
character = character - space - digit
write character
write space
write digit
END

Ok, now let's start to write the code, I look for some starting examples and I could wrote this:

Code:
ORG    \$1000 *this is where the code is storaged but some times I saw \$2000 and \$3000 and do not know why
START:                  ; first instruction of program

*This block is to answer the string

LEA     MESSAGE1,A1  *Charges message in A1
MOVE.B  #14,D0         *Moves byte data from origin to destiny, so I understand I am moving from memory direction 14 to register (data bus) D0
*I found this is like cout so this is why I'm using it
TRAP    #15                *This stops the system with priority 15

*This block storage the string

LEA     BUFFER,A1   * Here I storage the string
MOVE.B  #2,D0       * Now I read the string, similar to cin>>string, lenght is in D1.W direction
TRAP    #15            * I don't understand why is always the same stop priority, I read there this trap is the following:

*Display the unsigned number in D1.L converted to number base (2 through 36) contained in D2.B
*at this moment I have searched explanations but is like chinese

*This block shows the message

LEA     MESSAGE2,A1 *Charges message in A1, using the same direction so I understand I am removing message1 with message2
MOVE.B  #14,D0
TRAP    #15

*This block shows the string

LEA     BUFFER,A1   ; Rescue string storage in A1
MOVE.B  #13,D0      ; Shows the string in a new line, if not is MOVE.B #14,D0
TRAP    #15

MOVE.B   #9,D0 *I don't understand this command

TRAP   #15          ; halt simulator

*----------------------------------------------

message1 dc.b 'enter your string: ',0
message2 dc.b 'string you have entered is: ',0

ds.w    0           * the command ds is to storage bytes so i don't understand why we storage 0 words
buffer  ds.b    80   * this is to storage 80 bytes, I guess is the lenght of the string

END    START        ; last line of source

So now I have this and I would like to continue, I guess the code I have to use is some kind of this:

LOOP MOVE.L #10,D0 *Loop counter in D0
CMP.B #\$ff,D0 *#\$ff is a word type (2 bytes) so I have to use CMP.B to compare words in the string so I suppose I have to use this.
ADD.B #1,D0 *increment counter from direction 1 to D0
BNE LOOP * make the loop while D0 <> 0

Looking for another codes It's seems to me that I have to write a lot of things but Im so lost,

Regards

Top

 Post subject: Re: Programming codePosted: Sun Dec 15, 2019 11:36 am

Joined: Thu Dec 16, 2004 6:42 pm
Posts: 1118
You are on the correct path. The program you are attempting to write is complex for someone that does not know Assembly language. I suggest starting with smaller programs first. Look in the EASy68K/Examples folder and online: http://www.easy68k.com/easy68kexamples.htm

_________________
Prof. Kelly

Top

 Post subject: Re: Programming codePosted: Fri Feb 21, 2020 9:46 pm

Joined: Thu Feb 20, 2020 8:02 pm
Posts: 12
Hello
I will try to answer some questions...

The comment on "MOVE.B #14,D0" is not correct. # means it's an immediate value, not a memory address.

The following is commented as something you don't understand:
Quote:
MOVE.B #9,D0
TRAP #15

But it's simply a call to a EASy68k function to terminate the program (similar to the SIMHALT directive).

I attached a small program which does what you say, ie counts characters, spaces and digits in a string entered by the user.

Top

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

 All times are UTC

#### Who is online

Users browsing this forum: Bing [Bot] and 8 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