<commit_before>/*
 * Copyright (c) 2017 <NAME>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include <stdlib.h>

#include "../../arch/arm32/arm2_div.h"
#include "../../arch/arm32/arm_gen.h"
#include "../../arch/arm32/arm_peephole.h"
#include "../../arch/arm32/arm_reg_alloc.h"
#include "../../arch/arm32/arm_sub_section.h"
#include "../../common/error_codes.h"
#include "riscos_arm.h"

#define RISCOS_ARM_GLOBAL_ESC_FLAG (-4)
#define RISCOS_ARM_GLOBAL_ESC_HANDLER (-8)
#define RISCOS_ARM_GLOBAL_ESC_R12 (-12)

static void prv_add_escape_handler(subtilis_arm_section_t *arm_s,
				   subtilis_error_t *err)
{
	size_t label;
	subtilis_arm_instr_t *instr;
	subtilis_arm_br_instr_t *br;

	subtilis_arm_add_mov_imm(arm_s, SUBTILIS_ARM_CCODE_AL, false, 0, 9,
				 err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;
	subtilis_arm_add_add_imm(arm_s, SUBTILIS_ARM_CCODE_AL, false, 1, 15, 16,
				 err);<commit_msg>Add description of application memory layout for RO<commit_after>/*
 * Copyright (c) 2017 <NAME>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include <stdlib.h>

#include "../../arch/arm32/arm2_div.h"
#include "../../arch/arm32/arm_gen.h"
#include "../../arch/arm32/arm_peephole.h"
#include "../../arch/arm32/arm_reg_alloc.h"
#include "../../arch/arm32/arm_sub_section.h"
#include "../../common/error_codes.h"
#include "riscos_arm.h"

#define RISCOS_ARM_GLOBAL_ESC_FLAG (-4)
#define RISCOS_ARM_GLOBAL_ESC_HANDLER (-8)
#define RISCOS_ARM_GLOBAL_ESC_R12 (-12)

/*
 * RiscOS memory layout
 *
 * Memory organisation of an application under RiscOS is as follows:
 *
 * TOP      |------------------|-------------------------------------------
 *          |   Gloabals       | Memory reserved for Global variables
 * R12      |------------------|-------------------------------------------
 *          | Escape Condition | non zero if escape has not been handled
 * R12-4    |------------------| -------------------------------------------
 *          |Old Escape Handler| Address of old escape handler
 * R12-8    |------------------| -------------------------------------------
 *          |Old Escape R12    | Value of R12 for old escape handler
 *R13,R12-12|------------------| -------------------------------------------
 *          |   Stack          | Stack used for function calls and locals
 *R13-8192  |------------------| -------------------------------------------
 *          |   Heap           | Heap, used for strings, arrays and structures
 * 0x8000   |------------------| -------------------------------------------
 */

static void prv_add_escape_handler(subtilis_arm_section_t *arm_s,
				   subtilis_error_t *err)
{
	size_t label;
	subtilis_arm_instr_t *instr;
	subtilis_arm_br_instr_t *br;

	subtilis_arm_add_mov_imm(arm_s, SUBTILIS_ARM_CCODE_AL, false, 0, 9,
				 err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;
	subtilis_arm_add_add_imm(arm_s, SUBTILIS_ARM_CCODE_AL, false, 1, 15, 16,
				 err);
{'fraction_non_alphanumeric': 0.20959595959595959, 'fraction_numerical': 0.023484848484848483, 'mean_word_length': 2.24672131147541, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '4199630', 'n_tokens_mistral': 1309, 'n_tokens_neox': 1234, 'n_words': 350}