[BITS 16]
[org 0]
[section .text]

start:
	mov ax,cs
	mov ds,ax
	mov es,ax

	mov ah,03
	mov bh,0
	int 10h

	call _main
	jmp 0x1000:0

global _main
global _is_digit
global _strlen
global _atoi
global _scanf
global _print_short
global _printf
global _strcpy
global _strstr
global _bzero
global _putc
global _getch
global _bzero
global _strcmp

[segment .text]

%include "io.asm"


%define _ret -2
%define _i -4
%define _n -6
%define _off -8
%define _num -20
%define temp1 -22
%define _str 4

_atoi:
	push bp
	mov bp,sp
	sub sp,word 20
	push word 0
	push 4
	pop bx
	pop dx
	add bx,dx
	push bx
	lea bx,[bp+_num]
	pop dx
	imul dx,word 2
	add bx,dx
	push bx
	push 10000
	pop dx
	pop di
	mov [di],dx
	push dx
	pop ax
	push word 0
	push 3
	pop bx
	pop dx
	add bx,dx
	push bx
	lea bx,[bp+_num]
	pop dx
	imul dx,word 2
	add bx,dx
	push bx
	push 1000
	pop dx
	pop di
	mov [di],dx
	push dx
	pop ax
	push word 0
	push 2
	pop bx
	pop dx
	add bx,dx
	push bx
	lea bx,[bp+_num]
	pop dx
	imul dx,word 2
	add bx,dx
	push bx
	push 100
	pop dx
	pop di
	mov [di],dx
	push dx
	pop ax
	push word 0
	push 1
	pop bx
	pop dx
	add bx,dx
	push bx
	lea bx,[bp+_num]
	pop dx
	imul dx,word 2
	add bx,dx
	push bx
	push 10
	pop dx
	pop di
	mov [di],dx
	push dx
	pop ax
	push word 0
	push 0
	pop bx
	pop dx
	add bx,dx
	push bx
	lea bx,[bp+_num]
	pop dx
	imul dx,word 2
	add bx,dx
	push bx
	push 1
	pop dx
	pop di
	mov [di],dx
	push dx
	pop ax
	push 0
	pop ax
	mov [bp+_ret],ax
	push ax
	pop ax
	push word [bp+_str]
	call _strlen
	add sp,word 2
	push ax
	pop ax
	mov [bp+_n],ax
	push ax
	pop ax
	push word [bp+_n]
	push 1
	pop bx
	pop dx
	sub dx,bx
	push dx
	pop ax
	mov [bp+_off],ax
	push ax
	pop ax
	push 0
	pop ax
	mov [bp+_i],ax
	push ax
.L13:	
	push word [bp+_i]
	push word [bp+_n]
	pop bx
	pop dx
	cmp dx,bx
	jl .L14
	push 0
	jmp .L15
.L14:	
	push 1
.L15:	
	pop ax
	cmp ax,word 0
	je .L12
	sub sp,word 2
	push word 0
	push word [bp+_i]
	pop bx
	pop dx
	add bx,dx
	push bx
	mov bx,[bp+_str]
	pop dx
	push bx
	add bx,dx
	push bx
	pop bx
	mov al,[bx]
	cpush al
	pop word [bp+temp1]
	mov ax,'0'
	mov bx,word [bp+temp1]
	cmp ax,bx
	jne .L17
	jmp .L16
.L17:	
	mov ax,'1'
	mov bx,word [bp+temp1]
	cmp ax,bx
	jne .L18
	push word [bp+_ret]
	push 1
	push word 0
	push word [bp+_off]
	push word [bp+_i]
	pop bx
	pop dx
	sub dx,bx
	push dx
	pop bx
	pop dx
	add bx,dx
	push bx
	lea bx,[bp+_num]
	pop dx
	imul dx,word 2
	add bx,dx
	push bx
	pop bx
	mov dx,[bx]
	push dx
	pop bx
	pop dx
	imul bx,dx
	push bx
	pop bx
	pop dx
	add dx,bx
	push dx
	pop ax
	mov [bp+_ret],ax
	push ax
	pop ax
	jmp .L16
.L18:	
	mov ax,'2'
	mov bx,word [bp+temp1]
	cmp ax,bx
	jne .L19
	push word [bp+_ret]
	push 2
	push word 0
	push word [bp+_off]
	push word [bp+_i]
	pop bx
	pop dx
	sub dx,bx
	push dx
	pop bx
	pop dx
	add bx,dx
	push bx
	lea bx,[bp+_num]
	pop dx
	imul dx,word 2
	add bx,dx
	push bx
	pop bx
	mov dx,[bx]
	push dx
	pop bx
	pop dx
	imul bx,dx
	push bx
	pop bx
	pop dx
	add dx,bx
	push dx
	pop ax
	mov [bp+_ret],ax
	push ax
	pop ax
	jmp .L16
.L19:	
	mov ax,'3'
	mov bx,word [bp+temp1]
	cmp ax,bx
	jne .L20
	push word [bp+_ret]
	push 3
	push word 0
	push word [bp+_off]
	push word [bp+_i]
	pop bx
	pop dx
	sub dx,bx
	push dx
	pop bx
	pop dx
	add bx,dx
	push bx
	lea bx,[bp+_num]
	pop dx
	imul dx,word 2
	add bx,dx
	push bx
	pop bx
	mov dx,[bx]
	push dx
	pop bx
	pop dx
	imul bx,dx
	push bx
	pop bx
	pop dx
	add dx,bx
	push dx
	pop ax
	mov [bp+_ret],ax
	push ax
	pop ax
	jmp .L16
.L20:	
	mov ax,'4'
	mov bx,word [bp+temp1]
	cmp ax,bx
	jne .L21
	push word [bp+_ret]
	push 4
	push word 0
	push word [bp+_off]
	push word [bp+_i]
	pop bx
	pop dx
	sub dx,bx
	push dx
	pop bx
	pop dx
	add bx,dx
	push bx
	lea bx,[bp+_num]
	pop dx
	imul dx,word 2
	add bx,dx
	push bx
	pop bx
	mov dx,[bx]
	push dx
	pop bx
	pop dx
	imul bx,dx
	push bx
	pop bx
	pop dx
	add dx,bx
	push dx
	pop ax
	mov [bp+_ret],ax
	push ax
	pop ax
	jmp .L16
.L21:	
	mov ax,'5'
	mov bx,word [bp+temp1]
	cmp ax,bx
	jne .L22
	push word [bp+_ret]
	push 5
	push word 0
	push word [bp+_off]
	push word [bp+_i]
	pop bx
	pop dx
	sub dx,bx
	push dx
	pop bx
	pop dx
	add bx,dx
	push bx
	lea bx,[bp+_num]
	pop dx
	imul dx,word 2
	add bx,dx
	push bx
	pop bx
	mov dx,[bx]
	push dx
	pop bx
	pop dx
	imul bx,dx
	push bx
	pop bx
	pop dx
	add dx,bx
	push dx
	pop ax
	mov [bp+_ret],ax
	push ax
	pop ax
	jmp .L16
.L22:	
	mov ax,'6'
	mov bx,word [bp+temp1]
	cmp ax,bx
	jne .L23
	push word [bp+_ret]
	push 6
	push word 0
	push word [bp+_off]
	push word [bp+_i]
	pop bx
	pop dx
	sub dx,bx
	push dx
	pop bx
	pop dx
	add bx,dx
	push bx
	lea bx,[bp+_num]
	pop dx
	imul dx,word 2
	add bx,dx
	push bx
	pop bx
	mov dx,[bx]
	push dx
	pop bx
	pop dx
	imul bx,dx
	push bx
	pop bx
	pop dx
	add dx,bx
	push dx
	pop ax
	mov [bp+_ret],ax
	push ax
	pop ax
	jmp .L16
.L23:	
	mov ax,'7'
	mov bx,word [bp+temp1]
	cmp ax,bx
	jne .L24
	push word [bp+_ret]
	push 7
	push word 0
	push word [bp+_off]
	push word [bp+_i]
	pop bx
	pop dx
	sub dx,bx
	push dx
	pop bx
	pop dx
	add bx,dx
	push bx
	lea bx,[bp+_num]
	pop dx
	imul dx,word 2
	add bx,dx
	push bx
	pop bx
	mov dx,[bx]
	push dx
	pop bx
	pop dx
	imul bx,dx
	push bx
	pop bx
	pop dx
	add dx,bx
	push dx
	pop ax
	mov [bp+_ret],ax
	push ax
	pop ax
	jmp .L16
.L24:	
	mov ax,'8'
	mov bx,word [bp+temp1]
	cmp ax,bx
	jne .L25
	push word [bp+_ret]
	push 8
	push word 0
	push word [bp+_off]
	push word [bp+_i]
	pop bx
	pop dx
	sub dx,bx
	push dx
	pop bx
	pop dx
	add bx,dx
	push bx
	lea bx,[bp+_num]
	pop dx
	imul dx,word 2
	add bx,dx
	push bx
	pop bx
	mov dx,[bx]
	push dx
	pop bx
	pop dx
	imul bx,dx
	push bx
	pop bx
	pop dx
	add dx,bx
	push dx
	pop ax
	mov [bp+_ret],ax
	push ax
	pop ax
	jmp .L16
.L25:	
	mov ax,'9'
	mov bx,word [bp+temp1]
	cmp ax,bx
	jne .L26
	push word [bp+_ret]
	push 9
	push word 0
	push word [bp+_off]
	push word [bp+_i]
	pop bx
	pop dx
	sub dx,bx
	push dx
	pop bx
	pop dx
	add bx,dx
	push bx
	lea bx,[bp+_num]
	pop dx
	imul dx,word 2
	add bx,dx
	push bx
	pop bx
	mov dx,[bx]
	push dx
	pop bx
	pop dx
	imul bx,dx
	push bx
	pop bx
	pop dx
	add dx,bx
	push dx
	pop ax
	mov [bp+_ret],ax
	push ax
	pop ax
	jmp .L16
.L26:	
.L16:	
	inc word [bp+_i]
	push word [bp+_i]
	pop ax
	jmp .L13
.L12:	
	push word [bp+_ret]
	pop ax
	leave
	ret
%undef _ret
%undef _i
%undef _n
%undef _off
%undef _num
%undef temp1
%undef _str

%define _ch 4

_is_digit:
	push bp
	mov bp,sp
	sub sp,word 0
	push word [bp+_ch]
	push word '0'
	pop bx
	pop dx
	cmp dx,bx
	jge .L5
	push 0
	jmp .L6
.L5:	
	push 1
.L6:	
	push word [bp+_ch]
	push word '9'
	pop bx
	pop dx
	cmp dx,bx
	jle .L7
	push 0
	jmp .L8
.L7:	
	push 1
.L8:	
	pop bx
	pop ax
	and ax,bx
	push ax
	pop ax
	cmp ax,word 0
	je .L9
	sub sp,word 0
	push 1
	pop ax
	leave
	ret
	jmp .L4
.L9:	
.L4:	
	push 0
	pop ax
	leave
	ret
%undef _ch

%define _buffer -100
%define _ptr -102
%define _argc 4
%define _argv 8
%define _envp 10

_main:
	push bp
	mov bp,sp
	sub sp,word 102
	push 0
	pop ax
	mov [bp+_ptr],ax
	push ax
	pop ax
	push 100
	lea ax,[bp+_buffer]
	push ax
	call _bzero
	add sp,word 4
	push ax
	pop ax
	push C0
	lea ax,[bp+_buffer]
	push ax
	call _strcpy
	add sp,word 4
	push ax
	pop ax
	lea ax,[bp+_buffer]
	push ax
	call _printf
	add sp,word 2
	push ax
	pop ax
	push C1
	lea ax,[bp+_buffer]
	push ax
	call _strstr
	add sp,word 4
	push ax
	pop ax
	mov [bp+_ptr],ax
	push ax
	pop ax
	push word [bp+_ptr]
	push 0
	pop bx
	pop dx
	cmp dx,bx
	jne .L1
	push 0
	jmp .L2
.L1:	
	push 1
.L2:	
	pop ax
	cmp ax,word 0
	je .L3
	sub sp,word 0
	push word [bp+_ptr]
	push C2
	call _printf
	add sp,word 4
	push ax
	pop ax
	jmp .L0
.L3:	
.L0:	
	push 0
	pop ax
	leave
	ret
%undef _buffer
%undef _ptr
%undef _argc
%undef _argv
%undef _envp

%define _ret -2
%define _n -4
%define _byte_array -14
%define _buffer -24
%define _index -26
%define _number 4

_print_short:
	push bp
	mov bp,sp
	sub sp,word 26
	push 0
	pop ax
	mov [bp+_ret],ax
	push ax
	pop ax
	push word 0
	push 0
	pop bx
	pop dx
	add bx,dx
	push bx
	mov al,[bp+_byte_array]
	cpush al
	push word '0'
	cpop al
	pop di
	mov [di],al
	cpush al
	pop ax
	push word 0
	push 1
	pop bx
	pop dx
	add bx,dx
	push bx
	mov al,[bp+_byte_array]
	cpush al
	push word '1'
	cpop al
	pop di
	mov [di],al
	cpush al
	pop ax
	push word 0
	push 2
	pop bx
	pop dx
	add bx,dx
	push bx
	mov al,[bp+_byte_array]
	cpush al
	push word '2'
	cpop al
	pop di
	mov [di],al
	cpush al
	pop ax
	push word 0
	push 3
	pop bx
	pop dx
	add bx,dx
	push bx
	mov al,[bp+_byte_array]
	cpush al
	push word '3'
	cpop al
	pop di
	mov [di],al
	cpush al
	pop ax
	push word 0
	push 4
	pop bx
	pop dx
	add bx,dx
	push bx
	mov al,[bp+_byte_array]
	cpush al
	push word '4'
	cpop al
	pop di
	mov [di],al
	cpush al
	pop ax
	push word 0
	push 5
	pop bx
	pop dx
	add bx,dx
	push bx
	mov al,[bp+_byte_array]
	cpush al
	push word '5'
	cpop al
	pop di
	mov [di],al
	cpush al
	pop ax
	push word 0
	push 6
	pop bx
	pop dx
	add bx,dx
	push bx
	mov al,[bp+_byte_array]
	cpush al
	push word '6'
	cpop al
	pop di
	mov [di],al
	cpush al
	pop ax
	push word 0
	push 7
	pop bx
	pop dx
	add bx,dx
	push bx
	mov al,[bp+_byte_array]
	cpush al
	push word '7'
	cpop al
	pop di
	mov [di],al
	cpush al
	pop ax
	push word 0
	push 8
	pop bx
	pop dx
	add bx,dx
	push bx
	mov al,[bp+_byte_array]
	cpush al
	push word '8'
	cpop al
	pop di
	mov [di],al
	cpush al
	pop ax
	push word 0
	push 9
	pop bx
	pop dx
	add bx,dx
	push bx
	mov al,[bp+_byte_array]
	cpush al
	push word '9'
	cpop al
	pop di
	mov [di],al
	cpush al
	pop ax
	push word [bp+_number]
	push 0
	pop bx
	pop dx
	cmp dx,bx
	je .L53
	push 0
	jmp .L54
.L53:	
	push 1
.L54:	
	pop ax
	cmp ax,word 0
	je .L55
	sub sp,word 0
	push word '0'
	call _putc
	add sp,word 2
	push ax
	pop ax
	jmp .L52
.L55:	
.L52:	
	push 0
	pop ax
	mov [bp+_index],ax
	push ax
	pop ax
.L57:	
	push word [bp+_number]
	pop ax
	cmp ax,word 0
	je .L56
	sub sp,word 0
	push word [bp+_number]
	push 10
	pop bx
	pop ax
	xor dx,dx
	idiv bx
	push dx
	pop ax
	mov [bp+_n],ax
	push ax
	pop ax
	push word [bp+_number]
	push 10
	pop bx
	pop ax
	xor dx,dx
	idiv bx
	push ax
	pop ax
	mov [bp+_number],ax
	push ax
	pop ax
	push word 0
	push word [bp+_index]
	pop bx
	pop dx
	add bx,dx
	push bx
	mov al,[bp+_buffer]
	cpush al
	push word 0
	push word [bp+_n]
	pop bx
	pop dx
	add bx,dx
	push bx
	mov al,[bp+_byte_array]
	cpush al
	pop bx
	mov al,[bx]
	cpush al
	cpop al
	pop di
	mov [di],al
	cpush al
	pop ax
	inc word [bp+_index]
	push word [bp+_index]
	pop ax
	jmp .L57
.L56:	
	dec word [bp+_index]
	push word [bp+_index]
	pop ax
.L59:	
	push word [bp+_index]
	push 0
	pop bx
	pop dx
	cmp dx,bx
	jge .L60
	push 0
	jmp .L61
.L60:	
	push 1
.L61:	
	pop ax
	cmp ax,word 0
	je .L58
	sub sp,word 0
	push word 0
	push word [bp+_index]
	pop bx
	pop dx
	add bx,dx
	push bx
	mov al,[bp+_buffer]
	cpush al
	pop bx
	mov al,[bx]
	cpush al
	call _putc
	add sp,word 2
	push ax
	pop ax
	dec word [bp+_index]
	push word [bp+_index]
	pop ax
	jmp .L59
.L58:	
	push word [bp+_ret]
	pop ax
	leave
	ret
%undef _ret
%undef _n
%undef _byte_array
%undef _buffer
%undef _index
%undef _number

%define _ptr -2
%define _ptr0 -4
%define _ptr1 -6
%define _i -8
%define _j -10
%define _ret -12
%define _fmt 4

_printf:
	push bp
	mov bp,sp
	sub sp,word 12
	push 0
	pop ax
	mov [bp+_ret],ax
	push ax
	pop ax
	push word [bp+_fmt]
	pop ax
	mov [bp+_ptr],ax
	push ax
	pop ax
	push 2
	pop ax
	mov [bp+_i],ax
	push ax
	pop ax
.L63:	
	mov di,[bp+_ptr]
	mov al,[di]
	cpush al
	cpop al
	cmp al,byte 0
	je .L62
	sub sp,word 0
	mov di,[bp+_ptr]
	mov al,[di]
	cpush al
	push word '%'
	pop bx
	pop dx
	cmp dx,bx
	je .L65
	push 0
	jmp .L66
.L65:	
	push 1
.L66:	
	pop ax
	cmp ax,word 0
	je .L67
	sub sp,word 0
	inc word [bp+_ptr]
	push word [bp+_ptr]
	pop ax
	mov di,[bp+_ptr]
	mov al,[di]
	cpush al
	push word '%'
	pop bx
	pop dx
	cmp dx,bx
	je .L69
	push 0
	jmp .L70
.L69:	
	push 1
.L70:	
	pop ax
	cmp ax,word 0
	je .L71
	sub sp,word 0
	push word '%'
	call _putc
	add sp,word 2
	push ax
	pop ax
	inc word [bp+_ptr]
	push word [bp+_ptr]
	pop ax
	jmp .L68
.L71:	
	mov di,[bp+_ptr]
	mov al,[di]
	cpush al
	push word 'x'
	pop bx
	pop dx
	cmp dx,bx
	je .L72
	push 0
	jmp .L73
.L72:	
	push 1
.L73:	
	pop ax
	cmp ax,word 0
	je .L74
	sub sp,word 0
	lea ax,[bp+_fmt]
	push ax
	push word [bp+_i]
	pop bx
	pop dx
	add dx,bx
	push dx
	pop ax
	mov [bp+_ptr0],ax
	push ax
	pop ax
	push bp
	mov ax,[bp+_ptr0]
	mov bp,ax
	mov dx,[bp]
	pop bp
	push dx
	call _tohex
	add sp,word 2
	push 2
	mov bx,[bp+_i]
	pop dx
	add bx,dx
	push bx
	pop ax
	mov [bp+_i],ax
	push ax
	pop ax
	inc word [bp+_ptr]
	push word [bp+_ptr]
	pop ax
	jmp .L68
.L74:	
	mov di,[bp+_ptr]
	mov al,[di]
	cpush al
	push word 'd'
	pop bx
	pop dx
	cmp dx,bx
	je .L75
	push 0
	jmp .L76
.L75:	
	push 1
.L76:	
	pop ax
	cmp ax,word 0
	je .L77
	sub sp,word 0
	lea ax,[bp+_fmt]
	push ax
	push word [bp+_i]
	pop bx
	pop dx
	add dx,bx
	push dx
	pop ax
	mov [bp+_ptr0],ax
	push ax
	pop ax
	push bp
	mov ax,[bp+_ptr0]
	mov bp,ax
	mov dx,[bp]
	pop bp
	push dx
	call _print_short
	add sp,word 2
	push ax
	pop ax
	push 2
	mov bx,[bp+_i]
	pop dx
	add bx,dx
	push bx
	pop ax
	mov [bp+_i],ax
	push ax
	pop ax
	inc word [bp+_ptr]
	push word [bp+_ptr]
	pop ax
	jmp .L68
.L77:	
	mov di,[bp+_ptr]
	mov al,[di]
	cpush al
	push word 's'
	pop bx
	pop dx
	cmp dx,bx
	je .L78
	push 0
	jmp .L79
.L78:	
	push 1
.L79:	
	pop ax
	cmp ax,word 0
	je .L80
	sub sp,word 0
	lea ax,[bp+_fmt]
	push ax
	push word [bp+_i]
	pop bx
	pop dx
	add dx,bx
	push dx
	pop ax
	mov [bp+_ptr0],ax
	push ax
	pop ax
	push bp
	mov ax,[bp+_ptr0]
	mov bp,ax
	mov dx,[bp]
	pop bp
	push dx
	pop ax
	mov [bp+_ptr1],ax
	push ax
	pop ax
.L82:	
	mov di,[bp+_ptr1]
	mov al,[di]
	cpush al
	cpop al
	cmp al,byte 0
	je .L81
	sub sp,word 0
	mov di,[bp+_ptr1]
	mov al,[di]
	cpush al
	call _putc
	add sp,word 2
	push ax
	pop ax
	inc word [bp+_ptr1]
	push word [bp+_ptr1]
	pop ax
	jmp .L82
.L81:	
	push 2
	mov bx,[bp+_i]
	pop dx
	add bx,dx
	push bx
	pop ax
	mov [bp+_i],ax
	push ax
	pop ax
	inc word [bp+_ptr]
	push word [bp+_ptr]
	pop ax
	jmp .L68
.L80:	
	sub sp,word 0
	inc word [bp+_ptr]
	push word [bp+_ptr]
	pop ax
.L68:	
	jmp .L64
.L67:	
	sub sp,word 0
	mov di,[bp+_ptr]
	mov al,[di]
	cpush al
	call _putc
	add sp,word 2
	push ax
	pop ax
	inc word [bp+_ptr]
	push word [bp+_ptr]
	pop ax
.L64:	
	jmp .L63
.L62:	
	push 0
	pop ax
	leave
	ret
%undef _ptr
%undef _ptr0
%undef _ptr1
%undef _i
%undef _j
%undef _ret
%undef _fmt

%define _ptr -2
%define _p -4
%define _temp -6
%define _buffer -106
%define _offset -108
%define _ch -110
%define _count -112
%define _fmt 4

_scanf:
	push bp
	mov bp,sp
	sub sp,word 112
	push 0
	pop ax
	mov [bp+_offset],ax
	push ax
	pop ax
	push 2
	pop ax
	mov [bp+_count],ax
	push ax
	pop ax
	lea ax,[bp+_fmt]
	push ax
	push word [bp+_count]
	pop bx
	pop dx
	add dx,bx
	push dx
	pop ax
	mov [bp+_ptr],ax
	push ax
	pop ax
	push word [bp+_fmt]
	pop ax
	mov [bp+_p],ax
	push ax
.L28:	
	mov di,[bp+_p]
	mov al,[di]
	cpush al
	cpop al
	cmp al,byte 0
	je .L27
	sub sp,word 0
	mov di,[bp+_p]
	mov al,[di]
	cpush al
	push word '%'
	pop bx
	pop dx
	cmp dx,bx
	je .L30
	push 0
	jmp .L31
.L30:	
	push 1
.L31:	
	pop ax
	cmp ax,word 0
	je .L32
	sub sp,word 0
	inc word [bp+_p]
	push word [bp+_p]
	pop ax
	mov di,[bp+_p]
	mov al,[di]
	cpush al
	push word 'd'
	pop bx
	pop dx
	cmp dx,bx
	je .L34
	push 0
	jmp .L35
.L34:	
	push 1
.L35:	
	pop ax
	cmp ax,word 0
	je .L36
	sub sp,word 0
	push bp
	mov ax,[bp+_ptr]
	mov bp,ax
	mov dx,[bp]
	pop bp
	push dx
	pop ax
	mov [bp+_temp],ax
	push ax
	pop ax
	call _getch
	push ax
	pop ax
	mov [bp+_ch],ax
	push ax
	pop ax
	push word [bp+_ch]
	call _putc
	add sp,word 2
	push ax
	pop ax
	push 0
	pop ax
	mov [bp+_offset],ax
	push ax
	pop ax
.L38:	
	push word [bp+_ch]
	call _is_digit
	add sp,word 2
	push ax
	push word [bp+_ch]
	push word 13
	pop bx
	pop dx
	cmp dx,bx
	jne .L39
	push 0
	jmp .L40
.L39:	
	push 1
.L40:	
	push word [bp+_ch]
	push word 10
	pop bx
	pop dx
	cmp dx,bx
	jne .L41
	push 0
	jmp .L42
.L41:	
	push 1
.L42:	
	pop bx
	pop ax
	and ax,bx
	push ax
	pop bx
	pop ax
	and ax,bx
	push ax
	pop ax
	cmp ax,word 0
	je .L37
	sub sp,word 0
	push word 0
	push word [bp+_offset]
	pop bx
	pop dx
	add bx,dx
	push bx
	mov al,[bp+_buffer]
	cpush al
	push word [bp+_ch]
	cpop al
	pop di
	mov [di],al
	cpush al
	pop ax
	inc word [bp+_offset]
	push word [bp+_offset]
	pop ax
	call _getch
	push ax
	pop ax
	mov [bp+_ch],ax
	push ax
	pop ax
	push word [bp+_ch]
	call _putc
	add sp,word 2
	push ax
	pop ax
	jmp .L38
.L37:	
	push word 0
	push word [bp+_offset]
	pop bx
	pop dx
	add bx,dx
	push bx
	mov al,[bp+_buffer]
	cpush al
	push word 0
	cpop al
	pop di
	mov [di],al
	cpush al
	pop ax
	lea ax,[bp+_buffer]
	push ax
	call _atoi
	add sp,word 2
	push ax
	pop ax
	mov di,[bp+_temp]
	mov [di],ax
	push ax
	pop ax
	push word [bp+_count]
	push 2
	pop bx
	pop dx
	add dx,bx
	push dx
	pop ax
	mov [bp+_count],ax
	push ax
	pop ax
	lea ax,[bp+_fmt]
	push ax
	push word [bp+_count]
	pop bx
	pop dx
	add dx,bx
	push dx
	pop ax
	mov [bp+_ptr],ax
	push ax
	pop ax
	jmp .L33
.L36:	
	mov di,[bp+_p]
	mov al,[di]
	cpush al
	push word 'f'
	pop bx
	pop dx
	cmp dx,bx
	je .L43
	push 0
	jmp .L44
.L43:	
	push 1
.L44:	
	pop ax
	cmp ax,word 0
	je .L45
	sub sp,word 0
	nop
	jmp .L33
.L45:	
	mov di,[bp+_p]
	mov al,[di]
	cpush al
	push word 's'
	pop bx
	pop dx
	cmp dx,bx
	je .L46
	push 0
	jmp .L47
.L46:	
	push 1
.L47:	
	pop ax
	cmp ax,word 0
	je .L48
	sub sp,word 0
	nop
	jmp .L33
.L48:	
	mov di,[bp+_p]
	mov al,[di]
	cpush al
	push word 'c'
	pop bx
	pop dx
	cmp dx,bx
	je .L49
	push 0
	jmp .L50
.L49:	
	push 1
.L50:	
	pop ax
	cmp ax,word 0
	je .L51
	sub sp,word 0
	nop
	jmp .L33
.L51:	
.L33:	
	jmp .L29
.L32:	
	sub sp,word 0
	nop
.L29:	
	inc word [bp+_p]
	push word [bp+_p]
	pop ax
	jmp .L28
.L27:	
	push 0
	pop ax
	leave
	ret
%undef _ptr
%undef _p
%undef _temp
%undef _buffer
%undef _offset
%undef _ch
%undef _count
%undef _fmt

%define _a 4
%define _b 6

_strcpy:
	push bp
	mov bp,sp
	sub sp,word 0
.L84:	
	mov di,[bp+_b]
	mov al,[di]
	cpush al
	cpop al
	mov di,[bp+_a]
	mov [di],al
	cpush al
	cpop al
	cmp al,byte 0
	je .L83
	sub sp,word 0
	inc word [bp+_a]
	push word [bp+_a]
	pop ax
	inc word [bp+_b]
	push word [bp+_b]
	pop ax
	jmp .L84
.L83:	
	leave
	ret

%undef _a
%undef _b

%define _n -2
%define _ptr 4

_strlen:
	push bp
	mov bp,sp
	sub sp,word 2
	push 0
	pop ax
	mov [bp+_n],ax
	push ax
	pop ax
.L11:	
	mov di,[bp+_ptr]
	mov al,[di]
	cpush al
	cpop al
	cmp al,byte 0
	je .L10
	sub sp,word 0
	inc word [bp+_n]
	push word [bp+_n]
	pop ax
	inc word [bp+_ptr]
	push word [bp+_ptr]
	pop ax
	jmp .L11
.L10:	
	push word [bp+_n]
	pop ax
	leave
	ret
%undef _n
%undef _ptr



[section .data]

C0: db 'HELLO WORLD',13,10,0
C1: db 'WORLD',0
C2: db 'ptr = %s',0

[section .bss]

answer: resb 20

