<commit_before>/**
 * Basic MMU.
 *
 * Copyright (c) 2011 <NAME> (<EMAIL>)
 * Created: 10/09/11 18:10
 * 
 */
"use strict";
/**
 * MMU
 * read functions return undefined when cannot read
 * write functions return true when write is possible, false otherwise
 */
lm32.MMU = function() {
    this.handlers = [];
    this.last_handler = undefined;
    var dummy = function() { return 0 };
    this.dummy_handler = {
            read_8: dummy,
            read_16: dummy,
            read_32: dummy,
            write_8: dummy,
            write_16: dummy,
            write_32: dummy
    };
};

lm32.MMU.prototype.get_handler_for = function(addr, name) {
    if((this.last_handler != undefined)
        && (addr >= this.last_handler.base_addr)
        && (addr < this.last_handler.base_addr + this.last_handler.size)) {
        return this.last_handler;
    }

    var handler = undefined;
    var len = this.handlers.length;
    for(var i = 0; i < len; i++) {
        var curr = this.handlers[i];
        if((addr >= curr.base_addr) && (addr < curr.base_addr + curr.size)) {
            handler = curr;
            this.last_handler = handler;
        }
    }
    if(handler === undefined) {
        handler = this.dummy_handler;
        //console.log("MMU get_handler_for (called by " + name + "): no handler found for address 0x" + addr.toString(16));
    }
    return handler;<commit_msg>Removing dummy handlers (moved to lm32_sys)<commit_after>/**
 * Basic MMU.
 *
 * Copyright (c) 2011 <NAME> (<EMAIL>)
 * Created: 10/09/11 18:10
 * 
 */
"use strict";
/**
 * MMU
 * read functions return undefined when cannot read
 * write functions return true when write is possible, false otherwise
 */
lm32.MMU = function() {
    this.handlers = [];
    this.last_handler = undefined;
};

lm32.MMU.prototype.get_handler_for = function(addr, name) {
    if((this.last_handler != undefined)
        && (addr >= this.last_handler.base_addr)
        && (addr < this.last_handler.base_addr + this.last_handler.size)) {
        return this.last_handler;
    }

    var handler = undefined;
    var len = this.handlers.length;
    for(var i = 0; i < len; i++) {
        var curr = this.handlers[i];
        if((addr >= curr.base_addr) && (addr < curr.base_addr + curr.size)) {
            handler = curr;
            this.last_handler = handler;
        }
    }
    if(handler === undefined) {
        console.log("MMU get_handler_for (called by " + name + "): no handler found for address 0x" + addr.toString(16));
    }
    return handler;
{'fraction_non_alphanumeric': 0.13663366336633664, 'fraction_numerical': 0.022574257425742573, 'mean_word_length': 2.4274084124830395, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 11, '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': '4177480', 'n_tokens_mistral': 844, 'n_tokens_neox': 802, 'n_words': 202}