EASy68K
http://www.easy68k.com/EASy68Kforum/

Convetr to Upper Case & Arrays
http://www.easy68k.com/EASy68Kforum/viewtopic.php?f=6&t=633
Page 3 of 3

Author:  undershadow [ Thu Oct 29, 2009 11:51 pm ]
Post subject: 

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?

Author:  profkelly [ Fri Oct 30, 2009 1:14 pm ]
Post subject: 

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.

Author:  alyshaz103 [ Wed Mar 23, 2011 6:14 pm ]
Post subject: 

hey can you show me the correct version to dark's code?please and thanks

Author:  profkelly [ Wed Mar 23, 2011 7:15 pm ]
Post subject: 

No, and you are welcome. I don't do homework programs for my students or any other students on this forum.

Author:  clive [ Thu Mar 24, 2011 1:11 am ]
Post subject: 

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

Page 3 of 3 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/