Please explain?

This is a discussion on Please explain? within the C Programming forums, part of the General Programming Boards category; I am studying hardware programming on this time, some of the codes which may difficult for me to understand. I ...

  1. #1
    Registered User
    Join Date
    Aug 2006
    Posts
    30

    Smile Please explain?

    I am studying hardware programming on this time, some of the codes which may difficult for me to understand. I found this code in the internet. Hope you can explain to me better.


    The following program will set the border color to blue.

    Code:
    	#include <conio.h> /* needed for outp() */
    
    	#include <stdio.h> /* needed for getchar() */
    
    	#include <dos.h> /* for REGS definition */
    
    	#define CSReg 0x3d9
    
    	#define BLUE 1
    
    	void cls()
    
    	{
    
    		union REGS regs;
    
    		regs.h.ah = 15; int86( 0x10, &regs, &regs );
    
    		regs.h.ah = 0; int86( 0x10, &regs, &regs );
    
    	}
    
    	main()
    
    	{
    
    		cls();
    
    		printf("Press any key to set border color to blue.\n");
    
    		getchar();
    
    		outp( CSReg, BLUE );
    
    	}

    This part of code which i do not understand, I think this involves assembly language. Can anyone here explain me better about this.

    Code:
    regs.h.ah = 15; int86( 0x10, &regs, &regs );
    
    		regs.h.ah = 0; int86( 0x10, &regs, &regs );

    Thanks in advance...

  2. #2
    Registered User
    Join Date
    Aug 2006
    Posts
    30
    Code:
    regs.h.ah = 15;
    int86( 0x10, &regs, &regs );
    
    regs.h.ah = 0;
    int86( 0x10, &regs, &regs );

    Are these built-in statements in C?

  3. #3
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,556
    > regs.h.ah = 15;
    regs is an instance of the REGS union.
    Its purpose is to represent all the possible values of the x86 registers.

    > int86( 0x10, &regs, &regs );
    This is just a function call, which generates an interrupt service "trap", usually to DOS (int 0x21) or the video BIOS (int 0x10).
    The two regs pointers allow you to specify all the input conditions to the interrupt (the 2nd param), and get all the results back (the 3rd param).

    These will explain more.
    http://www.ctyme.com/intr/int.htm
    http://www.cs.cmu.edu/afs/cs.cmu.edu...WWW/files.html

    > regs.h.ah = 15; int86( 0x10, &regs, &regs );
    Corresponds to
    Int 10/AH=0Fh - VIDEO - GET CURRENT VIDEO MODE

    > regs.h.ah = 0; int86( 0x10, &regs, &regs );
    Int 10/AH=00h - VIDEO - SET VIDEO MODE
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  4. #4
    Registered User
    Join Date
    Aug 2006
    Posts
    30
    Thank you so much Salem...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Can someone explain to me what this code means
    By Shadow12345 in forum C++ Programming
    Replies: 3
    Last Post: 12-22-2002, 11:36 AM
  2. Replies: 4
    Last Post: 11-19-2002, 08:18 PM
  3. explain this loop statement?
    By Unregistered in forum C Programming
    Replies: 2
    Last Post: 05-05-2002, 02:46 AM
  4. Pls explain how this program works...
    By Unregistered in forum C Programming
    Replies: 9
    Last Post: 01-05-2002, 08:53 AM
  5. Can someone explain "extern" to me?
    By valar_king in forum C++ Programming
    Replies: 3
    Last Post: 09-16-2001, 12:22 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21