; vim: ft=fasm :
;---------------------------------------------------------------------
driver_init:
	ret

code 'bye',bye
	sub ebx,ebx	;Return exit status 0
	mov eax,ebx
	inc eax		;1 = sys_exit
	int 80h
code 'cr',cr
	upsh 10
	call emit
	ret
code 'emit',emit
        upsh [no_echo]
	cmp eax, 1
	drop
	jz .a
	push ebx
	push ecx
	push edx
	mov ebx, 1	;stdout
	mov edx, ebx	;count
	lea ecx, [esp-4]
	mov [ecx], eax
	mov eax, 4	;sys_write
	int 80h
	pop edx
	pop ecx
	pop ebx
.a:	drop
	upsh 0
	upop [no_echo]
	ret

no_echo dd 0
code 'key',key
        upsh 1
	upop [no_echo]
	dup
	push ebx
	push ecx
	push edx
	sub ebx,ebx	;0 = stdin
	mov edx, 1	;count
	lea ecx, [esp-4]
	mov eax, 3	;sys_read
	int 80h
	mov eax, [ecx]
	pop edx
	pop ecx
	pop ebx
	ret
