diff options
author | JozanLeClerc <> | 2022-05-04 20:48:42 +0000 |
---|---|---|
committer | JozanLeClerc <> | 2022-05-04 20:48:42 +0000 |
commit | 3383cf69a6a76668d488b0d397bdb29606d62a3a (patch) | |
tree | 4fd58e3ed9cf2681b48d1110d2f2f895111712ce /src/c_example.S | |
parent | In progress (diff) | |
download | asm-cgi-example-3383cf69a6a76668d488b0d397bdb29606d62a3a.tar.gz asm-cgi-example-3383cf69a6a76668d488b0d397bdb29606d62a3a.tar.bz2 asm-cgi-example-3383cf69a6a76668d488b0d397bdb29606d62a3a.tar.xz asm-cgi-example-3383cf69a6a76668d488b0d397bdb29606d62a3a.tar.zst asm-cgi-example-3383cf69a6a76668d488b0d397bdb29606d62a3a.zip |
Good progress, now wait(2)
FossilOrigin-Name: 5ac5cffbb2bcbe00aae821cded1d575ff9b730f8
Diffstat (limited to 'src/c_example.S')
-rw-r--r-- | src/c_example.S | 63 |
1 files changed, 37 insertions, 26 deletions
diff --git a/src/c_example.S b/src/c_example.S index 81538c7..f410c17 100644 --- a/src/c_example.S +++ b/src/c_example.S @@ -57,13 +57,43 @@ main: # movb $0x4, %al /* SYS_write */ # syscall - # xorq %rdi, %rdi - # xorq %rsi, %rsi - # xorq %rax, %rax - # movq $sysctl, %rdi - # movq $0x0, %rsi - # movq $0x3b, %rax /* SYS_execve */ - # syscall + xorq %rdi, %rdi + xorq %rsi, %rsi + xorq %rax, %rax + movb $0x2, %al /* SYS_fork */ + syscall + cmp $0x0, %rax + jne next + + xorq %rax, %rax + pushq %rbp + movq %rsp, %rbp + movq $sysctl, -32(%rbp) + movq $model, -24(%rbp) + movq $0x0, -16(%rbp) + movq -32(%rbp), %rdi + leaq -32(%rbp), %rsi + xorq %rdx, %rdx + movq $0x3b, %rax /* SYS_execve */ + syscall + popq %rbp + retq + +next: + xorq %rdi, %rdi + xorq %rsi, %rsi + xorq %rax, %rax + pushq %rbp + movq %rsp, %rbp + movq $sysctl, -32(%rbp) + movq $ncpu, -24(%rbp) + movq $0x0, -16(%rbp) + movq -32(%rbp), %rdi + leaq -32(%rbp), %rsi + xorq %rdx, %rdx + movq $0x3b, %rax /* SYS_execve */ + syscall + popq %rbp # xorq %rdi, %rdi # xorq %rsi, %rsi @@ -74,24 +104,6 @@ main: # movb $0x4, %al /* SYS_write */ # syscall - xorq %rdx, %rdx - movq $buff, %rdx - pushq %rcx - movq %rcx, %rcx - movb $0x8, %cl - movq $sysctl, (%rdx, %rcx, 1) - movq $model, (%rdx, %rcx, 2) - movq $0x0, (%rdx, %rcx, 4) - xorq %rdi, %rdi - xorq %rsi, %rsi - xorq %rax, %rax - movb $0x1, %dil - movq (%rdx, %rcx, 1), %rsi - movq $0x6, %rdx - movb $0x4, %al /* SYS_write */ - syscall - popq %rcx - xorq %rax, %rax retq @@ -104,4 +116,3 @@ main: lscpu: .asciz "/usr/local/bin/lscpu" model: .asciz "hw.model" ncpu: .asciz "hw.ncpu" - buff: .byte 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 |