linux-assembly.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Frank Kotler <fbkotler@comcast.net>
To: Niel A <amerei@gmail.com>
Cc: linux-assembly@vger.kernel.org
Subject: Re: newbie
Date: Fri, 23 Dec 2005 04:56:48 -0500	[thread overview]
Message-ID: <43ABC9E0.3010409@comcast.net> (raw)
In-Reply-To: <20051223165014.3a1db406.amerei@gmail.com>

Niel A wrote:
> hello all!
> 
> i'm taking linux assembly as a hobby for christmas

... and for New Year you're doing micro-code? :)

> and i found your great site. the tutorials have been much helpful.
> 
> anyway, i meant to ask something.. 
> 
> section .data
> 	string: db "hi!",10
> 
> and i wanna capitalize the small letter 'h'.
> 
> at first i used
> 	mov di, string ; but di is 16 bits and ld complains

Right. As Fred explains, an address is 32 bits (or 64).

> so i eventually started using the 32 bit ones to do the capitalisation operation. but for some reason, i lose all other letters, including the linefeed.

Sounds like maybe you went too far. The address is 32 bits (or 64), but 
the characters of the string are only a byte (8 bits). If you tried to 
"uppercase" a whole 32 bits, you'd lose the whole thing, including the 
linefeed.

> please point me to the right direction.

Easy way:

sub byte [string], 32

maybe you'd write it as:

sub byte [string], 'a' - 'A'

to make it more "self-documenting". But a more flexible way, using some 
registers...

mov edi, string
mov al, [edi]
cmp al, 'a'  ; don't "uppercase" it unless
jb skip      ; it's lower case!
cmp al, 'z'
ja skip
sub al, 'a' - 'A'
mov [edi], al  ; store it back in "string"
skip:

...perhaps "inc edi", and loop back do do the next letter, or whatever...

inc edi
mov byte [edi], 'a'  ; change it to "Ha!"

Have fun.

> merry christmas,

Same to you and yours... and the rest of the list.

Best,
Frank


  parent reply	other threads:[~2005-12-23  9:56 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-12-23 16:50 newbie Niel A
2005-12-23  9:11 ` newbie Fred Marmond
2005-12-23  9:56 ` Frank Kotler [this message]
2005-12-24 23:16   ` newbie Niel A

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=43ABC9E0.3010409@comcast.net \
    --to=fbkotler@comcast.net \
    --cc=amerei@gmail.com \
    --cc=linux-assembly@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).