Lecture 16.

Slides:



Advertisements
Similar presentations
Computer Programming Spring-2007
Advertisements

Lecture # 12. PIC Printer Interface Printer IRQ7 INT ACK Printer Interface.
1 Homework Reading (linked from my web page) –S and S Extracts –National Semiconductor UART Data Sheet Machine Projects –mp2 due at start of class 12 Labs.
Introduction to Computer Engineering by Richard E. Haskell Multiplication and Division Instructions Module M16.4 Section 10.4.
Divisor máximo de dois inteiros. unsigned int gcd(unsigned int A, unsigned int B) { if (B > A) return gcd(B,A); else if (B==0) return A; else return gcd(B,A%B);}
Sort the given string, without using string handling functions.
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.
BY Kamran Yousaf Application of Computer Graphics and Animation Using C++ Language.
Outline  Examine some of the H/W supplied with a typical PC and consider the software required to control it.  Introduce Commkit, a software tool that.
Communication Lab - Interrupts 1/13 Sequential Programming  Our C++ programs are sequential ( סדרתיים), they start at the first instruction and end at.
BR 6/001 Ways to Handle I/O (Input/Ouput) For Output –Use Irvine16 Functions Writechar, WriteBin, WriteInt, Writehex, Writestring –Use DOS (Int 21h) Functions.
CS 450 Module R5. Next Week Reminder: R3 & R4 is due next Friday. Only one member of your group needs to be present at demonstration. If your group would.
Lecture 9. - Synchronous Devices require a timing signal. Clock generated Interval Timer Microprocessor Interval Timer Clk PCLK = MHz PCLK (for.
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.
Another Example: #include<BIOS.H> #include<DOS.H>
 Attaches itself to a program or file leaving infections as it travels.  Usually attached to an executable file (.exe)  Cannot be spread without a.
CS 450 Module R5. Next Week Reminder: R3 & R4 is due next Friday. No documentation due. You do not need to turn in a copy of your source code. Remember.
PASSING VALUE TO A FUNCTION # CALL BY VALUECALL BY VALUE # CALL BY REFERENCECALL BY REFERENCE STORAGE CLASS # AUTOAUTO # EXTERNALEXTERNAL # STATICSTATIC.
Functions available for Writing to the Video Display Three different ways to write to the display –Irvine library functions –DOS Video Functions (Interrupt.
Asynchronous Serial I/O Unit 12 - Part 1. SCI Registers – Channel 0 SCI0BDH – SCI Baud Rate Register High Byte SCI0BDL – SCI Baud Rate Register Low.
Programming the I/O Hardware Reference: –textbook: Tanenbaum ch.5.1 – s.htmlwww.cs.umb.edu/ulab/UsingCforHardwareReg.
Passing Structure to function.  structure to function structure to function  Passing structure to function in C Passing structure to function in C 
Data Structure and c K.S.Prabhu Lecturer All Deaf Educational Technology.
ECE 103 Engineering Programming Chapter 53 Generic Algorithms Herbert G. Mayer, PSU CS Status 6/4/2014 Initial content copied verbatim from ECE 103 material.
SPI Test UNIT 26 로봇 SW 교육원 조용수. 학습 목표 SPI Sample SPI Read/Write Function SPI loop back Test MPL115A1 Pressure and Temperature Sensor 2.
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:
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.
Print Row Function void PrintRow(float x[ ][4],int i) { int j; for(j=0;j
Int fact (int n) { If (n == 0) return 1; else return n * fact (n – 1); } 5 void main () { Int Sum; : Sum = fact (5); : } Factorial Program Using Recursion.
Objectives A data type is  A set of values AND  A set of operations on those values A data type is used to  Identify the type of a variable when the.
C syntax (simplified) BNF. Program ::= [ ] Directives ::= [ ] ::= | |… ::=#include > ::=#define.
C++ CODES PART#04 1 COPY ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT.
Lecture 15. Modem Controller Register 4310 DTR 0 = Polling Operator 1 = Interrupts Enabled RTS 1 =Self Test 0 =Normal.
Lecture # 14. RS – 232C Standard Standard for physical dimensions of the connectors. PC (DTE) Modem RS – 232C Cable Connected via serial port (DCE)
Computer Graphics Lecture 04 Point Taqdees A. Siddiqi
#include <dos. h> void interrupt(
CS-401 Computer Architecture & Assembly Language Programming
1st prog! Q: Read a char – from a keyboard & display it at the beginning of the next line! ====== A.
ACCEL SOFTWARE AND TECHNOLOGIES LTD.
Programming the I/O Hardware
Decisions Chapter 4.
Lecture # 13.
LESSON 3 IO, Variables and Operators
Homework Reading (linked from my web page) Machine Projects Labs
Morgan Kaufmann Publishers Computer Organization and Assembly Language
CS-401 Computer Architecture & Assembly Language Programming
Example 21H/42H: handle = open("c:\\abc.txt",O_RDONLY);
Tejalal Choudhary “C Programming from Scratch” Pointers
The slides must be understood in Lecture 5
Lecture 22.
Programming the I/O Hardware
Introduction to Programming and the C Language
توابع ورودي-خروجي.
Microprocessor and Assembly Language
Lecture 5: Interrupts in Turbo C++
Interrupt Mechanism Interrupt Compared With Procedures Call MyProc
UART Protocol Chapter 11 Sepehr Naimi
Lecture 10.
Symbolic Instruction and Addressing
Zack and A.C. Sensor Report.
unsigned char far *scr=0xb ;
Lecture 19.
Lecture # 11.
TicTacToe 過三關 使用者可按 XO X char gb[3][3]; gb[0][1] gb[0][0] gb[0][2]
Chapter 6 –Symbolic Instruction and Addressing
Lecture 17.
UNIT 26 SPI Test 로봇 SW 교육원 조용수.
Lecture 24.
Presentation transcript:

Lecture 16

Example: #include<BIOS.H> #include<DOS.H> char ch1, ch2; void initialize (int pno) { _AH=0; _AL=0x57; _DX=pno; geninterrupt(0x14); }

char receivechar (int pno) { char ch; _DX = pno; _AH = 2; geninterrupt (0x14); ch = _AL; return ch; }

void sendchar (char ch, int pno) { _DX = pno; _AH = 1; _AL = ch; geninterrupt (0x14); } unsigned int getcomstatus (int pno) unsigned int temp; _AH = 03; *((char*)(&temp)) = _AL; *(((char*)(&temp)) + 1) = _AH; return temp;

void main() { while(1) { i = getcomstatus (0); if (((*(((char*)(&i)) + 1)&0x20) == 0x20) && (kbhit())) ch1 = getche(); sendchar (ch1, 0); } if ((*(((char*)(&i)) +1) & 0x01) == 0x01) { ch2 = receivechar (0); putch (ch2); if ((ch1 == 27) || (ch2 ==27)) break;

Line Control Register 7 6 5 4 3 2 1 Word Length 0 Load THR 00 = 5 BITS Word Length 0 Load THR 1Load Divisor Value 00 = 5 BITS 01 = 6 BITS 10 = 7 BITS 11 = 8 BITS Stop Communication =1 Resume Communication =0 Length of Stop BITS 0 = one BIT 1 =1-5 for 5 bit Word Constant Parity 0 =NO constant Parity 1 =Constant Parity 0 if bit 4 =1 1 if bit 4 =0 Parity Check and generation on Parity O = odd 1 = Even.

#include <dos.h> #include <bios.h> void initialize (unsigned int far *com) { outportb ( (*com)+3, inport ((*com)+3) | 0x80); outportb ( (*com),0x80); outportb( (*com) +1, 0x01); outportb ( (*com)+3, 0x1b); } void SelfTestOn(unsigned int far * com) outportb((*com)+4,inport((*com)+4)|0x10);

void SelfTestOff(unsigned int far * com) { outportb( (*com)+4, inport((*com)+4) & 0xEf); } void writechar( char ch, unsigned int far * com) while ( !((inportb((*com)+5) & 0x20) == 0x20)); outport(*com,ch); char readchar( unsigned int far *com) while (!((inportb((*com)+5) & 0x01)==0x01)); return inportb(*com);

unsigned int far *com=(unsigned int far*) 0x00400000; void main () { char ch = 0; int i = 1;int j= 1; char ch2='A'; initialize( com); SelfTestOn(com); clrscr(); while (ch!=27) if (i==80) j++; i=0; }

if (j==13) j=0; gotoxy(i,j); ch=getche(); writechar(ch,com); ch2=readchar(com); gotoxy(i,j+14); putch(ch2); i++; } SelfTestOff (com);

hello how r u ? whats new about systems programming?

#include <dos.h> #include <bios.h> void initialize (unsigned int far *com) { outportb ( (*com)+3, inport ((*com)+3) | 0x80); outportb ( (*com),0x80); outportb( (*com) +1, 0x01); outportb ( (*com)+3, 0x1b); } void SelfTestOn(unsigned int far * com) outportb((*com)+4,inport((*com)+4)|0x18);

void SelfTestOff(unsigned int far * com) { outportb( (*com)+4, inport((*com)+4) & 0xE7); } void writechar( char ch, unsigned int far * com) //while ( !((inportb((*com)+5) & 0x20) == 0x20)); outport(*com,ch); char readchar( unsigned int far *com) //while (!((inportb((*com)+5) & 0x01)==0x01)); return inportb(*com);

unsigned int far *com=(unsigned int far*) 0x00400000; unsigned char far *scr=(unsigned char far*) 0xB8000000; int i =0,j=0;char ch;int k; void interrupt (*oldint)(); void interrupt newint(); void main () { initialize(com); SelfTestOn(com); oldint = getvect(0x0c); setvect(0x0c,newint); outport((*com)+1,1); outport(0x21,inport(0x21)&0xEF); keep(0,1000); }

void interrupt newint() { ch= readchar(com); if (i==80) j++; i=0; } if (j==13) j=0; k = i*2+(j+14)*80*2; *(scr+k)=ch; i++; outport(0x20,0x20);

C:\>DEBUG -o 3f8 41 -o 3f8 42 -o 3f8 56 -o 3f8 55 -q C:\>

#include <bios. h> #include <dos. h> void interrupt ( #include <bios.h> #include <dos.h> void interrupt (*oldint)(); void interrupt newint(); unsigned char far *scr= (unsigned char far *)0xB8000000; void initialize (unsigned int far *com) { outportb ( (*com)+3, inport ((*com)+3) | 0x80); outportb ( (*com),0x80); outportb( (*com) +1, 0x01); outportb ( (*com)+3, 0x1b); }

void main (void) { oldint = getvect(0x0C); setvect (0x0C,newint); initialize (*com); outport ((*com)+4, inport ((*com)+4) | 0x08); outport (0x21,inport (0x21)&0xEF); outport ((*com) + 1, 1); keep(0,1000); } void interrupt newint () { *scr = inport(*com); outport (0x20,0x20);