From 9cab06121021ce8fb4626dfdbe34ef50bf55f182 Mon Sep 17 00:00:00 2001 From: JozanLeClerc <> Date: Sun, 22 May 2022 15:12:53 +0000 Subject: Update FossilOrigin-Name: 34d2b122f1068e995b1a752fbfc9d37878cf4e80 --- src/c_cpu.S | 47 ++++++++++++++++++++++++++++++++++++++++++++++- src/c_example.S | 6 ++++-- 2 files changed, 50 insertions(+), 3 deletions(-) diff --git a/src/c_cpu.S b/src/c_cpu.S index 1c5a30c..395b176 100644 --- a/src/c_cpu.S +++ b/src/c_cpu.S @@ -48,6 +48,15 @@ c_cpu: fork_model: + xorq %rdi, %rdi + xorq %rsi, %rsi + xorq %rdx, %rdx + xorq %rax, %rax + movb $0x1, %dil + movq $str_model, %rsi + movq $len_model, %rdx + movb $0x4, %al /* SYS_write */ + syscall xorq %rdi, %rdi xorq %rsi, %rsi xorq %rax, %rax @@ -59,6 +68,15 @@ fork_model: jg wait_model fork_ncpu: + xorq %rdi, %rdi + xorq %rsi, %rsi + xorq %rdx, %rdx + xorq %rax, %rax + movb $0x1, %dil + movq $str_ncpu, %rsi + movq $len_ncpu, %rdx + movb $0x4, %al /* SYS_write */ + syscall xorq %rdi, %rdi xorq %rsi, %rsi xorq %rax, %rax @@ -70,6 +88,15 @@ fork_ncpu: jg wait_ncpu fork_lscpu: + xorq %rdi, %rdi + xorq %rsi, %rsi + xorq %rdx, %rdx + xorq %rax, %rax + movb $0x1, %dil + movq $str_lscpu, %rsi + movq $len_lscpu, %rdx + movb $0x4, %al /* SYS_write */ + syscall xorq %rdi, %rdi xorq %rsi, %rsi xorq %rax, %rax @@ -154,6 +181,17 @@ wait_lscpu: xorq %rax, %rax movb $0x7, %al /* sys_wait4 */ syscall + +write_end: + xorq %rdi, %rdi + xorq %rsi, %rsi + xorq %rdx, %rdx + xorq %rax, %rax + movb $0x1, %dil + movq $str_end, %rsi + movq $len_end, %rdx + movb $0x4, %al /* SYS_write */ + syscall retq err: @@ -164,7 +202,14 @@ err: syscall .data -# sysctl hw.model\n\t\t\tsysctl hw.ncpu\n\t\t\tlscpu + str_model: .asciz "\t\t

\n\t\t\tsysctl hw.model:\n\t\t

\n\t\t
\n"
+	len_model	= . - str_model
+	str_ncpu:	.asciz "\t\t
\n\t\t

\n\t\t\tsysctl hw.ncpu:\n\t\t

\n\t\t
\n"
+	len_ncpu	= . - str_ncpu
+	str_lscpu:	.asciz "\t\t
\n\t\t

\n\t\t\tlscpu:\n\t\t

\n\t\t
\n"
+	len_lscpu	= . - str_lscpu
+	str_end:	.asciz "\t\t
\n" + len_end = . - str_end sysctl: .asciz "/sbin/sysctl" lscpu: .asciz "/usr/local/bin/lscpu" model: .asciz "hw.model" diff --git a/src/c_example.S b/src/c_example.S index 3de431b..17b2f34 100644 --- a/src/c_example.S +++ b/src/c_example.S @@ -58,6 +58,8 @@ write_begin: movq $len_begin, %rdx movb $0x4, %al /* SYS_write */ syscall + +cpu: callq c_cpu write_end: @@ -75,7 +77,7 @@ end: retq .data - str_begin: .ascii "Content-type: text/html\n\n\n\t\n\t\tTitle\n\t\n\t\n\t\t

asm-cgi-example

\n\t\t

\n\t\t\tThis page was generated by a small assembly program. It will run some shell commands for you. It's pointless in essence but I am trying to prove a point.\n\t\t

\n\t\t

Some CPU infos

\n\t\t

\n\t\t\tLet's fetch some infos about this server's CPU.\n\t\t\n\t\t

\n"
+	str_begin:	.ascii "Content-type: text/html\n\n\n\t\n\t\tTitle\n\t\n\t\n\t\t

asm-cgi-example

\n\t\t

\n\t\t\tThis page was generated by a small assembly program. It will run some shell commands for you. It's pointless in essence but I am trying to prove a point.\n\t\t

\n\t\t

Some CPU infos

\n\t\t

\n\t\t\tLet's fetch some infos about this server's CPU.\n\t\t

\n" len_begin = . - str_begin - str_end: .ascii "\t\t

\n\t\n\n" + str_end: .ascii "\t\n\n" len_end = . - str_end -- cgit v1.2.3