More about procedures and Video Processing. Lesson plan Review existing concepts More about procedures and boolean expression Video processing.

Slides:



Advertisements
Similar presentations
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.
Advertisements

There are two types of addressing schemes:
Assembly Programming Notes for Practical2 Munaf Sheikh
ICS312 Set 6 Operands. Basic Operand Types (1) Register Operands. An operand that refers to a register. MOV AX, BX ; moves contents of register BX to.
Subroutines: Passing Arguments Using the Stack. Passing Arguments via the Stack Arguments to a subroutine are pushed onto the stack. The subroutine accesses.
Video systems (continue). Practice Modify the program to get a string from a keyboard to display the input string on the middle of the screen with reverse.
8086 Assembly Language Programming I
CEN 226: Computer Organization & Assembly Language :CSC 225 (Lec#4)
Direct video practice and Keyboard Operations
Assembly Language for Intel-Based Computers Chapter 15: BIOS-Level Programming (c) Pearson Education, All rights reserved. You may modify and.
CS2422 Assembly Language & System Programming November 2, 2006.
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.
Factorial of a number data segment x1 db 4 fact dw ? data ends
Assembly Language – Lab 5
Assembly Programming Timothy C. Rice Jr., MIT. OUTLINE Basic Structure Exit to Dos Print Character Clear Screen Change BG & FG Color Set Curser Location.
Fundamentals of Assembly language
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 ;
ORG ; FOUR INT 21H and INT 10H Programming and Macros Dec Hex Bin
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.
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
Chapter 3 Examining Computer Memory and Executing Instructions.
1 Chapter 5: Procedures and Interrupts Assembly Language for Intel-Based Computers, Kip R. Irvine 3rd edition 3/17/2000.
Chapter 2 Instruction Addressing and Execution. Lesson plan Review some concepts in the first week First assembly program with EMU8086 Related concepts.
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?
Strings, Procedures and Macros
Lecture 7 A closer look at procedures Dr. Dimitrios S. Nikolopoulos CSL/UIUC.
Executing and Linking an assembly program. Lesson plan Review Program logic and control Practice exercise Assembling, Linking and Executing Programs Practice.
UHD:CS2401: A. Berrached1 The Intel x86 Hardware Organization.
Video systems. Lesson plan Review the code for the previous exercise Video systems Review for midterm exam.
Writing and using procedures
21/11/2005CAP2411 Input & Output Instructions CPU communicates with the peripherals through I/O registers called I/O ports. There are 2 instructions, IN.
Processing String Data and Binary Data (continue)
Click to add Title Comunicación y Gerencia Click To add Subtitle Click to add Text Fundamentals of Assembly Language.
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:
String Instructions String instructions were designed to operate on large data structures. The SI and DI registers are used as pointers to the data structures.
Assembly Programming Notes for Practical 1
Microprocessors used in Personal Computers. The Memory Map of a Personal Computers Transient Program Area (TPA): Holds the operating system (interrupt.
Review of Assembly language. Recalling main concepts.
Microprocessors Monday, Apr. 16 Dr. Asmaa Farouk Faculty of Engineering, Electrical Department, Assiut University.
Calling Procedures C calling conventions. Outline Procedures Procedure call mechanism Passing parameters Local variable storage C-Style procedures Recursion.
Assembly Language Lecture 2. Lecture Outline Program Structure Memory models Data Segment Stack Segment Code Segment Input and Output Instructions INT.
Internal Programming Architecture or Model
BITS Pilani Pilani Campus Pawan Sharma Lecture /12/ EEE /INSTR/CS F241 ES C263 Microprocessor Programming and Interfacing.
File Operations. FILE PROCESSING For the purposes of the following discussion, reading means copying all or part of an existing file into memory Writing.
Chapter 5: Procedures and Interrupts
ECE291 Computer Engineering II Lecture 12 Josh Potts University of Illinois at Urbana- Champaign.
Assembly language programming
Format of Assembly language
1st prog! Q: Read a char – from a keyboard & display it at the beginning of the next line! ====== A.
Microprocessor and Assembly Language
Additional Assembly Programming Concepts
Microprocessor and Assembly Language
(The Stack and Procedures)
Microprocessor and Assembly Language
BIC 10503: COMPUTER ARCHITECTURE
Stack and Subroutines Module M17.1 Section 11.2.
8086 Registers Module M14.2 Sections 9.2, 10.1.
اصول اساسی برنامه نویسی به زبان اسمبلی
Symbolic Instruction and Addressing
(The Stack and Procedures)
Symbolic Instruction and Addressing
Unit:08 Software Interrupts
Chapter 6 –Symbolic Instruction and Addressing
(The Stack and Procedures)
By Nasser Halasa Assembly Language.
Presentation transcript:

More about procedures and Video Processing

Lesson plan Review existing concepts More about procedures and boolean expression Video processing

Review Procedure: name PROC ; the code of the procedure... RET name ENDP Calling a procedure: CALL Address of the next instruction will be pushed onto STACK

More about procedures Passing parameters: –Are very similar to the concept of passing parameters in C/C++ and Java –A program may pass parameters by: Value Reference

Passing parameters by value: –Parameters are the actual data item. Passing value in register: -Store values being passed in registers -Call the procedure Example: MOV AX, operand1 MOV BX, operand2 CALL MULTIPROC … MULTIPROCPROC MUL BX RET MULTIPROCENDP MULTIPROC(operand1,operand2

Passing parameters by value: Passing value in STACK -Push values being passed in STACK -Call the procedure -Pop values from STACK Example: PUSH operand1 PUSH operand2 CALL MULTIPROC … MULTIPROCPROC PUSH BP MOV BP, SP MOV AX, [BP+8] MUL WORD PTR [BP+4] POP BP RET MULTIPROCENDP MULTIPROC(operand1,operand)

Passing parameters by value: Passing value in STACK: Address the limitations in terms of number of registers More complicated because we need indirect addressing to access the stack (use of BP)

Passing parameters by value: Operand1 DW 10 ; (0AH) Operand2 DW 2 ; (02H) PUSH BP ;to save its content

Passing parameters by Reference Instead of passing values, we pass the address using register or stack LEA SI, operand1 LEA DI, operand2 CALL MULTIPROC MULTIPROCPROC MOV AX, [SI] MUL [DI] RET MULTIPROCENDP MULTIPROC(&operand1, &operand2)

Passing parameters by Reference Instead of passing values, we pass the address using register or stack PUSH OFFSET operand1 PUSH OFFSET operand2 CALL MULTIPROC …… MULTIPROCPROC PUSH BP MOV BP, SP MOV BX, [BP+6] MOV DI,[BP+4] MOV AX, [BX] MUL WORD PTR [DI] POP BP RET 4 MULTIPROCENDP MULTIPROC(&operand1, &operand2)

Video processing Use INT instruction to handle inputs and outputs INT 10H: screen handling INT 21H: for displaying screen output Main idea: –Insert a value in AH register which is used to identify the type of service the interrupt needs to perform

Screen features 25 rows (0-24) and 80 columns (0-79) (0,79) (0,0) (24,0)(24,79)

Screen features Cursor location: Upper left corner: Row: 0, Column 0 Upper right corner: Row: 0, Column 79 Lower left corner: Row: 24, Column 0 Lower right corner: Row: 24, Column 79 Center:Row 12, Column 39

Screen features Video Display Area: Text mode: 4KB in BIOS (2K for characters and 2K for attributes) Pages: 0 to 7 INT 10H: Set cursor (AH= 02H) INT 10H: Clear & Scroll screen (AH = 06H)

Screen features Setting cursor: INT 10H function 02H tells BIOS to set the cursor Step 1: Determine the row and column that we want to set our cursor at. E.g row = 12, column = 40) Step 2: Load 02H to AH. Load page# to BH, Row# to DH, and Column# to DL Step 3: Call INT 10H function

Screen features Example: Set cursor at (12,40) MOV AH, 02H MOV BH, 0 ; page# to BH MOV DH, 12; row# to DH MOV DL, 40; column# to DL INT 10H

Screen features Clear & Scrolling screen INT 10H function 06H tells BIOS to clear or scroll screen –Step 1: Load 06H to AH –Step 2:Determine number of lines to scroll –Step 3:Determine the attributes of the screen (background and foreground colors). Load them into BH –Step 4: Load the starting row:column to CX –Step 5: Load the ending row:column to DX –Step 6: Call INT 10H

Screen features Example: MOV AH,06H ; clear and scroll MOV AL,00H MOV BH,0F1H ; white background, blue foreground MOV CX,0000H ; starting row:column MOV DX,184FH ; ending row:column INT 10H

Screen features –Attribute byte in text mode determines the characteristics of each displayed character 71= (White background and Blue foreground)

Screen features INT 21H: Display ASCII characters (02H) Display string (09H or 40H) Get input from keyboard (0AH or 3FH)

Screen features Display a character –Step 1: Set AH =02H –Step 2: Load the character to DL –Step 3: Call INT 21H to display the character

Screen features Example: MOV AH, 02H MOV DL, ‘C’ INT 21H

Practice/Lab 1 1.Open your browser and open this page: C:\emu8086\documentation\8086_instruction_set.html And C:\emu8086\documentation\8086_and_dos_interrupts. html 2. Open your emu8086 software 3. Cut and paste (or type) the following code (as shown in the next page) and save as output.asm

Practice/Lab 1 page 60,132 TITLEVideoPracticeClearScreen and Output ; STACKSEGMENT PARA STACK 'Stack' DW 32 DUP(0) STACKENDS ; DATASEGSEGMENT PARA 'Data' ; Please insert your data declaration here DATASEGENDS CODESEG SEGMENT PARA 'Code' MAINPROC FAR MOV AX, dataseg MOV DS, AX ; Please enter your code here MOV AX,4C00H ;exit procedure INT 21H MAIN ENDP CODESEG ENDS END MAIN;End of program

Practice/Lab 1 4. Modify your code so that it performs the following tasks: Clear screen Set cursor to the middle of screen Display the characters (5) in: CHAR_TBL DB ‘A’,’B’, ’C’, ’D’, ’E’ on the middle of the screen 5. Compile and run your code

Answer to Fibonaci practice FIBONACI PROC NEAR MOVAX,00 MOVBX,01 MOVCX,7;7 repetitions MOVDX,00 L10: ADDAX,BX;Number is in AX MOVBX,DX MOVDX,AX LOOPL10 RET FIBONACI ENDP

INT 21H displaying screen INT 21H, function 09H: display a string which is followed by the dollar($) sign –Step 1: Declare a string, which is followed by dollar sign –Step 2: Set DS to the beginning address of data segment. And set AH =09H –Step 3: Load offset of the string to DX –Step 4: Call INT 21H

INT 21H displaying screen Example: message db "Hello everybody! I am learning assembly language!","$“ mov ah,09 ; move 9 to AH lea dx,message int 21h

INT 21H displaying screen INT 21H, function 40H –Use file handles to process display operations –Procedure: Step 1: Set AH=40H Step 2: Set BX= file handle (of screen) Step 3: Set CX = number of characters to display Step 4: Set DX = Offset Address of display area Step 5: Call INT 21H

INT 21H displaying screen –File handle: is a number used to refer to a specific device HandleDevice 00Input (keyboard) 01 Output (screen) 04Printer

INT 21H displaying screen –Example: message db ‘Hello’, 0DH, 0AH MOV AH,40H ; move 40H to AH MOV BX, 01 MOV CX, 7 lea dx,message int 21h

INT 21H for keyboards INT 21H function: –0AH: input from keyboard –3FH: input from keyboard

INT 21H for keyboards INT 21H function 0AH –Step 1:Set AH = 0AH –Step 2: Load offset address of the parameter list into DX –Step 3: Call INT 21H

INT 21H for keyboards Parameter list is a structure which consists of: LABEL BYTE DB

INT 21H for keyboards Example: Para_list label byte max_len DB 100 act_lenDB ? input DB 100 DUP(‘ ‘) MOV AH, 0AH LEA DX, Para_list INT 21H

INT 21H for keyboards Example: Assume the input string is ‘CS271’ act_len = 5 input:CS271$ ‘ ‘ ‘ ‘ ‘ ‘ ‘ ‘ MOV BH, 00 MOV BL, ACT_LEN MOV INPUT[BX],’$’ CS271$

This uses file handles to request keyboard input –Step 1: Set AH = 3FH –Step 2: Set BX=00H (file handle 00 represents keyboard) –Step 3: Set CX = maximum number of character to accept –Step 4: Load offset address of area for entering characters to DX INT 21H function 3F

Example: input DB 100 DUP(‘ ‘) MOV AH, 3FH MOV BX, 00H MOV CX, 100 LEA DX, input INT 21H INT 21H function 3F

Example: (not available in EMU8086) input DB 100 DUP(‘ ‘) MOV AH, 3FH MOV BX, 00H MOV CX, 100 LEA DX, input INT 21H INT 21H function 3F

Practice/Lab 2 1.Open your browser and open this page: C:\emu8086\documentation\8086_instruction_set.html And C:\emu8086\documentation\8086_and_dos_interrupts. html 2. Open your emu8086 software 3. Cut and paste (or type) the following code (as shown in the next page) and save as input.asm

Practice/Lab page 60,132 TITLEInputPRactice Input ; STACKSEGMENT PARA STACK 'Stack' DW 32 DUP(0) STACKENDS ; DATASEGSEGMENT PARA 'Data' ; Please insert your data declaration here DATASEGENDS CODESEG SEGMENT PARA 'Code' MAINPROC FAR MOV AX, dataseg MOV DS, AX ; Please enter your code here MOV AX,4C00H ;exit procedure INT 21H MAIN ENDP CODESEG ENDS END MAIN;End of program

Practice/Lab 4. Modify your code so that it performs the following tasks: - Read a string (length <= 50) from keyboard. You need to insert the following into your data declaration Para_list label byte max_len DB act_lenDB ? input DB DUP(‘ ‘) - Display the string on the screen at (12,40) 5. Compile and run your code

Project 2

Adavanced Screen Processing Explore INT 10H to: –Set video mode –Display attribute or character at cursor position