mmap.c
uint32_t *generate_hybrid(uint32_t *code)
{
	uint32_t idx = 0;

	if (cheri_getlength(code) <= (10 * sizeof(uint32_t)))
	{
		error("Insufficient size");
		exit(-1);
	}

	code[idx++] = cincoffsetimm(csp, csp, ((-32) + (2 << 20)));
	code[idx++] = cspecialrw(cnull, csp, 1); // cspecialw csp, ddc
	code[idx++] = csc_128(zero, cra, 16);
	code[idx++] = csc_128(zero, cs0, 0);
	code[idx++] = cincoffset(cs0, csp, 32);
	code[idx++] = addi(a0, zero, 5);
	code[idx++] = clc_128(cs0, zero, 0);
	code[idx++] = clc_128(cra, zero, 16);
	code[idx++] = cincoffsetimm(csp, csp, 32);
	code[idx++] = cjalr(zero, cra);
	return code;
}
/*
 * This hybrid function works because the DDC can be set to the stack pointer and used as a
 * reference. This works because when we are in hybrid mode the DDC's address is used as a base. We
 * have the DDC set to be the stack pointer. This allows storing values on the stack though `csc
 * cra, 16(zero)`. The calculateion is done like this: `ddc.address + zero_value + 16`. Therefore
 * cnull can be used in place of the stack pointer in the case of this example.
 */
This hybrid function works because the DDC can be set to the stack pointer and used as a
reference. This works because when we are in hybrid mode the DDC's address is used as a base. We
have the DDC set to be the stack pointer. This allows storing values on the stack though `csc
cra, 16(zero)`. The calculateion is done like this: `ddc.address + zero_value + 16`. Therefore
cnull can be used in place of the stack pointer in the case of this example.
This hybrid function works because the DDC can be set to the stack pointer and used as a reference . This works because when we are in hybrid mode the DDC ' s address is used as a base . We have the DDC set to be the stack pointer . This allows storing values on the stack though ` csc cra 16 ( zero ) ` . The calculateion is done like this : ` ddc . address + zero_value + 16 ` . Therefore cnull can be used in place of the stack pointer in the case of this example .
uint32_t *generate_hybrid(uint32_t *code)
{
	uint32_t idx = 0;
	if (cheri_getlength(code) <= (10 * sizeof(uint32_t)))
	{
		error("Insufficient size");
		exit(-1);
	}
	code[idx++] = cincoffsetimm(csp, csp, ((-32) + (2 << 20)));
	code[idx++] = cspecialrw(cnull, csp, 1); 
	code[idx++] = csc_128(zero, cra, 16);
	code[idx++] = csc_128(zero, cs0, 0);
	code[idx++] = cincoffset(cs0, csp, 32);
	code[idx++] = addi(a0, zero, 5);
	code[idx++] = clc_128(cs0, zero, 0);
	code[idx++] = clc_128(cra, zero, 16);
	code[idx++] = cincoffsetimm(csp, csp, 32);
	code[idx++] = cjalr(zero, cra);
	return code;
}
uint32_t * generate_hybrid ( uint32_t * code ) { uint32_t idx = 0 ; if ( cheri_getlength ( code ) <= ( 10 * sizeof ( uint32_t ) ) ) { error ( " " ) ; exit ( -1 ) ; } code [ idx ++ ] = cincoffsetimm ( csp , csp , ( ( -32 ) + ( 2 << 20 ) ) ) ; code [ idx ++ ] = cspecialrw ( cnull , csp , 1 ) ; code [ idx ++ ] = csc_128 ( zero , cra , 16 ) ; code [ idx ++ ] = csc_128 ( zero , cs0 , 0 ) ; code [ idx ++ ] = cincoffset ( cs0 , csp , 32 ) ; code [ idx ++ ] = addi ( a0 , zero , 5 ) ; code [ idx ++ ] = clc_128 ( cs0 , zero , 0 ) ; code [ idx ++ ] = clc_128 ( cra , zero , 16 ) ; code [ idx ++ ] = cincoffsetimm ( csp , csp , 32 ) ; code [ idx ++ ] = cjalr ( zero , cra ) ; return code ; }
This hybrid function works because the DDC can be set to the stack pointer and used as a
 reference.
This hybrid function works because the DDC can be set to the stack pointer and used as a reference .
// cspecialw csp, ddc