global		main
%define 	stdin 	00h
%define 	stdout 	01h
%define		stderr	02h
%define		write	04h
%define		read	03h

section	.data
	prompt		db 0Ah, "> "
	prompt_len	equ $-prompt
	buffer		db 0Ah, 0Ah
	buffer_len	equ $-buffer
	myinfo		db "CARDS: by Mike Pellegrino (q)uit", 0Ah
	myinfo_len	equ $-myinfo
	return		dw 0000h
	
section	.text
main:
_start:
	mov eax, write
	mov ebx, stdout
	mov ecx, myinfo
	mov edx, myinfo_len
	int 80h
	
top:
	
	;;
	;; rand
	;;
	mov eax, 78
	int 80h
	mov [return], eax
	
	mov eax, write
	mov ebx, stdout
	mov ecx, return
	mov edx, 2
	int 80h
	mov eax, write
	mov ebx, stdout
	mov ecx, prompt
	mov edx, prompt_len
	int 80h

	mov eax, read
	mov ebx, stdin
	mov ecx, buffer
	mov edx, buffer_len
	int 80h

	mov al, [buffer]
	cmp al, "q"
	je quit

	
	jmp top
	
quit:	;; terminate control
	mov ebx, 0
	mov eax, 1
	int 80h

;;; nasm -f elf cards.asm
;;; ld cards.o -o cards
