Skip to content

Commit

Permalink
bits16: Format code
Browse files Browse the repository at this point in the history
Signed-off-by: Stefan Weil <[email protected]>
  • Loading branch information
stweil committed Mar 31, 2019
1 parent 146079f commit be96b7b
Showing 1 changed file with 29 additions and 33 deletions.
62 changes: 29 additions & 33 deletions src/ccutil/bits16.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
* File: bits16.h (Formerly bits8.h)
* Description: Code for 8 bit field class.
* Author: Phil Cheatle
* Created: Thu Oct 17 10:10:05 BST 1991
*
* (C) Copyright 1991, Hewlett-Packard Ltd.
** Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -20,43 +19,40 @@
#ifndef BITS16_H
#define BITS16_H

#include "host.h"
#include <cstdint> // for uint8_t, ...
#include "platform.h" // for DLLSYM

class DLLSYM BITS16
{
public:
uint16_t val;
class DLLSYM BITS16 {
public:
uint16_t val;

BITS16() {
val = 0;
} // constructor
BITS16() { val = 0; } // constructor

BITS16(uint16_t init) {
val = init;
}
BITS16(uint16_t init) { val = init; }

void turn_on_bit( // flip specified bit
uint8_t bit_num) { // bit to flip 0..7
val = val | 01 << bit_num;
}
void turn_on_bit( // flip specified bit
uint8_t bit_num) { // bit to flip 0..7
val = val | 01 << bit_num;
}

void turn_off_bit( // flip specified bit
uint8_t bit_num) { // bit to flip 0..7
val = val & ~(01 << bit_num);
}

void turn_off_bit( // flip specified bit
uint8_t bit_num) { // bit to flip 0..7
void set_bit( // flip specified bit
uint8_t bit_num, // bit to flip 0..7
bool value) { // value to flip to
if (value)
val = val | 01 << bit_num;
else
val = val & ~(01 << bit_num);
}

void set_bit( // flip specified bit
uint8_t bit_num, // bit to flip 0..7
bool value) { // value to flip to
if (value)
val = val | 01 << bit_num;
else
val = val & ~(01 << bit_num);
}

bool bit( // access bit
uint8_t bit_num) const { // bit to access
return (val >> bit_num) & 01;
}
}

bool bit( // access bit
uint8_t bit_num) const { // bit to access
return (val >> bit_num) & 01;
}
};

#endif

0 comments on commit be96b7b

Please sign in to comment.