string to char array?

Kagamin via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Jun 5 11:30:52 PDT 2015


Well, reading assembler is good enough:

void f(int[] a)
{
   a[0]=0;
   a[1]=1;
   a[2]=2;
}

Here pointer is passed in rsi register and length - in rdi:

void f(int[]):
	push	rax
	test	rdi, rdi
	je	.LBB0_4
	mov	dword ptr [rsi], 0
	cmp	rdi, 1
	jbe	.LBB0_5
	mov	dword ptr [rsi + 4], 1
	cmp	rdi, 2
	jbe	.LBB0_6
	mov	dword ptr [rsi + 8], 2
	pop	rax
	ret
.LBB0_4:
	mov	edi, 55
	mov	esi, .L.str
	mov	edx, 5
	call	_d_arraybounds
.LBB0_5:
	mov	edi, 55
	mov	esi, .L.str
	mov	edx, 6
	call	_d_arraybounds
.LBB0_6:
	mov	edi, 55
	mov	esi, .L.str
	mov	edx, 7
	call	_d_arraybounds

You play with assembler generated for D code at 
http://ldc.acomirei.ru/


More information about the Digitalmars-d-learn mailing list