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
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 ..

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

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

Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

Question has a verified solution.

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

In this post we will learn different types of Android Layout and some basics of an Android App.
This article will show how Aten was able to supply easy management and control for Artear's video walls and wide range display configurations of their newsroom.
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 …

777 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