Question:
What is the difference between carriage return and line feed in assembly language?
?
2016-03-31 05:03:52 UTC
Suppose we have a line “This is a test”, what is carriage return (CR)and line feed (LF) for this line ? IS carriage return enter key in keyboard? If so, what is line feed?
Three answers:
?
2016-04-05 22:03:09 UTC
Carriage return, abbreviated CR (ASCII 13, "\r" or 0Dh) and line feed, abbreviated LF (ASCII 10, "\n" or 0Ah) are characters which go back to old teletype terminals, which were basically just typewriters hooked up to a computer. Instead of a screen or display, the terminal printed out the text on a paper roll.



- A carriage return moved the carriage (which had the paper feed) back to the beginning of a line.

- A line feed advanced the paper feed by one line.



In order to start writing at the beginning of a new line, the teleprinter had to do both actions. Modern day operating systems have adapted these characters to represent line breaks ("enter" keys). But not all of them use the same sequence:



- Windows uses the combination CR LF as a line terminator ("\r\n").

- Unix / Linux and Mac OS X use just a single LF ("\n").

- Older Mac operating systems use a single CR ("\r").



Some higher level programming languages have made this less confusing by automatically doing the right thing. For example, in C a single "\n" maps to the correct sequence depending on the operating system it is compiled for.



In assembly, you should just experiment a bit by printing either 0Dh, 0Ah (Windows-style) or just plain 0Ah (*nix-style).
dday9
2016-03-31 06:21:48 UTC
Carriage return and line feed are two different constants that often get confused. Carriage return returns the caret to the beginning of the line(index 0) where as line feed will move the caret down one line.



In some operating systems such as Unix systems, all you need is the line feed constant to mimic the enter/return key. In other (much older) operating systems all you need is the carriage return constant to mimic the enter/return key. In windows operating systems you need both the carriage return and line feed constants in that order to mimic the enter/return key.



What some programming languages will incorporate, such as .NET languages, is a special property or method that will give you a new line character depending on which operating system the program is running in; this will take the guess work out of which constant or constant combinations you need to use. For the .NET languages this is the Environment.NewLine property.
anonymous
2016-03-31 05:11:43 UTC
Yes CR is the equivalent of the Enter (sometimes called Return) key - from the days of manual typewriters when the return key would physically move the carriage back to the start of the line.



LF dates back to the days of clunky printers that would print a line of text and you could send an LF signal to make it feed the paper up another line without printing anything.



Often a CR will move you to the next line with the cursor at the beginning of the new line and a LF will move you to the next line without moving the cursor.



https://www.youtube.com/watch?v=r97JHr13T98


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...