将 .py 和 .pyi 后缀名改为了 .vp 和 .vpi 后缀名
This commit is contained in:
114
vpsdk/syscall.vp
Normal file
114
vpsdk/syscall.vp
Normal file
@@ -0,0 +1,114 @@
|
||||
import t, c
|
||||
|
||||
CREATE_WINDOW: t.CDefine = 1
|
||||
DRAW_TEXT: t.CDefine = 2
|
||||
EXIT: t.CDefine = 3
|
||||
OPEN: t.CDefine = 4
|
||||
CLOSE: t.CDefine = 5
|
||||
READ: t.CDefine = 6
|
||||
WRITE: t.CDefine = 7
|
||||
SEEK: t.CDefine = 8
|
||||
TELL: t.CDefine = 9
|
||||
SIZE: t.CDefine = 10
|
||||
MKDIR: t.CDefine = 11
|
||||
REMOVE: t.CDefine = 12
|
||||
OPENDIR: t.CDefine = 13
|
||||
READDIR: t.CDefine = 14
|
||||
CLOSEDIR: t.CDefine = 15
|
||||
STAT: t.CDefine = 16
|
||||
WAIT_WINDOW: t.CDefine = 17
|
||||
SERIAL_PUTS: t.CDefine = 18
|
||||
LOAD_SO: t.CDefine = 19
|
||||
SO_CALL1: t.CDefine = 20
|
||||
GET_WINBUF: t.CDefine = 21
|
||||
WIN_FLUSH: t.CDefine = 22
|
||||
POLL_EVENT: t.CDefine = 23
|
||||
SET_CURSOR: t.CDefine = 24
|
||||
|
||||
YIELD: t.CDefine = 25
|
||||
SET_TITLE: t.CDefine = 26
|
||||
SET_GEOMETRY: t.CDefine = 27
|
||||
SPAWN: t.CDefine = 28
|
||||
MMAP: t.CDefine = 29
|
||||
MUNMAP: t.CDefine = 30
|
||||
SET_RESIZABLE: t.CDefine = 31
|
||||
GET_WIN_SIZE: t.CDefine = 32
|
||||
THREAD_CREATE: t.CDefine = 33
|
||||
|
||||
def _syscall0(num: t.CUInt64T) -> t.CUInt64T:
|
||||
ret: t.CUInt64T
|
||||
c.Asm(f"""mov rax, {c.AsmInp(num, t.ASM_DESCR.REG_ANY)}
|
||||
syscall""",
|
||||
out=[c.AsmOut(ret, t.ASM_DESCR.OUTPUT_REG)],
|
||||
op=[t.ASM_DESCR.CLOBBER_MEMORY, t.ASM_DESCR.CLOBBER_RCX,
|
||||
t.ASM_DESCR.CLOBBER_R11])
|
||||
return ret
|
||||
|
||||
def _syscall1(num: t.CUInt64T, a1: t.CUInt64T) -> t.CUInt64T:
|
||||
ret: t.CUInt64T
|
||||
c.Asm(f"""mov rdi, {c.AsmInp(a1, t.ASM_DESCR.REG_ANY)}
|
||||
mov rax, {c.AsmInp(num, t.ASM_DESCR.REG_ANY)}
|
||||
syscall""",
|
||||
out=[c.AsmOut(ret, t.ASM_DESCR.OUTPUT_REG)],
|
||||
op=[t.ASM_DESCR.CLOBBER_MEMORY, t.ASM_DESCR.CLOBBER_RCX,
|
||||
t.ASM_DESCR.CLOBBER_R11, t.ASM_DESCR.CLOBBER_RDI])
|
||||
return ret
|
||||
|
||||
def _syscall2(num: t.CUInt64T, a1: t.CUInt64T, a2: t.CUInt64T) -> t.CUInt64T:
|
||||
ret: t.CUInt64T
|
||||
c.Asm(f"""mov rdi, {c.AsmInp(a1, t.ASM_DESCR.REG_ANY)}
|
||||
mov rsi, {c.AsmInp(a2, t.ASM_DESCR.REG_ANY)}
|
||||
mov rax, {c.AsmInp(num, t.ASM_DESCR.REG_ANY)}
|
||||
syscall""",
|
||||
out=[c.AsmOut(ret, t.ASM_DESCR.OUTPUT_REG)],
|
||||
op=[t.ASM_DESCR.CLOBBER_MEMORY, t.ASM_DESCR.CLOBBER_RCX,
|
||||
t.ASM_DESCR.CLOBBER_R11, t.ASM_DESCR.CLOBBER_RDI,
|
||||
t.ASM_DESCR.CLOBBER_RSI])
|
||||
return ret
|
||||
|
||||
def _syscall3(num: t.CUInt64T, a1: t.CUInt64T, a2: t.CUInt64T, a3: t.CUInt64T) -> t.CUInt64T:
|
||||
ret: t.CUInt64T
|
||||
c.Asm(f"""mov rdi, {c.AsmInp(a1, t.ASM_DESCR.REG_ANY)}
|
||||
mov rsi, {c.AsmInp(a2, t.ASM_DESCR.REG_ANY)}
|
||||
mov rdx, {c.AsmInp(a3, t.ASM_DESCR.REG_ANY)}
|
||||
mov rax, {c.AsmInp(num, t.ASM_DESCR.REG_ANY)}
|
||||
syscall""",
|
||||
out=[c.AsmOut(ret, t.ASM_DESCR.OUTPUT_REG)],
|
||||
op=[t.ASM_DESCR.CLOBBER_MEMORY, t.ASM_DESCR.CLOBBER_RCX,
|
||||
t.ASM_DESCR.CLOBBER_R11, t.ASM_DESCR.CLOBBER_RDI,
|
||||
t.ASM_DESCR.CLOBBER_RSI, t.ASM_DESCR.CLOBBER_RDX])
|
||||
return ret
|
||||
|
||||
def _syscall5(num: t.CUInt64T, a1: t.CUInt64T, a2: t.CUInt64T, a3: t.CUInt64T, a4: t.CUInt64T, a5: t.CUInt64T) -> t.CUInt64T:
|
||||
ret: t.CUInt64T
|
||||
c.Asm(f"""mov rdi, {c.AsmInp(a1, t.ASM_DESCR.REG_ANY)}
|
||||
mov rsi, {c.AsmInp(a2, t.ASM_DESCR.REG_ANY)}
|
||||
mov rdx, {c.AsmInp(a3, t.ASM_DESCR.REG_ANY)}
|
||||
mov r10, {c.AsmInp(a4, t.ASM_DESCR.REG_ANY)}
|
||||
mov r8, {c.AsmInp(a5, t.ASM_DESCR.REG_ANY)}
|
||||
mov rax, {c.AsmInp(num, t.ASM_DESCR.REG_ANY)}
|
||||
syscall""",
|
||||
out=[c.AsmOut(ret, t.ASM_DESCR.OUTPUT_REG)],
|
||||
op=[t.ASM_DESCR.CLOBBER_MEMORY, t.ASM_DESCR.CLOBBER_RCX,
|
||||
t.ASM_DESCR.CLOBBER_R11, t.ASM_DESCR.CLOBBER_RDI,
|
||||
t.ASM_DESCR.CLOBBER_RSI, t.ASM_DESCR.CLOBBER_RDX,
|
||||
t.ASM_DESCR.CLOBBER_R10, t.ASM_DESCR.CLOBBER_R8])
|
||||
return ret
|
||||
|
||||
def _syscall6(num: t.CUInt64T, a1: t.CUInt64T, a2: t.CUInt64T, a3: t.CUInt64T, a4: t.CUInt64T, a5: t.CUInt64T, a6: t.CUInt64T) -> t.CUInt64T:
|
||||
ret: t.CUInt64T
|
||||
c.Asm(f"""mov rdi, {c.AsmInp(a1, t.ASM_DESCR.REG_ANY)}
|
||||
mov rsi, {c.AsmInp(a2, t.ASM_DESCR.REG_ANY)}
|
||||
mov rdx, {c.AsmInp(a3, t.ASM_DESCR.REG_ANY)}
|
||||
mov r10, {c.AsmInp(a4, t.ASM_DESCR.REG_ANY)}
|
||||
mov r8, {c.AsmInp(a5, t.ASM_DESCR.REG_ANY)}
|
||||
mov r9, {c.AsmInp(a6, t.ASM_DESCR.REG_ANY)}
|
||||
mov rax, {c.AsmInp(num, t.ASM_DESCR.REG_ANY)}
|
||||
syscall""",
|
||||
out=[c.AsmOut(ret, t.ASM_DESCR.OUTPUT_REG)],
|
||||
op=[t.ASM_DESCR.CLOBBER_MEMORY, t.ASM_DESCR.CLOBBER_RCX,
|
||||
t.ASM_DESCR.CLOBBER_R11, t.ASM_DESCR.CLOBBER_RDI,
|
||||
t.ASM_DESCR.CLOBBER_RSI, t.ASM_DESCR.CLOBBER_RDX,
|
||||
t.ASM_DESCR.CLOBBER_R10, t.ASM_DESCR.CLOBBER_R8,
|
||||
t.ASM_DESCR.CLOBBER_R9])
|
||||
return ret
|
||||
Reference in New Issue
Block a user