previous | start | next

Printing a Character

Here is an example of code that might be executed on the processor to get a character, 'A', printed on a simple printer with the three port registers described above:

    // Get printer status until it is ready
    status = read_status_register();
    while( readyBit(status) == 0 ) {
      status = read_status_register();
    }

   // Now put 'A' in the data port
   write_data_register('A');

   // Tell the printer to print the data from its data register
   cmd = read_control_register();
   cmd = set_start_bit(cmd);
   write_control_register(cmd);

   // Tell the printer to stop printing the data
   cmd = clear_start_bit(cmd);
   write_control_register(cmd);



previous | start | next