Skip to content

Instantly share code, notes, and snippets.

@zah
Created November 20, 2011 22:14
Show Gist options
  • Select an option

  • Save zah/1381031 to your computer and use it in GitHub Desktop.

Select an option

Save zah/1381031 to your computer and use it in GitHub Desktop.
os_proc.asm
N_NIMCALL(TY77202*, Startcmd_77238)(NimStringDesc* Command_77240, NU8 Options_77243) {TY77202* Result_77244;TY45613* C_77245;TY45613* A_77247;NI I_77287;NI HEX3Atmp_77288;NI Res_77290;Result_77244 = 0;C_77245 = 0;
#line 80 "/Volumes/home/zahary/Projects/nim/lib/pure/osproc.nim"
C_77245 = nosparseCmdLine(Command_77240);A_77247 = 0;
#line 82 "/Volumes/home/zahary/Projects/nim/lib/pure/osproc.nim"
A_77247 = (TY45613*) newSeq(NTI45613, (NI64)(C_77245->Sup.len - 1));I_77287 = 0;HEX3Atmp_77288 = 0;
#line 83 "/Volumes/home/zahary/Projects/nim/lib/pure/osproc.nim"
HEX3Atmp_77288 = (NI64)(C_77245->Sup.len - 1);Res_77290 = 0;
#line 1154 "/Volumes/home/zahary/Projects/nim/lib/system.nim"
Res_77290 = 1;
#line 1155 "/Volumes/home/zahary/Projects/nim/lib/system.nim"
while (1) {if (!(Res_77290 <= HEX3Atmp_77288)) goto LA1;
#line 1154 "/Volumes/home/zahary/Projects/nim/lib/system.nim"
I_77287 = Res_77290;
#line 83 "/Volumes/home/zahary/Projects/nim/lib/pure/osproc.nim"
asgnRefNoCycle((void**) &A_77247->data[(NI64)(I_77287 - 1)], copyString(C_77245->data[I_77287]));
#line 1157 "/Volumes/home/zahary/Projects/nim/lib/system.nim"
Res_77290 += 1;} LA1: ;
#line 84 "/Volumes/home/zahary/Projects/nim/lib/pure/osproc.nim"
Result_77244 = nospstartProcess(C_77245->data[0], ((NimStringDesc*) &TMP2683), A_77247->data, A_77247->Sup.len, NIM_NIL, Options_77243);return Result_77244;}
Dump of assembler code for function Startcmd_77238:
0x00000001000b0e50 <Startcmd_77238+0>: push %rbp
0x00000001000b0e51 <Startcmd_77238+1>: mov %rsp,%rbp
0x00000001000b0e54 <Startcmd_77238+4>: push %r15
0x00000001000b0e56 <Startcmd_77238+6>: push %r14
0x00000001000b0e58 <Startcmd_77238+8>: push %r13
0x00000001000b0e5a <Startcmd_77238+10>: push %r12
0x00000001000b0e5c <Startcmd_77238+12>: push %rbx
0x00000001000b0e5d <Startcmd_77238+13>: sub $0x28,%rsp
0x00000001000b0e61 <Startcmd_77238+17>: mov %sil,-0x41(%rbp)
0x00000001000b0e65 <Startcmd_77238+21>: callq 0x1000c03d0 <nosparseCmdLine>
0x00000001000b0e6a <Startcmd_77238+26>: mov %rax,%r14
0x00000001000b0e6d <Startcmd_77238+29>: mov (%rax),%rsi
0x00000001000b0e70 <Startcmd_77238+32>: dec %rsi
0x00000001000b0e73 <Startcmd_77238+35>: lea 0x87a86(%rip),%rax # 0x100138900 <NTI45613>
0x00000001000b0e7a <Startcmd_77238+42>: mov (%rax),%rdi
0x00000001000b0e7d <Startcmd_77238+45>: callq 0x1000d03b0 <newSeq>
0x00000001000b0e82 <Startcmd_77238+50>: mov %rax,-0x40(%rbp)
0x00000001000b0e86 <Startcmd_77238+54>: mov (%r14),%rax
0x00000001000b0e89 <Startcmd_77238+57>: dec %rax
0x00000001000b0e8c <Startcmd_77238+60>: mov %rax,-0x38(%rbp)
0x00000001000b0e90 <Startcmd_77238+64>: test %rax,%rax
0x00000001000b0e93 <Startcmd_77238+67>: jle 0x1000b0f14 <Startcmd_77238+196>
0x00000001000b0e95 <Startcmd_77238+69>: mov $0x1,%r12d
0x00000001000b0e9b <Startcmd_77238+75>: mov -0x40(%rbp),%rax
0x00000001000b0e9f <Startcmd_77238+79>: lea 0x8(%rax),%r15
0x00000001000b0ea3 <Startcmd_77238+83>: jmp 0x1000b0ebd <Startcmd_77238+109>
0x00000001000b0ea5 <Startcmd_77238+85>: nopl 0x0(%rax,%rax,1)
0x00000001000b0eaa <Startcmd_77238+90>: nopw 0x0(%rax,%rax,1)
0x00000001000b0eb0 <Startcmd_77238+96>: mov %rbx,0x0(%r13)
0x00000001000b0eb4 <Startcmd_77238+100>: inc %r12
0x00000001000b0eb7 <Startcmd_77238+103>: cmp %r12,-0x38(%rbp)
0x00000001000b0ebb <Startcmd_77238+107>: jl 0x1000b0f14 <Startcmd_77238+196>
0x00000001000b0ebd <Startcmd_77238+109>: mov 0x10(%r14,%r12,8),%rdi
0x00000001000b0ec2 <Startcmd_77238+114>: callq 0x1000cf690 <copyString>
0x00000001000b0ec7 <Startcmd_77238+119>: mov %rax,%rbx
0x00000001000b0eca <Startcmd_77238+122>: lea (%r15,%r12,8),%r13
0x00000001000b0ece <Startcmd_77238+126>: test %rax,%rax
0x00000001000b0ed1 <Startcmd_77238+129>: je 0x1000b0ed8 <Startcmd_77238+136>
0x00000001000b0ed3 <Startcmd_77238+131>: addq $0x8,-0x10(%rax)
0x00000001000b0ed8 <Startcmd_77238+136>: mov 0x0(%r13),%rdx
0x00000001000b0edc <Startcmd_77238+140>: test %rdx,%rdx
0x00000001000b0edf <Startcmd_77238+143>: je 0x1000b0eb0 <Startcmd_77238+96>
0x00000001000b0ee1 <Startcmd_77238+145>: lea -0x10(%rdx),%rsi
0x00000001000b0ee5 <Startcmd_77238+149>: mov -0x10(%rdx),%rax
0x00000001000b0ee9 <Startcmd_77238+153>: sub $0x8,%rax
0x00000001000b0eed <Startcmd_77238+157>: mov %rax,-0x10(%rdx)
0x00000001000b0ef1 <Startcmd_77238+161>: cmp $0x7,%rax
0x00000001000b0ef5 <Startcmd_77238+165>: ja 0x1000b0eb0 <Startcmd_77238+96>
0x00000001000b0ef7 <Startcmd_77238+167>: lea 0x858c2(%rip),%rdi # 0x1001367c0 <Gch_12258>
0x00000001000b0efe <Startcmd_77238+174>: add $0x10,%rdi
0x00000001000b0f02 <Startcmd_77238+178>: callq 0x1000cc6a0 <Addzct_13801>
0x00000001000b0f07 <Startcmd_77238+183>: mov %rbx,0x0(%r13)
0x00000001000b0f0b <Startcmd_77238+187>: inc %r12
0x00000001000b0f0e <Startcmd_77238+190>: cmp %r12,-0x38(%rbp)
0x00000001000b0f12 <Startcmd_77238+194>: jge 0x1000b0ebd <Startcmd_77238+109>
0x00000001000b0f14 <Startcmd_77238+196>: mov -0x40(%rbp),%rdx
0x00000001000b0f18 <Startcmd_77238+200>: add $0x10,%rdx
0x00000001000b0f1c <Startcmd_77238+204>: mov 0x10(%r14),%rdi
0x00000001000b0f20 <Startcmd_77238+208>: movzbl -0x41(%rbp),%r9d
0x00000001000b0f25 <Startcmd_77238+213>: xor %r8d,%r8d
0x00000001000b0f28 <Startcmd_77238+216>: mov -0x40(%rbp),%rax
0x00000001000b0f2c <Startcmd_77238+220>: mov (%rax),%rcx
0x00000001000b0f2f <Startcmd_77238+223>: lea 0x4456a(%rip),%rsi # 0x1000f54a0 <TMP2675>
0x00000001000b0f36 <Startcmd_77238+230>: add $0x28,%rsp
0x00000001000b0f3a <Startcmd_77238+234>: pop %rbx
0x00000001000b0f3b <Startcmd_77238+235>: pop %r12
0x00000001000b0f3d <Startcmd_77238+237>: pop %r13
0x00000001000b0f3f <Startcmd_77238+239>: pop %r14
0x00000001000b0f41 <Startcmd_77238+241>: pop %r15
0x00000001000b0f43 <Startcmd_77238+243>: leaveq
0x00000001000b0f44 <Startcmd_77238+244>: jmpq 0x1000b0880 <nospstartProcess>
0x00000001000b0f49 <Startcmd_77238+249>: nopl 0x0(%rax)
proc startCmd*(command: string, options: set[TProcessOption] = {
poStdErrToStdOut, poUseShell}): PProcess =
## a simpler version of `startProcess` that parses the command line into
## program and arguments and then calls `startProcess` with the empty string
## for `workingDir` and the nil string table for `env`.
var c = parseCmdLine(command)
var a: seq[string]
newSeq(a, c.len-1) # avoid slicing for now (still unstable)
for i in 1 .. c.len-1: a[i-1] = c[i]
result = startProcess(command=c[0], args=a, options=options)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment