1 / 12

Microprocessor

Microprocessor. 1 st prog!. Q: Read a char – from a keyboard & display it at the beginning of the next line! ====== A A. 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

Download Presentation

Microprocessor

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Microprocessor

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

  3. 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

  4. 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

  5. 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.

  6. 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

  7. 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 MAINENDP END MAIN

  8. 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]

  9. 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

  10. 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

  11. Read 4.12 A case conversion prog. lowercase to UPPER UPPER to lover

  12. Chapter 4 – finish the exercises Chapter 5 – next

More Related