Computer Programming Spring-2007

Slides:



Advertisements
Similar presentations
Programming 8086 – Part IV Stacks, Macros
Advertisements

Register In computer architecture, a processor register is a small amount of storage available on the CPU whose contents can be accessed more quickly than.
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.
Machine/Assembler Language Putting It All Together Noah Mendelsohn Tufts University Web:
MICROPROCESSORS TWO TYPES OF MODELS ARE USED :  PROGRAMMER’S MODEL :- THIS MODEL SHOWS FEATURES, SUCH AS INTERNAL REGISTERS, ADDRESS,DATA & CONTROL BUSES.
CEN 226: Computer Organization & Assembly Language :CSC 225 (Lec#3) By Dr. Syed Noman.
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.
Computer Organization & Assembly Language
Mouse handling Suthida Chaichomchuen
Flow Diagram: Push flags, CS, IP Pop IP,CS,flags Push AX,BX,CX,DX,ES,DS,SI,DI,BP POP BP,DI,SI,DS,ES,DX,CX,BX,AX.
Azir ALIU 1 What is an assembly language?. Azir ALIU 2 Inside the CPU.
BY Kamran Yousaf Application of Computer Graphics and Animation Using C++ Language.
SET 19 PROGRAMMING THE MOUSE. Mouse Features All mouse operations within a program are performed by standard INT 33H functions of the form: MOV AX, function.
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.
8.7 Memory management Program E Program D System memory DOS INT 21, function 48H: Allocate Memory Specification: allocates a number of memory paragraphs.
CEN 226: Computer Organization & Assembly Language :CSC 225 (Lec#8) By Dr. Syed Noman.
Lect 4: Instruction Set and Addressing Modes. 386 Instruction Set (3.4)  Basic Instruction Set : 8086/8088 instruction set  Extended Instruction Set.
Assembly Programming Timothy C. Rice Jr., MIT. OUTLINE Basic Structure Exit to Dos Print Character Clear Screen Change BG & FG Color Set Curser Location.
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.
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.
PC-technology MASM and Inline Code in C. PC-Teknik © CAAK2 MASM and Inline Code in C Some things to think about –Which size has the register you use AX,
C Tokens Identifiers Keywords Constants Operators Special symbols.
GRAPHICS AND MOUSE PROGRAMMING IN C. Turbo C has a good collection of graphics libraries. If you know the basics of C, you can easily learn graphics programming.
1 Screen and Keyboard Operations Suthida Chaichomchuen
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?
CET 3510 Microcomputer Systems Tech. Lecture 2 Professor: Dr. José M. Reyes Álamo.
Mouse Question #1 Which INT number is used for the mouse?
Module R3 Process Scheduling. Module R3 involves the creation of a simple “Round Robin” dispatcher. The successful completion of this module will require.
Video systems. Lesson plan Review the code for the previous exercise Video systems Review for midterm exam.
Writing and Reading Files Methods for processing disk files File Control Blocks (FCBs) –Supported by DOS –Can address drives and filenames.
Programming III SPRING 2015 School of Computer and Information Sciences Francisco R. Ortega, Ph.D. McKnight Fellow and GAANN Fellow LECTURE #6 Structures,
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:
COMP 1321 Digital Infrastructure Richard Henson University of Worcester October 2015.
University of Sargodha, Lahore Campus Prepared by Ali Saeed.
ROM BIOS Chapter 9. The ROM BIOS PC computer come with a set od built in routines collectively called the ROM BIOS. These routines are permanent part.
COMP 1321 Digital Infrastructure Richard Henson University of Worcester October 2012.
Computer Organization & Assembly Language University of Sargodha, Lahore Campus Prepared by Ali Saeed.
Assembly Language Lecture 2. Lecture Outline Program Structure Memory models Data Segment Stack Segment Code Segment Input and Output Instructions INT.
Computer and Information Sciences College / Computer Science Department CS 206 D Computer Organization and Assembly Language.
Riyadh Philanthropic Society For Science Prince Sultan College For Woman Dept. of Computer & Information Sciences CS 251 Introduction to Computer Organization.
Computer Organization & Assembly Language University of Sargodha, Lahore Campus Prepared by Ali Saeed.
Addressing Modes Instruction – Op-code – Operand Addressing mode indicates a way of locating data or operands. – Any instruction may belong to one or more.
Microprocessors CSE- 341 Dr. Jia Uddin Assistant Professor, CSE, BRAC University Dr. Jia Uddin, CSE, BRAC University.
Mouse Programming With “C” or “C++”
COMP 1321 Digital Infrastructure
Programming the I/O Hardware
8086 Microprocessor.
ADDRESSING MODES.
ADDRESSING MODES.
Intel 8088 (8086) Microprocessor Structure
CS-401 Computer Architecture Assembly Language Programming
9/17/2018 Kiến Trúc Máy Tính.
Symbolic Instruction and Addressing
Introduction to Assembly Language
Programming the I/O Hardware
Intel 8088 (8086) Microprocessor Structure
8086 Registers Module M14.2 Sections 9.2, 10.1.
Interrupt Mechanism Interrupt Compared With Procedures Call MyProc
Morgan Kaufmann Publishers Computer Organization and Assembly Language
Symbolic Instruction and Addressing
CS-401 Computer Architecture & Assembly Language Programming
COMP 1321 Digital Infrastructure
Symbolic Instruction and Addressing
CNET 315 Microprocessor & Assembly Language
Computer Architecture CST 250
X86 Assembly Review.
Unit-I 80386DX Architecture
COMP 1321 Digital Infrastructure
Chapter 6 –Symbolic Instruction and Addressing
Computer Architecture and System Programming Laboratory
Presentation transcript:

Computer Programming Spring-2007 Union in C language Accessing mouse in C language

Union As structures, unions are also used to group a number of different variables together. The difference between union and structure is that, structure treat each of its member as a different memory location store in the main memory. While union treat each of its member as a single memory location store in the main memory. i.e. all of the members of union shares a common memory of union member.

Union Example union searchOption { int SearchByRollNumber; char SearchByName[90]; char SearchByAddress[90]; char SearchByPhoneNumber[90]; }; searchOption sv; void main (void) int option = 0; switch (option) case 0: FunSearchRoll (sv.SearchByRollNumber); break; case 1: FunSearchName(sv.SearchByName); break; case 2: FunSearchByAddress(sv.SearchByAddress); break; case 3: FunSearchByPhone(sv.SearchByPhoneNumber); break; } } 90 Bytes

Accessing Mouse in C/C++ union REGS in,out;       void callmouse() {        in.x.ax=1;        int86(51,&in,&out); } int86 (…) is declared in the “dos.h” file, so include this file before calling the function.

Accessing Mouse in C/C++ union REGS { struct WORDREGS x; struct BYTEREGS h; } struct WORDREGS { unsigned int ax, bx, cx, dx; }; struct BYTEREGS { unsigned char al, ah, bl, bh; unsigned char cl, ch, dl, dh;

Accessing Mouse in C/C++ Interrupt Service Purpose 51 1 Show mouse pointer  Call with AX = 1   Returns: Nothing 2  Hide mouse pointer  Call with AX = 2  Returns: Nothing The various mouse functions can be accessed by setting up the AX register with different values (service number) and issuing interrupt number 51.

Accessing Mouse in C/C++ Interrupt Service Purpose 51 3 Get mouse position and button status  Call with AX = 3  Returns: BX = mouse button status  Bit   Significance   0     button not pressed   1     left button is pressed   2     right button is pressed   3     center button is pressed        CX = x coordinate  DX = y coordinate 4 Set mouse pointer position   Call with AX = 4  CX = x coordinate  DX = y coordinate  Returns: Nothing

Accessing Mouse in C/C++ Interrupt Service Purpose 51 7 Set horizontal limits for pointer  Call with AX = 7  CX = minimum x coordinate  DX = maximum x coordinate  Returns: Nothing 8 Set vertical limits for pointer  Call with AX = 8  CX = minimum y coordinate  DX = maximum y coordinate  Returns: Nothing

Setting Mouse Position      void setposi(int xpos,int ypos)       {              in.x.ax=4;              in.x.cx=xpos;              in.x.dx=ypos;              int86(51,&in,&out);       }

Receiving Mouse Position and Button Status        void mouseposi(int *xpos,int *ypos,int *click)        {               in.x.ax=3;               int86(51,&in,&out);               *click=out.x.bx;               *xpos=out.x.cx;               *ypos=out.x.dx;         }

Hiding Mouse        void mousehide()        {               in.x.ax=2;               int86(51,&in,&out);        }

Final Code void main (void ) {             int xCor,yCor,click,a,b;              a=40*8;  b=12*8;              setposi(a,b);              callmouse();              while (1)              {                     mouseposi(&xCor,&yCor,&click);                     gotoxy(10,9);                     printf("\n\tMouse Position is: %d,%d",xCor/8,yCor/8);                     printf("\n\tClick: %d",click); if ( click == 2 ) break;              }              mousehide(); }