linux-assembly.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: newbie
  2005-12-23 16:50 newbie Niel A
@ 2005-12-23  9:11 ` Fred Marmond
  2005-12-23  9:56 ` newbie Frank Kotler
  1 sibling, 0 replies; 4+ messages in thread
From: Fred Marmond @ 2005-12-23  9:11 UTC (permalink / raw)
  To: Niel A; +Cc: linux-assembly

Hi Niel
string is a label, that's to say here, a pointer.
If you are in x86 architecture (32bits), a pointer is 32bits long, so you'll 
have to do "mov edi,string".
If you are in x86_64 arch (64bits), you'll have to use 64bits registers for 
pointers, "mov rdi,string"


Fred


Le Vendredi 23 Décembre 2005 17:50, Niel A a écrit :
> hello all!
>
> i'm taking linux assembly as a hobby for christmas 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
>
> 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.
>
> please point me to the right direction.
>
> merry christmas,
> - niel
> -
> To unsubscribe from this list: send the line "unsubscribe linux-assembly"
> in the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
-
To unsubscribe from this list: send the line "unsubscribe linux-assembly" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: newbie
  2005-12-23 16:50 newbie Niel A
  2005-12-23  9:11 ` newbie Fred Marmond
@ 2005-12-23  9:56 ` Frank Kotler
  2005-12-24 23:16   ` newbie Niel A
  1 sibling, 1 reply; 4+ messages in thread
From: Frank Kotler @ 2005-12-23  9:56 UTC (permalink / raw)
  To: Niel A; +Cc: linux-assembly

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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* newbie
@ 2005-12-23 16:50 Niel A
  2005-12-23  9:11 ` newbie Fred Marmond
  2005-12-23  9:56 ` newbie Frank Kotler
  0 siblings, 2 replies; 4+ messages in thread
From: Niel A @ 2005-12-23 16:50 UTC (permalink / raw)
  To: linux-assembly

hello all!

i'm taking linux assembly as a hobby for christmas 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

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.

please point me to the right direction.

merry christmas,
- niel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: newbie
  2005-12-23  9:56 ` newbie Frank Kotler
@ 2005-12-24 23:16   ` Niel A
  0 siblings, 0 replies; 4+ messages in thread
From: Niel A @ 2005-12-24 23:16 UTC (permalink / raw)
  To: Frank Kotler; +Cc: linux-assembly

thanks for you help and clarifications!

my learning continues! looking forward to more posts....

again, merry christmas. and thank you.

tidings,
 - niel

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2005-12-24 23:16 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-12-23 16:50 newbie Niel A
2005-12-23  9:11 ` newbie Fred Marmond
2005-12-23  9:56 ` newbie Frank Kotler
2005-12-24 23:16   ` newbie Niel A

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).