tema 2

mail@pastecode.io avatar
unknown
assembly_x86
2 months ago
1.4 kB
1
Indexable
Never
//Cerinta 0



.data



	mLines: .space 4

	nCols: .space 4

	p: .space 4

	x: .space 4

	y: .space 4

	i: .space 4

	j: .space 4

	matrix: .space 1600

	formatPrintf: .asciz "%d "

	endl: .asciz "\n"

	formatScanf: .asciz "%d %d %d"

	formatScanfxy: .asciz "%d %d"

	

.text



.global main



main:



	push $p

	push $nCols

	push $mLines

	push $formatScanf

	call scanf

	pop %ebx

	pop %ebx

	pop %ebx

	pop %ebx

	

	//addl $8, %esp

	

	mov $0, %ecx

	lea matrix, %edi

	//lea matrix, %edi

	

et_p:



	cmp %ecx, p

	je et_cont

	

	push $y

	push $x

	push $formatScanfxy

	call scanf

	pop %ebx

	pop %ebx

	pop %ebx

	

	//nu sunt sigur

	

	mov x, %eax

	mull nCols

	addl y, %eax

	

	movl $1, (%edi, %eax, 4)

	

	incl %ecx

	jmp et_p

	

et_cont:



	movl $0, i

	movl $0, j

		

for_lines:



	mov i, %ecx

	cmp %ecx, mLines

	je et_exit

	

	movl $0, j

	

for_col:	

	

	mov j, %ecx

	cmp %ecx, nCols

	je et_cont_for_lines

	

	//aici se scrie cod

	//afisare:

	

	movl i, %eax

	mull nCols

	addl j, %eax

	movl (%edi, %eax, 4), %ebx

	

	push %ebx

	push $formatPrintf

	call printf

	pop %ebx

	pop %ebx

	

	//afisare ebx

	incl j

	jmp for_col

	

et_cont_for_lines:

	

	push $endl

	call printf

	pop %ebx

	

	push $0

	call fflush

	pop %ebx

	

	incl i

	jmp for_lines

	

et_exit:



	movl $1, %eax

	movl $0, %ebx

	int $0x80

	

	

	

	

Leave a Comment