All pastes #235661 Raw Edit

multiply

public text v1 · immutable
·published 2006-11-03 11:27 UTC
rendered paste body
section .data
	global _start
	char db ' '
	value1 dw 2
	value2 dw 3

section .text
_start:
	
	mov eax, [value1]
	mov ebx, [value2]
	mov ecx, 0

	call multiply
	
	call draw

	call linefeed
	call exit

multiply:
	
	;; add registers ax to bx.
	add ecx, eax

	dec ebx
	cmp ebx, 0
	jne multiply

	ret
	
draw:
	
	;; draw a number of dots to represent the
	;; answer to the addition.
	
	call dot
	
	dec ecx
	cmp ecx, 0
	jne draw

	ret

exit:	
	mov eax,1
	mov ebx,0
	int 80h
	ret

linefeed:	
	
	mov [char],  byte 10
	call pr_char

	ret
	
dot:	

	mov [char],  byte '.'
	call pr_char

	ret

pr_char:	
	push eax
	push ebx
	push ecx
	push edx

	mov eax,4            
	mov ebx,1
	mov ecx, char
	mov edx,1
	int 80h              

	pop edx
	pop ecx
	pop ebx
	pop eax

	ret