EASy68K  
It is currently Mon Sep 16, 2019 5:12 am

All times are UTC




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: STRING
PostPosted: Mon Apr 25, 2011 4:02 pm 
Offline

Joined: Thu Apr 21, 2011 4:26 pm
Posts: 9
Location: BRIGHTON
i have to input a string from keyboard and then again display it with appropriate prompt.


for thi I am able to input a string using trap 5, compare command and then looping it but i am not able to retrieve it and display it again

Code:
*-----------------------------------------------------------
* Program    :
* Written by :
* Date       :
* Description:
*-----------------------------------------------------------
   ORG   $1000
START:            ; first instruction of program

    LEA   MESSAGE1,A1    *Loads message into address register A1
    MOVE.B  #14,D0          *Moves number 14 into data regiter D0
    TRAP   #15          *Displays Message
   


string move.b #5,d0
    trap #15
    cmp.l #0,d1
    beq  print
    move.b d1,(a6)+
    bra string
   
   

   LEA   MESSAGE2,A1    *Loads message into address register A1
    MOVE.B  #14,D0          *Moves number 14 into data regiter D0
    TRAP   #15          *Displays Message
   




print 
    move.b (a6)+,d1
    move.b #4,d0
    trap #15   
    cmp.l #0,d1
    bra print

   MOVE.B   #9,D0
   TRAP   #15      ; halt simulator
   
message1 dc.b 'enter your string: ',0


message2 dc.b 'string you hav entered is: ',0

cr dc.b 0



   END   START      ; last line of source

_________________
ANIKET
BRIGHTON,UK


Top
 Profile  
 
 Post subject:
PostPosted: Sat May 28, 2011 1:01 pm 
Offline
User avatar

Joined: Thu Dec 16, 2004 6:42 pm
Posts: 1101
There is no buffer for saving the input string.

The instruction move.b d1,(a6)+ is trying to save the string to address $00000000. That is not good. That area of memory is reserved for Reset and Interrupt vectors.

Perhaps trap task 2 would work better for reading the string.

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

    LEA     MESSAGE1,A1 *Loads message into address register A1
    MOVE.B  #14,D0      *Moves number 14 into data regiter D0
    TRAP    #15         *Displays Message
   
    LEA     BUFFER,A1   ; Where to store input string
    MOVE.B  #2,D0       ; Read string
    TRAP    #15

    LEA     MESSAGE2,A1 *Loads message into address register A1
    MOVE.B  #14,D0      *Moves number 14 into data regiter D0
    TRAP    #15         *Displays Message

    LEA     BUFFER,A1   ; String to display
    MOVE.B  #13,D0      ; Display string with newline
    TRAP    #15

    MOVE.B   #9,D0
    TRAP   #15          ; halt simulator
   
message1 dc.b 'enter your string: ',0
message2 dc.b 'string you have entered is: ',0

    ds.w    0       ; force even address
buffer  ds.b    80  ; input string storage

   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