flat assembler
Message board for the users of flat assembler.

Index > Main > Adding something to a variable

Author
Thread Post new topic Reply to topic
Joey



Joined: 02 Jul 2004
Posts: 4
Location: England, UK
Joey 29 Jul 2004, 12:47
I'm very new to assembler. I'm only realy learning it so i can build a compiler.

I was wondering how would add letters to a variable say i have a variable called String

String db "", 0

how would i add the result of a chracter read to this so if i read 32 into al how could i make this be

String db " ", 0

etc... so i can make it accumulate into a string??

Thanks in advance. Joey ^__^

_________________
Joey ^__^
Post 29 Jul 2004, 12:47
View user's profile Send private message MSN Messenger Reply with quote
Imagist



Joined: 13 Jun 2004
Posts: 114
Location: Pennsylvania (USA)
Imagist 29 Jul 2004, 14:28
That's why I started FASM too, but I think it is a worthwhile language on its own merit now.

As per your question, I think you need to develop a macro for that. As far as I know, there aren't any string operations.
Post 29 Jul 2004, 14:28
View user's profile Send private message Visit poster's website Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 29 Jul 2004, 18:32
joey: hardly for a newbie (i think). In high-level languages (pascal, C) you already have done libraries that do all the job for you. In asm there isn't such library (OK, there is one, in Fresh package). But I quess you want to know how is it done.

First, you need place (called "buffer") where both strings you want to "concatenate" (this is word used for this operation) will both fit. Then, you copy first string to this place, except ending 0. Then, you copy second string to the end of copied first. And then you have new string in your buffer (so now you can't use label "String" to acces it, you must use address of that buffer).

Anyway, string manipulation is one of hardest things in assembly, it is better to start with something other.
I think you will comprehend much by reading (carefully) something from my tutorials
http://board.flatassembler.net/topic.php?t=1178
Post 29 Jul 2004, 18:32
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
Joey



Joined: 02 Jul 2004
Posts: 4
Location: England, UK
Joey 29 Jul 2004, 23:26
Ah bummer Razz i thought it might be quite a hard task. makes me appreciate my pascal compiler a little more now Smile didnt think building a BASIC compiler would involve so much ASM but i was wrong Razz heehee. Got alot of learning todo.

Your tutorials great Smile i understand most stuff on there Very Happy just need to get a realy understanding tho Smile
Post 29 Jul 2004, 23:26
View user's profile Send private message MSN Messenger Reply with quote
BlueOwl



Joined: 02 May 2004
Posts: 14
BlueOwl 30 Jul 2004, 17:26
> would involve so much ASM

When you compile a program, all is translated to binary (ASM) Smile.
Post 30 Jul 2004, 17:26
View user's profile Send private message Reply with quote
VitalOne



Joined: 29 Jul 2003
Posts: 54
Location: USA
VitalOne 31 Jul 2004, 05:57
Joey wrote:
I'm very new to assembler. I'm only realy learning it so i can build a compiler.

I was wondering how would add letters to a variable say i have a variable called String

String db "", 0

how would i add the result of a chracter read to this so if i read 32 into al how could i make this be

String db " ", 0

etc... so i can make it accumulate into a string??

Thanks in advance. Joey ^__^


Well, you need to allocate the number of bytes you want the string to be, then you simply add the character(s) on to the string, which would just be replacing the zeros allocated into memory. But for your situation, you aren't actually adding at all, you're just replacing the first byte with 32. To allocate, you can either use GlobalAlloc (which is simpler) or VirtualAlloc (which supports addresses). You should probably make a proc to do it for you everytime you add.
Post 31 Jul 2004, 05:57
View user's profile Send private message AIM Address Yahoo Messenger Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
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 vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.