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

Slides:



Advertisements
Similar presentations
Program.-(9)* Write a program Input two numbers from keyboard and multiply of given values using by variables. Input value No 1 input value No2 Multiply.
Advertisements

Program.(08) Write a program Divide 5 by 2 and display answer value and remainder value. 1 Store 5 into AL 2 Store BL into 2 3Divide AL Into BL 4Store.
DOS and BIOS Interrupts DOS and BIOS interrupts are used to perform some very useful functions, such as displaying data to the monitor, reading data from.
Assembly Language for x86 Processors 6th Edition Chapter 5: Procedures (c) Pearson Education, All rights reserved. You may modify and copy this slide.
10-1 ECE 424 Design of Microprocessor-Based Systems Haibo Wang ECE Department Southern Illinois University Carbondale, IL Subroutine and Interrupt.
More about procedures and Video Processing. Lesson plan Review existing concepts More about procedures and boolean expression Video processing.
CEN 226: Computer Organization & Assembly Language :CSC 225 (Lec#4)
Chapter 7 Programming with DOS and BIOS Function Calls Objectives: The use of DOS and BIOS function call How to read the PC’s keyboard How to send text.
Kip Irvine: Assembly Language for Intel-Based Computers Overview Stack Operations (PUSH and POP) Procedures Procedure Parameters Software Interrupts MS-DOS.
Kip Irvine: Assembly Language for Intel-Based Computers
8.4 Instruction Execution Times TOBIN PROC FAR SUB AX,AX MOV DX,AX MOV CX,4 NEXTD: PUSH CX SUB BP,BP MOV CX,4 GETNUM: RCL BX,1 RCL BP,1 LOOP GETNUM.
CEN 226: Computer Organization & Assembly Language :CSC 225 (Lec#8) By Dr. Syed Noman.
Program.-(4)* Write a program for input two integer number with message and display their sum. Algorithm steps Algorithm steps 1.Display message for input.
CEN 226: Computer Organization & Assembly Language :CSC 225 (Lec#6)
Assembly Programming Timothy C. Rice Jr., MIT. OUTLINE Basic Structure Exit to Dos Print Character Clear Screen Change BG & FG Color Set Curser Location.
ICS312 Set 4 Program Structure. Outline for a SMALL Model Program Note the quiz at the next lecture will be to reproduce this slide.MODEL SMALL.586 ;
Lab 5 Part C Write to the screen a character string that uses a ‘$’ to indicate the end of the string. Do not write the ‘$’ to the screen. Use DOS Interrupt.
Assembly Language for Intel-Based Computers, 4 th Edition Chapter 3: Assembly Language Fundamentals Assembling, Linking and Running Programs Example Programs.
Introduction to Subroutines. All the combinations in which a subroutine can be written 1. The subroutine may be: a. Internal or b. External 2. The type.
BIOS1 Basic Input Output System BIOS BIOS refers to a set of procedures or functions that enable the programmer have access to the hardware of the computer.
1/2002JNM1 Positional Notation (Hex Digits). 1/2002JNM2 Problem The 8086 has a 20-bit address bus. Therefore, it can access 1,048,576 bytes of memory.
Riyadh Philanthropic Society For Science Prince Sultan College For Woman Dept. of Computer & Information Sciences CS 251 Introduction to Computer Organization.
BIOS and DOS Programming in DOS INT 10 and 21H. Interrupts There are some extremely useful subroutines within BIOS or DOS that are available to the user.
1 Screen and Keyboard Operations Suthida Chaichomchuen
1 Chapter 5: Procedures and Interrupts Assembly Language for Intel-Based Computers, Kip R. Irvine 3rd edition 3/17/2000.
Multiplication and Division Instructions & the 0Ah function.
Text-Mode Programming Question #1 What are the three levels of access to the video display when writing characters on the screen in text mode?
“It was the night before midterm”. Midterm rule (March 16 nd, 2005) - Student ID is required. Open books, note exam - Don’t: - Leave the exam room after.
Strings, Procedures and Macros
Binary Number Output To display a number in binary format, a program looks at each bit in the number and sends the ASCII equivalent of a ‘1’ (31h) or a.
Mid-term Exam Basics & intuitive All materials till-to-date – very simple! Ref. book – Assembly Language Programming and Organization of the IBM PC, by.
Video systems. Lesson plan Review the code for the previous exercise Video systems Review for midterm exam.
21/11/2005CAP2411 Input & Output Instructions CPU communicates with the peripherals through I/O registers called I/O ports. There are 2 instructions, IN.
Software Interrupt Instruction ‘int’ A ‘int’ instruction is like a special kind of subroutine call. Will discuss details later ‘int’ stands for INTERRUPT.
10H Interrupt. Option 0H – Sets video mode. Registers used: – AH = 0H – AL = Video Mode. 3H - CGA Color text of 80X25 7H - Monochrome text of 80X25 Ex:
In Class Program Write, assemble and test a program: –Use the DB directive to define the following list of numbers and name it array: 31h, 32h, 33h, 34h.
ICS 312 SET 10 Multiplication & Division & input using function 0Ah.
Assembly Language for Intel-Based Computers, 4 th Edition Chapter 13: 16-Bit MS-DOS Programming Interrupts (c) Pearson Education, All rights reserved.
Assembly Language Lecture 2. Lecture Outline Program Structure Memory models Data Segment Stack Segment Code Segment Input and Output Instructions INT.
File Operations. FILE PROCESSING For the purposes of the following discussion, reading means copying all or part of an existing file into memory Writing.
Program Structure Example for Data Segment CRLF EQU 0DH, 0AH PROMPT DB 'Enter a digit between 0 and 9', 0 VAR1 DB ? ARRAY DW 1234h, 23h, 0FF54h.
Additional Assembly Programming Concepts
Microprocessor and Assembly Language
Microprocessor Systems Design I
Lecture 4 Control Flow Structures (LOOPS)
Microprocessor and Assembly Language
Computer Organization & Assembly Language
Microprocessor & Interfacing
(The Stack and Procedures)
Defining Types of data expression Dn [name] expression Dn [name]
Symbolic Instruction and Addressing
BIC 10503: COMPUTER ARCHITECTURE
Stack and Subroutines Module M17.1 Section 11.2.
8086 Registers Module M14.2 Sections 9.2, 10.1.
Microprocessor Lab CSL1543 0:0:2
Morgan Kaufmann Publishers Computer Organization and Assembly Language
Symbolic Instruction and Addressing
Chương 4: Lập trình hợp ngữ
(The Stack and Procedures)
Microprocessor Lab CSL1543 0:0:2
Symbolic Instruction and Addressing
Morgan Kaufmann Publishers Computer Organization and Assembly Language
Unit:08 Software Interrupts
Assembler Directives end label end of program, label is entry point
UNIT-II Assembly Language Programs Involving Logical
Chapter 6 –Symbolic Instruction and Addressing
(The Stack and Procedures)
Jump & Loop instructions
By Nasser Halasa Assembly Language.
Microprocessor and Assembly Language
Presentation transcript:

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

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

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

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.

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

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

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]

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

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

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