The MASM Forum

General => The Campus => Topic started by: deeR44 on September 03, 2022, 02:32:38 PM

Title: Alter a memory character
Post by: deeR44 on September 03, 2022, 02:32:38 PM
Quotemov     esi, OFFSET input_buffer ; get address of line
  ;  and     [esi], 05fh        ; this instruction is invalid--doesn't work
  ;  jmp     next1
    mov     al, [esi]           ; get a char--these three get the job done
    and     al, 05fh            ; force to uppercase if it isn't
    mov     [esi], al           ; return adjusted character

next1:
I guess one can't homogenize a memory byte the first way above.
Title: Re: Alter a memory character
Post by: NoCforMe on September 03, 2022, 02:36:22 PM
Quote from: deeR44 on September 03, 2022, 02:32:38 PM
I guess one can't homogenize a memory byte the first way above.

This will definitely work:

    mov     esi, OFFSET input_buffer ; get address of line
    and     BYTE PTR [esi], 05fh        ; this instruction is valid--will work


assuming it's a byte you want to bite. You can also do a word or dword if you like.

Your statement was ambiguous, so the poor assembler couldn't figure out what you wanted to do.

You're uppercasing characters here, right?

BTW, before you indiscriminately AND everything with 5Fh, you might want to check to see if the character is in the range "a ... z".
Title: Re: Alter a memory character
Post by: deeR44 on September 03, 2022, 02:39:11 PM
Thank you NoCforMe!

I don't think that this is the first assembler that I've come across that's smarter than I am.
Title: Re: Alter a memory character
Post by: NoCforMe on September 03, 2022, 02:40:10 PM
Ackshooly, the problem is that it's dumber than you are. Can't read our minds, yet.

(I'm still waiting for the mythical DWIM program: Do What I Mean.)
Title: Re: Alter a memory character
Post by: hutch-- on September 04, 2022, 12:03:05 AM
David,

You would have to be a MAC user to wish for that.  :tongue:
Title: Re: Alter a memory character
Post by: NoCforMe on September 04, 2022, 05:04:43 AM
Heh; yeah, they're the ones who can't wait for the cerebral-cortex implant interface. Apple fanbois (and -gurls).