VLA in Assembler

btdc via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Dec 17 07:20:28 PST 2014


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 {
> 		mov EAX, n;
> 		mov [arr + 8], ESP;
> 		sub [ESP], EAX;
> 		mov [arr + 0], EAX;
> 	}
> 	
> 	writeln(arr.length);
> 	//writeln(arr[0]);
> }
> ----
> but that does not work...

You cant always get what you want. try more, speak less.



More information about the Digitalmars-d-learn mailing list