<commit_before>window.openti.z80 = function() {
    var self = this;
    self.readMemory = null;
    self.writeMemory = null;
    self.readPort = null;
    self.writePort = null;
    af = bc = de = hl = ix = iy = 0;
    pc = 0; sp = 0;
    function countSetBits(value) {
        // Used to set the P/V flag under some conditions
        // There are some algorithms that do this faster, but we're already using JavaScript
        // so performance isn't a huge concern, plus this doesn't happen often and it's only
        // 8 bits.
        var count = 0;
        for (var i = 0; i < 8; i++) {
            if (value & (1 << i) > 0) {
                count++;
            }
        }
        return count;
    }
    self.registers = (function() {
        var self = this;
        af_ = bc_ = de_ = hl_ = ix_ = iy_ = 0;
        i = 0; r = 0;

        self.AF = function(value) {
            if (typeof value !== 'undefined') af = value & 0xFFFF;
            return af;
        };

        self.BC = function(value) {
            if (typeof value !== 'undefined') bc = value & 0xFFFF;
            return bc;
        };

        self.DE = function(value) {
            if (typeof value !== 'undefined') de = value & 0xFFFF;
            return de;
        };

        self.HL = function(value) {
            if (typeof value !== 'undefined') hl = value & 0xFFFF;
            return hl;
        };

        self.IX = function(value) {
            if (typeof value !== 'undefined') ix = value & 0xFFFF;
            return ix;
        };

        self.IY = function(value) {
            if (typeof value !== 'undefined') iy = value & 0xFFFF;
            return iy;
        };

        self.PC = function(value) {
            if (typeof value !== 'undefined') pc = value & 0xFFFF;
            return pc;
        };
        
        self.SP = function(value) {
            if (typeof value !== 'undefined') sp = value & 0xFFFF;
            return sp;
        };

        self.I = function(value) {
            if (typeof value !== 'undefined') self.i = value & 0xFF;
            return i;
        };

        self.R = function(value) {
            if (typeof value !== 'undefined') self.r = value & 0xFF;
            return r;
        }

        self.A = function(value) {
            if (typeof value !== 'undefined') {
                af &= 0x00FF;
                af |= (value & 0xFF) << 8;
            }
            return (af & 0xFF00) >> 8;
        };

        self.F = function(value) {
            if (typeof value !== 'undefined') {
                af &= 0xFF00;
                af |= value & 0xFF;
            }
            return af & 0x00FF;
        };

        self.B = function(value) {
            if (typeof value !== 'undefined') {
                bc &= 0x00FF;
                bc |= (value & 0xFF) << 8;
            }
            return (bc & 0xFF00) >> 8;
        };

        self.C = function(value) {
            if (typeof value !== 'undefined') {
                bc &= 0xFF00;
                bc |= value & 0xFF;
            }
            return bc & 0x00FF;
        };

        self.D = function(value) {
            if (typeof value !== 'undefined') {
                de &= 0x00FF;
                de |= (value & 0xFF) << 8;
            }
            return (de & 0xFF00) >> 8;
        };

        self.E = function(value) {
            if (typeof value !== 'undefined') {
                de &= 0xFF00;
                de |= value & 0xFF;
            }
            return af & 0x00FF;
        };

        self.H = function(value) {
            if (typeof value !== 'undefined') {
                hl &= 0x00FF;
                hl |= (value & 0xFF) << 8;
            }
            return (hl & 0xFF00) >> 8;<commit_msg>Improve register setting functions<commit_after>window.openti.z80 = function() {
    var self = this;
    self.readMemory = null;
    self.writeMemory = null;
    self.readPort = null;
    self.writePort = null;
    af = bc = de = hl = ix = iy = 0;
    pc = 0; sp = 0;
    function countSetBits(value) {
        // Used to set the P/V flag under some conditions
        // There are some algorithms that do this faster, but we're already using JavaScript
        // so performance isn't a huge concern, plus this doesn't happen often and it's only
        // 8 bits.
        var count = 0;
        for (var i = 0; i < 8; i++) {
            if (value & (1 << i) > 0) {
                count++;
            }
        }
        return count;
    }
    self.registers = (function() {
        var self = this;
        af_ = bc_ = de_ = hl_ = ix_ = iy_ = 0;
        i = 0; r = 0;

        self.AF = function(value) {
            if (typeof value !== 'undefined') af = value & 0xFFFF;
            return af;
        };

        self.BC = function(value) {
            if (typeof value !== 'undefined') bc = value & 0xFFFF;
            return bc;
        };

        self.DE = function(value) {
            if (typeof value !== 'undefined') de = value & 0xFFFF;
            return de;
        };

        self.HL = function(value) {
            if (typeof value !== 'undefined') hl = value & 0xFFFF;
            return hl;
        };

        self.IX = function(value) {
            if (typeof value !== 'undefined') ix = value & 0xFFFF;
            return ix;
        };

        self.IY = function(value) {
            if (typeof value !== 'undefined') iy = value & 0xFFFF;
            return iy;
        };

        self.PC = function(value) {
            if (typeof value !== 'undefined') pc = value & 0xFFFF;
            return pc;
        };
        
        self.SP = function(value) {
            if (typeof value !== 'undefined') sp = value & 0xFFFF;
            return sp;
        };

        self.I = function(value) {
            if (typeof value !== 'undefined') self.i = value & 0xFF;
            return i;
        };

        self.R = function(value) {
            if (typeof value !== 'undefined') self.r = value & 0xFF;
            return r;
        }

        self.A = function(value) {
            if (typeof value !== 'undefined') {
                af &= 0x00FF;
                af |= (value & 0xFF) << 8;
            }
            return af >> 8;
        };

        self.F = function(value) {
            if (typeof value !== 'undefined') {
                af &= 0xFF00;
                af |= value & 0xFF;
            }
            return af & 0x00FF;
        };

        self.B = function(value) {
            if (typeof value !== 'undefined') {
                bc &= 0x00FF;
                bc |= (value & 0xFF) << 8;
            }
            return bc >> 8;
        };

        self.C = function(value) {
            if (typeof value !== 'undefined') {
                bc &= 0xFF00;
                bc |= value & 0xFF;
            }
            return bc & 0x00FF;
        };

        self.D = function(value) {
            if (typeof value !== 'undefined') {
                de &= 0x00FF;
                de |= (value & 0xFF) << 8;
            }
            return de >> 8;
        };

        self.E = function(value) {
            if (typeof value !== 'undefined') {
                de &= 0xFF00;
                de |= value & 0xFF;
            }
            return af & 0x00FF;
        };

        self.H = function(value) {
            if (typeof value !== 'undefined') {
                hl &= 0x00FF;
                hl |= (value & 0xFF) << 8;
            }
            return hl >> 8;
{'fraction_non_alphanumeric': 0.12871154104527743, 'fraction_numerical': 0.02015316404675534, 'mean_word_length': 1.190700412007063, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3117108', 'n_tokens_mistral': 2307, 'n_tokens_neox': 2100, 'n_words': 626}