Link to home
Start Free TrialLog in
Avatar of ANGmoh
ANGmoh

asked on

8086 Programming Basics

how can i concantenate a string with a string variable by using PROMPT ?

for example , in VB

string1 ="Hello" & var_NAME

how to do that in assembly programming ?

pls give me an example . Thanks
Avatar of SunBow
SunBow
Flag of United States of America image

Try Assembly TA.

As I recall, one good approach is to have a label for two or three areas of data. Either add str1 to str3, then add str2 to str3, or, just add the one to the other (note, this is destructive of original string, so it shlould not have further use.

Define string as a row of text (bytes) beginning at a label. Each has a length, or runtime means to assess its termination.
Avatar of ANGmoh
ANGmoh

ASKER

can u please elaborate ? i cant get you ..
I haven't done much assembly lately. For label of "String1" you append the colon (":") and follow on same line or next with a reserved storage for data bytes. For simple sample or test, you can predefine the strings. That's there "where" it is in RAM. Perhaps make it 256 characters (bytes) long. Make comment on intentions.

To access each string, you place the address in an index register of choice, and find each character of string by an appropriate offset for character number, or position. An initial code attempt could be wise to use the very first reserved byte for indicating length of string, so that you know when you reach the end.  So address String1 +0 is length, and if value is zero, then it is empty string. Drawback is that when you create new string, you have to revisit the front to update length. String1 + 1 is then character in first position.

Alternative is to have a special character, such as <nul> or <cr> to indicate end of string. Thus the code continues until it finds that character.  (Later on you can get more sophisticated and make variable strings to save storage, and make heavier use of stack and indexing, don't think about that now).
Actually, we should say that there is no gurantee that any two Assembly Languages use same syntax, they only need to generate code acceptable to machine, so even operand order can be different. Here's a sample of possible string definition:

                   .Data
String1      DB       "Hello",0,"World",0      ;2 null-terminated strings
String2      DB       256 DUP (?)              ; Reserved storage for future use for strings
String3      BYTE     "Hello World",0Dh         ; <cr><lf>
             BYTE     0Ah
ASKER CERTIFIED SOLUTION
Avatar of EarthQuaker
EarthQuaker

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial