Thread: How to interface with and change VDU

  1. #1
    Registered User zolfaghar's Avatar
    Join Date
    Mar 2016
    Posts
    95

    How to interface with and change VDU

    Enclosed, is a question I got from let us c. I attached it as a file so I can share the question itself. I want to ask if I can attempt this on a Linux machine as this book was written for Turbo C I believe. Also the answer has some things I have not seen before, and I wanted to discuss it in a way that allows me understand the problem and perhaps write my version of the code, which accomplishes the same thing. I am trying to do these on an Ubuntu machine with gcc. So below is the code with my questions posted as comments:

    Code:
    #include <stdio.h>
    int main()
    {
      char far *scr = 0xB8000000; // What is a far pointer? 
      // Is the value 0xB8000000 the same for my environment? 
    
      int i; 
    
      while (!kbhit()) // The original answer uses the dos.h, which I do not have
      // Is there some other header file I can use to accomplish the same? 
      {
        for (i=0; i<4000; i+=2)
        if (scr[i] >='A' && scr[i] <= 'Z') 
        {
          scr[i] += 32;
        }
        else 
        {
          if (scr[i] >='a' && scr[i] <='z')
          scr[i] -= 32;
        }
      }
      }
    }
    Attached Images Attached Images

  2. #2
    Registered User
    Join Date
    Oct 2006
    Posts
    3,445
    If you attempt this on a Linux machine, the program will almost certainly crash. This program was written for DOS, which is a completely different operating system. You need to throw out that outdated book, and get one that teaches modern C for modern systems. There is a thread on this forum just for book suggestions.
    What can this strange device be?
    When I touch it, it gives forth a sound
    It's got wires that vibrate and give music
    What can this thing be that I found?

  3. #3
    Registered User rstanley's Avatar
    Join Date
    Jun 2014
    Location
    New York, NY
    Posts
    668
    The code was written for a 16 bit DOS or Windows computer. "far" pointers do not exist in 32 and 64 bit computers.

    Do not us any conio functions. These are specific to Windows compilers, and are non-standard C.

    "dos.h" is also specific to DOS and Windows compilers.

  4. #4
    Registered User zolfaghar's Avatar
    Join Date
    Mar 2016
    Posts
    95
    Quote Originally Posted by rstanley View Post
    The code was written for a 16 bit DOS or Windows computer. "far" pointers do not exist in 32 and 64 bit computers.

    Do not us any conio functions. These are specific to Windows compilers, and are non-standard C.

    "dos.h" is also specific to DOS and Windows compilers.
    Thanks. I feel I am stuck; if I switch books now, I would have to decide if I skip some chapters, or waist time which I do not have re-reading some redundant content. I did pick up a couple of really good books based on the latest C specifications like " 21st century C" and "Problem Solving and Program Design in C". I have read eight chapters of this book. I don't know if continuing with this book will benefit me though if I can not validate what the book tries to teach by writing my own code. Let me know what you think. I'll have a look at the thread mentioned earlier about suggested books. Has anyone used these books I have? What do you think?

  5. #5
    Registered User rstanley's Avatar
    Join Date
    Jun 2014
    Location
    New York, NY
    Posts
    668
    Please check out the list of books on the C Programming Language on this site. The list is a little outdated.

    The two I recommend are:

    C Primer Plus, 6th Edition, by Stephen Prata

    C Programming: A Modern Approach, 2nd Edition, K. N. King

    Choose one, and study it cover to cover, even the details you already know. Re-reading is NOT redundant! Don't skip any chapters, or paragraphs! Work through the exercises at the end of each chapter.

    You will also want to familiarize yourself with features added in the C99 and C11 C Programming Language Standards.

    You have been using a compiler that may not even be C89/90 compliant!
    Last edited by rstanley; 04-19-2016 at 01:47 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Change Calculator with Breakdown of the Change
    By insertcoin in forum C Programming
    Replies: 2
    Last Post: 04-16-2014, 08:25 AM
  2. interface in c
    By Liakos in forum C Programming
    Replies: 5
    Last Post: 03-23-2011, 02:13 AM
  3. I/O interface
    By bean66 in forum C Programming
    Replies: 0
    Last Post: 08-28-2007, 12:53 PM
  4. USB interface
    By ziga in forum Tech Board
    Replies: 9
    Last Post: 08-22-2007, 04:24 AM
  5. PCI ISA bus Interface
    By Mohsinzb in forum C Programming
    Replies: 0
    Last Post: 03-27-2002, 01:12 PM