EASy68K  
It is currently Fri May 29, 2020 3:25 am

All times are UTC




Post new topic Reply to topic  [ 35 posts ]  Go to page Previous  1, 2, 3
Author Message
 Post subject:
PostPosted: Thu Oct 29, 2009 11:51 pm 
Offline

Joined: Thu Oct 29, 2009 11:18 pm
Posts: 1
Location: Denver
I guess I'm a little slow with this, but to convert a string from upper case to lower or vice versa I understand you have to go through the string and convert each individual letter but what would be the best way to go about that?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 30, 2009 1:14 pm 
Offline
User avatar

Joined: Thu Dec 16, 2004 6:42 pm
Posts: 1122
The best way is the way you come up with to solve the problem. There are several examples of iterating through a string in this thread. Any one of them will work or you can use a totally different scheme. Just make sure you understand the code.

_________________
Prof. Kelly


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 23, 2011 6:14 pm 
Offline

Joined: Sat Mar 12, 2011 2:53 am
Posts: 9
hey can you show me the correct version to dark's code?please and thanks


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 23, 2011 7:15 pm 
Offline
User avatar

Joined: Thu Dec 16, 2004 6:42 pm
Posts: 1122
No, and you are welcome. I don't do homework programs for my students or any other students on this forum.

_________________
Prof. Kelly


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 24, 2011 1:11 am 
Offline

Joined: Mon Jul 26, 2010 11:43 pm
Posts: 198
Location: Aurora, IL
Code:
; Convert a NUL terminated string to upper case

; There is much to be learned by looking at other peoples code.

        ORG     $1000

start   lea     Msg,a0          ; Print original
        bsr     puts

        lea     Msg,a0          ; Load A0 with the address of Msg
loop    move.b  (a0)+,d0        ; Load current character, and advance
        beq     done            ; NUL found at end-of-string, free test
        cmp     #'a',d0
        blt     loop            ; Less than 'a', check next
        cmp     #'z',d0
        bgt     loop            ; Greater than 'z' check next
        bclr    #5,d0           ; Clear bit 5 ('a' - 'A' = $20)
        move.b  d0,-1(a0)       ; Reach back and fix lower case char in place
        bra     loop            ; do next

done    lea     Msg,a0          ; Print out result
        bsr     puts

        MOVE.B  #9,D0
        TRAP    #15             ; halt simulator

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

puts    movem.l d0/a0-a1,-(a7)
        move    #14,d0          ; task number into D0
        move    a0,a1
        trap    #15             ; display string
        lea     crlf,a1
        trap    #15
        movem.l (a7)+,d0/a0-a1
        rts

crlf    dc.b    13,10,0,0

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

Msg     dc.b    'Jello World! If Bill Cosby had written the first C program. A-Z,a-z[]{}',0

        END     start


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 35 posts ]  Go to page Previous  1, 2, 3

All times are UTC


Who is online

Users browsing this forum: No registered users and 15 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