Skip to content
Snippets Groups Projects
Select Git revision
  • aaff82afe5a72ec69e05f1e56047d0acfde91d0e
  • wip-bootstrap default
  • dualcore
  • ch3/leds
  • ch3/time
  • master
6 results

loop_count-2-range_iter.py

Blame
  • gccollect.c 3.57 KiB
    /*
     * This file is part of the Micro Python project, http://micropython.org/
     *
     * The MIT License (MIT)
     *
     * Copyright (c) 2013, 2014 Damien P. George
     *
     * Permission is hereby granted, free of charge, to any person obtaining a copy
     * of this software and associated documentation files (the "Software"), to deal
     * in the Software without restriction, including without limitation the rights
     * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
     * copies of the Software, and to permit persons to whom the Software is
     * furnished to do so, subject to the following conditions:
     *
     * The above copyright notice and this permission notice shall be included in
     * all copies or substantial portions of the Software.
     *
     * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
     * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
     * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
     * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
     * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
     * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
     * THE SOFTWARE.
     */
    
    #include <stdio.h>
    
    #include "misc.h"
    #include "mpconfig.h"
    #include "gc.h"
    
    #if MICROPY_ENABLE_GC
    
    extern void *stack_top;
    
    // We capture here callee-save registers, i.e. ones which may contain
    // interesting values held there by our callers. It doesn't make sense
    // to capture caller-saved registers, because they, well, put on the
    // stack already by the caller.
    #ifdef __x86_64__
    typedef machine_uint_t regs_t[6];
    
    void gc_helper_get_regs(regs_t arr) {
        register long rbx asm ("rbx");
        register long rbp asm ("rbp");
        register long r12 asm ("r12");
        register long r13 asm ("r13");
        register long r14 asm ("r14");
        register long r15 asm ("r15");
        arr[0] = rbx;
        arr[1] = rbp;
        arr[2] = r12;
        arr[3] = r13;
        arr[4] = r14;
        arr[5] = r15;
    }
    #endif
    
    #ifdef __i386__
    typedef machine_uint_t regs_t[4];
    
    void gc_helper_get_regs(regs_t arr) {
        register long ebx asm ("ebx");
        register long esi asm ("esi");
        register long edi asm ("edi");
        register long ebp asm ("ebp");
        arr[0] = ebx;
        arr[1] = esi;
        arr[2] = edi;