Presentation is loading. Please wait.

Presentation is loading. Please wait.

1st prog! Q: Read a char – from a keyboard & display it at the beginning of the next line! ====== A.

Similar presentations


Presentation on theme: "1st prog! Q: Read a char – from a keyboard & display it at the beginning of the next line! ====== A."— Presentation transcript:

1 1st prog! Q: Read a char – from a keyboard & display it at the beginning of the next line! ====== A

2 Display a question mark: MOV AH, 2 ;display character fn. – p
Display a question mark: MOV AH, 2 ;display character fn. – p.456  DOS Interrupts – Function 2h  display output to standard output device I/P: AH = 02h o/p: DL = character

3 MOV DL, ‘?’ ; char is ‘?’ It moves 3Fh [‘?’] into DL INT 21h ; display character Next read a char. MOV AH, 1 ; read char fn Fn 1h  Keyboard input INT 21h ; char in AL

4 Now display the char on the next line: [the char MUST be saved in another register] MOV BL, AL ; save it in BL Why? We move the input character from AL to BL – as the INT 21h, function 2  changes AL.

5 To move the cursor to the beginning of the next line, we must execute a carriage return and line feed. So, put the ASCII codes for them in DL and execute INT 21h MOV AH, 2 ; display char fn [আগের] MOV DL, 0Dh ; for carriage return INT 21h ; execute carr ret. MOV DL, 0Ah ; for line feed INT 21h ; execute line feed

6 So full prog TITLE Echo prog .MODEL SMALL .STACK 100h .CODE MAIN PROC ; make a comment for a block MOV AH, 2 ; display char func … ; another block… ; return to DOS MOV AH, 4Ch ; DOS exit func INT 21h ; exit to DOS MAIN ENDP END MAIN

7 RUN! Create the source program file – in a word proc/text/… [*.asm file] Assemble the prog using an Assembler [*.obj file] Link object program – to link one or more obj files to create a run file [*.exe file]

8 Do/Read 4.11 Displaying a string INT 21h , Function 1  to read a single char Function 2  to display a single char Function 9  to display a string Input: DX = offset address of string The string must end with a ‘$’ char

9 LEA LEA – Load Effective Address
- puts a copy of the source offset address into the dest. LEA DX, MSG - Puts the offset address of the variable MSG into DX

10 Read 4.12 A case conversion prog. lowercase to UPPER UPPER to lover Chapter 4 – finish the exercises Chapter 5 – next


Download ppt "1st prog! Q: Read a char – from a keyboard & display it at the beginning of the next line! ====== A."

Similar presentations


Ads by Google