Re: VLA in Assembler

2014-12-17 Thread Foo via Digitalmars-d-learn
On Wednesday, 17 December 2014 at 16:10:40 UTC, Adam D. Ruppe wrote: On Wednesday, 17 December 2014 at 14:11:32 UTC, Foo wrote: asm { mov EAX, n; mov [arr + 8], ESP; sub [ESP], EAX; mov [arr + 0], EAX; } but that doe

Re: VLA in Assembler

2014-12-17 Thread Namespaces via Digitalmars-d-learn
On Wednesday, 17 December 2014 at 15:20:28 UTC, btdc wrote: On Wednesday, 17 December 2014 at 14:11:32 UTC, Foo wrote: And it is using malloc... ;) I wanted something that increases the stack pointer ESP. e.g. void main() { int[] arr; int n = 42; writeln(ar

Re: VLA in Assembler

2014-12-17 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 17 December 2014 at 14:11:32 UTC, Foo wrote: asm { mov EAX, n; mov [arr + 8], ESP; sub [ESP], EAX; mov [arr + 0], EAX; } but that does not work... That wouldn't work even with malloc remember, an i

Re: VLA in Assembler

2014-12-17 Thread btdc via Digitalmars-d-learn
On Wednesday, 17 December 2014 at 14:11:32 UTC, Foo wrote: And it is using malloc... ;) I wanted something that increases the stack pointer ESP. e.g. void main() { int[] arr; int n = 42; writeln(arr.length); writeln(arr.ptr); asm {

Re: VLA in Assembler

2014-12-17 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 17 December 2014 at 12:29:53 UTC, Foo wrote: And how? I'm on Windows. Digital Mars sells an obj2asm function that will disassemble dmd generated code. I think it is in the $15 basic utility package. But VLA/alloca is more complex than a regular function - the compiler needs to

Re: VLA in Assembler

2014-12-17 Thread Foo via Digitalmars-d-learn
And it is using malloc... ;) I wanted something that increases the stack pointer ESP. e.g. void main() { int[] arr; int n = 42; writeln(arr.length); writeln(arr.ptr); asm { mov EAX, n; mov [arr + 8], ES

Re: VLA in Assembler

2014-12-17 Thread btdc via Digitalmars-d-learn
On Wednesday, 17 December 2014 at 12:54:44 UTC, btdc wrote: On Wednesday, 17 December 2014 at 10:35:39 UTC, Foo wrote: Hi, Could someone explain me, if and how it is possible to allocate a variable length array with inline assembly? Somewhat like int[] arr; int n = 42; asm { // allocat

Re: VLA in Assembler

2014-12-17 Thread btdc via Digitalmars-d-learn
On Wednesday, 17 December 2014 at 10:35:39 UTC, Foo wrote: Hi, Could someone explain me, if and how it is possible to allocate a variable length array with inline assembly? Somewhat like int[] arr; int n = 42; asm { // allocate n stack space for arr } I know it is dangerous and al

Re: VLA in Assembler

2014-12-17 Thread Foo via Digitalmars-d-learn
On Wednesday, 17 December 2014 at 12:15:23 UTC, uri wrote: On Wednesday, 17 December 2014 at 11:39:43 UTC, Foo wrote: On Wednesday, 17 December 2014 at 10:59:09 UTC, bearophile wrote: Foo: Hi, Could someone explain me, if and how it is possible to allocate a variable length array with inline

Re: VLA in Assembler

2014-12-17 Thread uri via Digitalmars-d-learn
On Wednesday, 17 December 2014 at 11:39:43 UTC, Foo wrote: On Wednesday, 17 December 2014 at 10:59:09 UTC, bearophile wrote: Foo: Hi, Could someone explain me, if and how it is possible to allocate a variable length array with inline assembly? Somewhat like int[] arr; int n = 42; asm {

Re: VLA in Assembler

2014-12-17 Thread Foo via Digitalmars-d-learn
On Wednesday, 17 December 2014 at 10:59:09 UTC, bearophile wrote: Foo: Hi, Could someone explain me, if and how it is possible to allocate a variable length array with inline assembly? Somewhat like int[] arr; int n = 42; asm { // allocate n stack space for arr } I know it is dan

Re: VLA in Assembler

2014-12-17 Thread bearophile via Digitalmars-d-learn
Foo: Hi, Could someone explain me, if and how it is possible to allocate a variable length array with inline assembly? Somewhat like int[] arr; int n = 42; asm { // allocate n stack space for arr } I know it is dangerous and all that, but I just want it know. ;) Doing it with a

VLA in Assembler

2014-12-17 Thread Foo via Digitalmars-d-learn
Hi, Could someone explain me, if and how it is possible to allocate a variable length array with inline assembly? Somewhat like int[] arr; int n = 42; asm { // allocate n stack space for arr } I know it is dangerous and all that, but I just want it know. ;)