How To Print New Line in Assembly Language emu8086


There are several method for printing new line in assembly Language. We will discuss about the most used one

First of all we need to declare a variable that holds the value of new line character. Then we need to keep this value in DX register and call interrupt. Have a look on the code. Here we are print character A first, then a new line and the printing character B. We know that, we have to put our value in DL register first if we want to print a single character. And then we have to call an interrupt. That's what we are doing here. But to print new line we have to keep the value of new line character in our DX register. For moving values in DX register we used LEA command here which means least effective address. After that we are calling an interrupt which prints the new line. That's it, now look at the full code, hope you will understand it.
.MODEL SMALL

.STACK 100h

.DATA       

   n_line DB 0AH,0DH,"$"   ;for new line


.CODE

    MAIN PROC

        MOV AX,@DATA

        MOV DS,AX


        MOV DL,'A'

        MOV AH,2

        INT 21H        ;print 'A'

       

        LEA DX,n_line ;lea means least effective address

        MOV AH,9

        INT 21H       ;print new line

       

        MOV DL,'B'

        MOV AH,2

        INT 21H        ;print 'B'

  MAIN ENDP

END MAIN

I can develop a simple game for you in python

There is also a built in method for printing a new line.



Put include'emu8086.inc' in the top of the code. Then use 'printn' where you need
to print new line.

Comments

  1. Is there a new line character to put in a string??
    I have this string, and i want a new line character for it:
    ext_string db "part1 new line character part 2", 0

    ReplyDelete
  2. Casinos In Dubai - Airport Review & Hotels - Air
    Book jordan 18 white royal blue online free shipping a Flight or Flight On Airfare & Book 배당 토토 Direct In air jordan 18 retro varsity red to my site Dubai website to buy air jordan 18 retro racer blue (Tif) with Airjet Radar, Free Shipping or Book Direct Direct great air jordan 18 retro racer blue On Airfare and Book Direct In Dubai.

    ReplyDelete

Post a Comment

Popular posts from this blog

How to Declare array in Assembly languages emu8086

Simple Input and output in assembly Language EMU8086