My Project
Loading...
Searching...
No Matches
kernel_asm.h File Reference
#include <stdio.h>
#include <stdlib.h>
#include <setjmp.h>
#include <memory.h>

Go to the source code of this file.

Macros

#define KERNEL_ASM_H
 
#define PROTO(proc)
 
#define EXTERN(proc)
 
#define MAX_MEMORY_LEN   100
 
#define PROC(proc_name)
 
#define ENDP
 
#define PUSH(param)
 
#define POP(param)
 
#define MOVL(dst, src)
 
#define ADD(dst, src)
 
#define SUB(dst, src)
 
#define MUL(dst, src)
 
#define DIV(dst, src)
 
#define JMP(lbl)
 
#define CMP(p1, p2)
 
#define JZ(lbl)
 
#define JNZ(lbl)
 
#define INC(param)
 
#define DEC(param)
 
#define LEA(dst, src)
 
#define SETL(dst, src)
 
#define GETL(dst, src)
 
#define CALL(proc)
 
#define INVOKE(proc)
 
#define RETURN()
 
#define RET()
 
#define LOOP(index, start, end)
 
#define ENDLOOP(index)
 
#define EXIT()
 
#define PROC_NAKED(proc_name)
 
#define ENDP_NAKED
 

Typedefs

typedef const char * STRING
 
typedef unsigned char BYTE
 
typedef unsigned short WORD
 
typedef unsigned long DWORD
 
typedef unsigned long long QWORD
 
typedef QWORD INT
 

Enumerations

enum  FLAG { FLAG_SIGNED = 1 , FLAG_ZERO = 1 << 2 }
 

Macro Definition Documentation

◆ ADD

#define ADD ( dst,
src )
Value:
{ \
(dst) += (INT)(src); \
}
QWORD INT
Definition kernel_asm.h:36

Definition at line 102 of file kernel_asm.h.

◆ CALL

#define CALL ( proc)
Value:
{ \
static INT ip; \
static jmp_buf _ip; \
static jmp_buf _ipArray[10]; \
if (setjmp(_ip) == 0) \
{ \
memcpy(_ipArray[ip++], &_ip, sizeof(jmp_buf)); \
PUSH(ip); \
proc(); \
} \
}

Definition at line 174 of file kernel_asm.h.

◆ CMP

#define CMP ( p1,
p2 )
Value:
{ \
flag = ((p1) == (p2)) ? FLAG_ZERO : 0; \
}
@ FLAG_ZERO
Definition kernel_asm.h:64

Definition at line 129 of file kernel_asm.h.

◆ DEC

#define DEC ( param)
Value:
{ \
--(param); \
}

Definition at line 152 of file kernel_asm.h.

◆ DIV

#define DIV ( dst,
src )
Value:
{ \
(dst) /= (INT)(src); \
}

Definition at line 117 of file kernel_asm.h.

◆ ENDLOOP

#define ENDLOOP ( index)
Value:
INC(index); \
}
#define INC(param)
Definition kernel_asm.h:147

Definition at line 216 of file kernel_asm.h.

◆ ENDP

#define ENDP
Value:
_end_proc: \
proc_retn(); \
return 0; \
}

Definition at line 73 of file kernel_asm.h.

◆ ENDP_NAKED

#define ENDP_NAKED
Value:
_end_proc: \
return 0; \
}

Definition at line 230 of file kernel_asm.h.

◆ EXIT

#define EXIT ( )
Value:
{ \
exit(a); \
}

Definition at line 220 of file kernel_asm.h.

◆ EXTERN

#define EXTERN ( proc)
Value:
INT proc();

Definition at line 41 of file kernel_asm.h.

◆ GETL

#define GETL ( dst,
src )
Value:
{ \
(dst) = *(INT *)(src); \
}

Definition at line 168 of file kernel_asm.h.

◆ INC

#define INC ( param)
Value:
{ \
++(param); \
}

Definition at line 147 of file kernel_asm.h.

◆ INVOKE

#define INVOKE ( proc)
Value:
{ \
static INT n; \
CALL(proc); \
POP(n); \
}

Definition at line 187 of file kernel_asm.h.

◆ JMP

#define JMP ( lbl)
Value:
{ \
goto lbl; \
}

Definition at line 123 of file kernel_asm.h.

◆ JNZ

#define JNZ ( lbl)
Value:
if (!(flag & FLAG_ZERO)) \
{ \
goto lbl; \
}

Definition at line 140 of file kernel_asm.h.

◆ JZ

#define JZ ( lbl)
Value:
if (flag & FLAG_ZERO) \
{ \
goto lbl; \
}

Definition at line 134 of file kernel_asm.h.

◆ KERNEL_ASM_H

#define KERNEL_ASM_H

Definition at line 3 of file kernel_asm.h.

◆ LEA

#define LEA ( dst,
src )
Value:
{ \
(dst) = (void *)(src); \
}

Definition at line 158 of file kernel_asm.h.

◆ LOOP

#define LOOP ( index,
start,
end )
Value:
MOVL(index, start); \
while (index < end) \
{
#define MOVL(dst, src)
Definition kernel_asm.h:97

Definition at line 210 of file kernel_asm.h.

◆ MAX_MEMORY_LEN

#define MAX_MEMORY_LEN   100

Definition at line 49 of file kernel_asm.h.

◆ MOVL

#define MOVL ( dst,
src )
Value:
{ \
(dst) = (INT)(src); \
}

Definition at line 97 of file kernel_asm.h.

◆ MUL

#define MUL ( dst,
src )
Value:
{ \
(dst) *= (INT)(src); \
}

Definition at line 112 of file kernel_asm.h.

◆ POP

#define POP ( param)
Value:
{ \
INT *p; \
p = (INT *)(m + sp); \
sp += sizeof(INT); \
(param) = *p; \
}

Definition at line 88 of file kernel_asm.h.

◆ PROC

#define PROC ( proc_name)
Value:
static int proc_name##DTCASE() \
{ \
proc_init();

Definition at line 68 of file kernel_asm.h.

◆ PROC_NAKED

#define PROC_NAKED ( proc_name)
Value:
static INT proc_name() \
{

Definition at line 226 of file kernel_asm.h.

◆ PROTO

#define PROTO ( proc)
Value:
static INT proc();

Definition at line 40 of file kernel_asm.h.

◆ PUSH

#define PUSH ( param)
Value:
{ \
INT *p; \
sp -= sizeof(INT); \
p = (INT *)(m + sp); \
*p = (INT)(param); \
}

Definition at line 80 of file kernel_asm.h.

◆ RET

#define RET ( )
Value:
{ \
static INT ip; \
static jmp_buf _ip; \
static jmp_buf _ipArray[]; \
POP(ip); \
memcpy(&_ip, _ipArray[ip - 1], sizeof(jmp_buf)); \
longjmp(_ip, a); \
}

Definition at line 199 of file kernel_asm.h.

◆ RETURN

#define RETURN ( )
Value:
{ \
goto _end_proc; \
}

Definition at line 194 of file kernel_asm.h.

◆ SETL

#define SETL ( dst,
src )
Value:
{ \
*(INT *)(dst) = (src); \
}

Definition at line 163 of file kernel_asm.h.

◆ SUB

#define SUB ( dst,
src )
Value:
{ \
(dst) -= (INT)(src); \
}

Definition at line 107 of file kernel_asm.h.

Typedef Documentation

◆ BYTE

typedef unsigned char BYTE

Definition at line 28 of file kernel_asm.h.

◆ DWORD

typedef unsigned long DWORD

Definition at line 30 of file kernel_asm.h.

◆ INT

typedef QWORD INT

Definition at line 36 of file kernel_asm.h.

◆ QWORD

typedef unsigned long long QWORD

Definition at line 31 of file kernel_asm.h.

◆ STRING

typedef const char* STRING

Definition at line 27 of file kernel_asm.h.

◆ WORD

typedef unsigned short WORD

Definition at line 29 of file kernel_asm.h.

Enumeration Type Documentation

◆ FLAG

enum FLAG
Enumerator
FLAG_SIGNED 
FLAG_ZERO 

Definition at line 61 of file kernel_asm.h.