Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


8086 Programming Basics

Posted on 2003-03-31
Medium Priority
Last Modified: 2013-12-13
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
Question by:ANGmoh
  • 5
LVL 24

Expert Comment

ID: 8241942
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.

Author Comment

ID: 8243030
can u please elaborate ? i cant get you ..
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

LVL 24

Expert Comment

ID: 8247575
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).
LVL 24

Expert Comment

ID: 8247716
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:

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
LVL 24

Expert Comment

ID: 8284949

Accepted Solution

EarthQuaker earned 60 total points
ID: 8370192
In assembly, strings are like C-strings : an array of character (byte) which ends with value 0 ( '\0' ).

Here is an example of how you may want to fill a char array, 1st statement is in C then in ASM.

x[0] = 'H';
mov     BYTE PTR _x$[ebp], 72    ;value 72 stands for H

x[1] = 'e';
mov     BYTE PTR _x$[ebp+1], 101     ;value 101 stands for e

x[2] = 'l';
mov     BYTE PTR _x$[ebp+2], 108

x[3] = 'l';
mov     BYTE PTR _x$[ebp+3], 108

x[4] = 'o';
mov     BYTE PTR _x$[ebp+4], 111

x[5] = ' ';
mov     BYTE PTR _x$[ebp+5], 32

x[6] = 'W';
mov     BYTE PTR _x$[ebp+6], 87    

x[7] = 'o';
mov     BYTE PTR _x$[ebp+7], 111

x[8] = 'r';
mov     BYTE PTR _x$[ebp+8], 114

x[9] = 'l';
mov     BYTE PTR _x$[ebp+9], 108

x[10] = '\0';     ;this tells the string ends here
mov     BYTE PTR _x$[ebp+10], 0

Then to concatenate, ecrase the ending '\0' with the ascii value you want, continue filling the array, don't forget to end it with another 0 value.

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
If you are a mobile app developer and especially develop hybrid mobile apps then these 4 mistakes you must avoid for hybrid app development to be the more genuine app developer.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

577 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question