Taking a string as input and then display it in assembly 8086 - string

I know how to take single character input and string input. Also I know how to display a self-chosen string using DOS functions with INT 21h. But I was wondering about how to take a string input and display the same string.
When taking string input using:
MOV AH, 0Ah
INT 21h
Where does the string get stored? In case of a single character input and output, the character is stored in the AL register. So knowing the address of the stored string, I can load the address of it in the DX register and display it, right?
Any help is appreciated, thanks in advance...

Where does the string get stored?
The string is stored starting at the third byte of the input buffer for which you provide a pointer in DS:DX.
For a very detailed explanation, with examples you can study, see
How buffered input works
But I was wondering about how to take a string input and display the same string.
The examples in the linked post do exactly that.

For INT 21, AH=0Ah, the caller passes in the buffer in which to store the string in DS:DX.
See Ralf Brown's interrupt list for full information about using interrupts. One of many places you can find it is http://www.ctyme.com/rbrown.htm.

Related

What is happening when I declare a string as: char aString[SIZE*2+1];?

I am studying an example of a program the takes a user input, stores in a string then prints two occurrences of the corrosponding character in upper or lower case. For example, input ABCdef would print aabbccDDEEFF.
I'm a little bit confused about the way the new string is declared, can anybody help explain what is happening.
char string[MAX_STRING_SIZE+1]; // MAX_STRING_SIZE is defined as 500 and +1 is for the NULL char to terminate string
char stringNew[MAX_STRING_SIZE*2+1]; // Here I do not understand *2+1
EDIT: Just after I posted this question I figured out the answer and realised it may not be useful to the stack overflow community but as the question had already been answered it would be rude to delete it.
In the event that an other member is interested in this specific question I have attempted to make it useful by editing the question title and summarising the answer.
As this program will print 2 occurrences of every character from the user input, the new string needs to be twice the size as the original string. By declaring the new string size with *2 you are simply multiplying the size by 2 thus doubling the size.
Very simple in hindsight, I hope this can be of use to somebody else.
No pointers are involved in that declaration. You're just declaring another array of chars that is twice the size of the first one + the extra byte that'll store \0.
It can't be a pointer because there are no identifiers between the square brackets. After the preprocessor will have done its job with the source file, that expression will actually become char stringNew[500*2+1];

ASM (Gnu AS): How to split a FLOAT variable into parts?

I got a small problem: that I want to split a float variable into parts and then compute these parts (add / subtract etc.). My main problem is that I don't know how to get that splitted parts/variables from the float type variable. I want to operate on those parts using rax / eax registers and b,c,d etc.
Is there somebody who can help me to acquire some knowledge about this and eventually lead me to some code that can do the trick? One restriction of mine is: I can't operate on FPU commands.

ReadStr() and WriteStr() in Delphi

I have some code that uses ReadStr and WriteStr for what I presume is writing a string to a binary file.
The explanation for WriteStr in the documentation states that it will write raw data in the shape of an AnsiString to the object's stream, which makes sense. But then ReadStr says that it reads a character. So are they not the opposite of each other?
Let say I have,
pName: String[80];
and I use WriteStr on it, what does it actually write? Since WriteStr expects AnsiString, does it cast pName to be such? In that case, does it not write the "Length" field into the stream because an AnsiString pointer points to the first element and not the length field? I was also looking and it seems String == AnsiString these days, but my question about the length field still remains the same.
If lets say it doesn't write the Length field into the file, does it still write the NULL at the end of the data? As such, can I find where the string ends by looking for a '\0'? Does ReadStr read until the NULL character?
Thank you kindly :)
In your pre-Unicode version of Delphi, WriteStr and ReadStr write and read an AnsiString value. The writing code writes the length, and then the string content. The reading code reads the length, allocates the string, and then fills it with the content.
This has the potential of involving a truncation when you assign the result of ReadStr to your 80 character short string.

Fortran77 Casting integer to a String

Out of interest, I was trying to find a way to cast an integer to a String in Fortran77.
I came across CHAR(I), but this converts the ASCII index I into the character in that postion.
Is there a way to just simply cast an integer to a String in Fortran77?
How about vice versa?
The Fortran way is to write the value of the integer into a string variable; this operation is known as an internal write. I'm heading out the door now so won't check this, and I have an ethical objection to writing FORTRAN77 or helping anyone else write it, so make no guarantee that the following doesn't contain bits of more modern Fortran.
First declare a character variable to receive the integer
character(len=12) :: int_as_string
then write the integer into it as you would normally write an integer to any other channel such as stdout
write(int_as_string,'(i12.12)') my_int
I expect you'll want to set the format for writing the integer to something that suits you better

Converting String to DWORD (Assembly x86)

I am trying to learn how to convert a string to an integer. I think I am pretty close. My code works for numbers under 260. Once the numbers entered are greater than or equal to 260, then it just converts them to 0. I think it might have something to do with the size of a BYTE, but I'm not sure how to fix it. Any suggestions?
Some Irvine functions are included, but I'm trying to write my own ReadInt function.
I can see the problem. Rather than giving away the answer completely, here's a hint:
The lodsb instruction loads one byte into al (which is the low 8 bits of eax). The rest of eax is unchanged. What might cause eax to contain extra bits that aren't changed by lodsb?

Resources