[BITS 16]
[section .text]

org 100h

	call _main

	ret

global _is_digit
global _strlen
global _atoi
global _scanf
global _print_short
global _printf
global _strcpy
global _get_fat
global _gets
global _bzero
global _findsector2
global _load_program
global _strcmp
global _link_program
global _main
global _putc
global _getch
global _readline
global _getch
global _putc
global _readfile
global _tohex
global _exit

[segment .text]

%include "io.asm"

struc _reloc
   ._addr0 resw 1
   ._addr1 resw 1
   ._is_label resw 1
endstruc


%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
	mov bx,word 4
	pop dx
	add bx,dx
	push bx
	lea bx,[bp+_num]
	pop dx
	imul dx,word 2
	add bx,dx
	push bx
	mov dx,word 10000
	pop di
	mov [di],dx
	mov ax,dx
	push word 0
	mov bx,word 3
	pop dx
	add bx,dx
	push bx
	lea bx,[bp+_num]
	pop dx
	imul dx,word 2
	add bx,dx
	push bx
	mov dx,word 1000
	pop di
	mov [di],dx
	mov ax,dx
	push word 0
	mov bx,word 2
	pop dx
	add bx,dx
	push bx
	lea bx,[bp+_num]
	pop dx
	imul dx,word 2
	add bx,dx
	push bx
	mov dx,word 100
	pop di
	mov [di],dx
	mov ax,dx
	push word 0
	mov bx,word 1
	pop dx
	add bx,dx
	push bx
	lea bx,[bp+_num]
	pop dx
	imul dx,word 2
	add bx,dx
	push bx
	mov dx,word 10
	pop di
	mov [di],dx
	mov ax,dx
	push word 0
	mov bx,word 0
	pop dx
	add bx,dx
	push bx
	lea bx,[bp+_num]
	pop dx
	imul dx,word 2
	add bx,dx
	push bx
	mov dx,word 1
	pop di
	mov [di],dx
	mov ax,dx
	mov [bp+_ret],word 0
	push word [bp+_str]
	call _strlen
	add sp,word 2
	mov [bp+_n],ax
	push word [bp+_n]
	mov bx,word 1
	pop dx
	sub dx,bx
	mov [bp+_off],dx
	mov [bp+_i],word 0
	push ax
.L9:	
	push word [bp+_i]
	mov bx,word [bp+_n]
	pop dx
	cmp dx,bx
	jl .L10
	mov ax,word 0
	jmp .L11
.L10:	
	mov ax,word 1
.L11:	
	cmp ax,word 0
	je .L8
	sub sp,word 2
	push word 0
	mov bx,word [bp+_i]
	pop dx
	add bx,dx
	push bx
	mov bx,[bp+_str]
	pop dx
	push bx
	add bx,dx
	mov al,[bx]
	cpush al
	pop word [bp+temp1]
	mov ax,'0'
	mov bx,word [bp+temp1]
	cmp ax,bx
	jne .L13
	jmp .L12
.L13:	
	mov ax,'1'
	mov bx,word [bp+temp1]
	cmp ax,bx
	jne .L14
	push word [bp+_ret]
	push 1
	push word 0
	push word [bp+_off]
	mov bx,word [bp+_i]
	pop dx
	sub dx,bx
	mov bx,dx
	pop dx
	add bx,dx
	push bx
	lea bx,[bp+_num]
	pop dx
	imul dx,word 2
	add bx,dx
	mov bx,word [bx]
	pop dx
	imul bx,dx
	pop dx
	add dx,bx
	mov [bp+_ret],dx
	jmp .L12
.L14:	
	mov ax,'2'
	mov bx,word [bp+temp1]
	cmp ax,bx
	jne .L15
	push word [bp+_ret]
	push 2
	push word 0
	push word [bp+_off]
	mov bx,word [bp+_i]
	pop dx
	sub dx,bx
	mov bx,dx
	pop dx
	add bx,dx
	push bx
	lea bx,[bp+_num]
	pop dx
	imul dx,word 2
	add bx,dx
	mov bx,word [bx]
	pop dx
	imul bx,dx
	pop dx
	add dx,bx
	mov [bp+_ret],dx
	jmp .L12
.L15:	
	mov ax,'3'
	mov bx,word [bp+temp1]
	cmp ax,bx
	jne .L16
	push word [bp+_ret]
	push 3
	push word 0
	push word [bp+_off]
	mov bx,word [bp+_i]
	pop dx
	sub dx,bx
	mov bx,dx
	pop dx
	add bx,dx
	push bx
	lea bx,[bp+_num]
	pop dx
	imul dx,word 2
	add bx,dx
	mov bx,word [bx]
	pop dx
	imul bx,dx
	pop dx
	add dx,bx
	mov [bp+_ret],dx
	jmp .L12
.L16:	
	mov ax,'4'
	mov bx,word [bp+temp1]
	cmp ax,bx
	jne .L17
	push word [bp+_ret]
	push 4
	push word 0
	push word [bp+_off]
	mov bx,word [bp+_i]
	pop dx
	sub dx,bx
	mov bx,dx
	pop dx
	add bx,dx
	push bx
	lea bx,[bp+_num]
	pop dx
	imul dx,word 2
	add bx,dx
	mov bx,word [bx]
	pop dx
	imul bx,dx
	pop dx
	add dx,bx
	mov [bp+_ret],dx
	jmp .L12
.L17:	
	mov ax,'5'
	mov bx,word [bp+temp1]
	cmp ax,bx
	jne .L18
	push word [bp+_ret]
	push 5
	push word 0
	push word [bp+_off]
	mov bx,word [bp+_i]
	pop dx
	sub dx,bx
	mov bx,dx
	pop dx
	add bx,dx
	push bx
	lea bx,[bp+_num]
	pop dx
	imul dx,word 2
	add bx,dx
	mov bx,word [bx]
	pop dx
	imul bx,dx
	pop dx
	add dx,bx
	mov [bp+_ret],dx
	jmp .L12
.L18:	
	mov ax,'6'
	mov bx,word [bp+temp1]
	cmp ax,bx
	jne .L19
	push word [bp+_ret]
	push 6
	push word 0
	push word [bp+_off]
	mov bx,word [bp+_i]
	pop dx
	sub dx,bx
	mov bx,dx
	pop dx
	add bx,dx
	push bx
	lea bx,[bp+_num]
	pop dx
	imul dx,word 2
	add bx,dx
	mov bx,word [bx]
	pop dx
	imul bx,dx
	pop dx
	add dx,bx
	mov [bp+_ret],dx
	jmp .L12
.L19:	
	mov ax,'7'
	mov bx,word [bp+temp1]
	cmp ax,bx
	jne .L20
	push word [bp+_ret]
	push 7
	push word 0
	push word [bp+_off]
	mov bx,word [bp+_i]
	pop dx
	sub dx,bx
	mov bx,dx
	pop dx
	add bx,dx
	push bx
	lea bx,[bp+_num]
	pop dx
	imul dx,word 2
	add bx,dx
	mov bx,word [bx]
	pop dx
	imul bx,dx
	pop dx
	add dx,bx
	mov [bp+_ret],dx
	jmp .L12
.L20:	
	mov ax,'8'
	mov bx,word [bp+temp1]
	cmp ax,bx
	jne .L21
	push word [bp+_ret]
	push 8
	push word 0
	push word [bp+_off]
	mov bx,word [bp+_i]
	pop dx
	sub dx,bx
	mov bx,dx
	pop dx
	add bx,dx
	push bx
	lea bx,[bp+_num]
	pop dx
	imul dx,word 2
	add bx,dx
	mov bx,word [bx]
	pop dx
	imul bx,dx
	pop dx
	add dx,bx
	mov [bp+_ret],dx
	jmp .L12
.L21:	
	mov ax,'9'
	mov bx,word [bp+temp1]
	cmp ax,bx
	jne .L22
	push word [bp+_ret]
	push 9
	push word 0
	push word [bp+_off]
	mov bx,word [bp+_i]
	pop dx
	sub dx,bx
	mov bx,dx
	pop dx
	add bx,dx
	push bx
	lea bx,[bp+_num]
	pop dx
	imul dx,word 2
	add bx,dx
	mov bx,word [bx]
	pop dx
	imul bx,dx
	pop dx
	add dx,bx
	mov [bp+_ret],dx
	jmp .L12
.L22:	
.L12:	
	inc word [bp+_i]
	mov ax,word [bp+_i]
	jmp .L9
.L8:	
	mov ax,word [bp+_ret]
	leave
	ret
%undef _ret
%undef _i
%undef _n
%undef _off
%undef _num
%undef temp1
%undef _str

%define _i -2
%define _ptr 4
%define _size 6

_bzero:
	push bp
	mov bp,sp
	sub sp,word 2
	mov [bp+_i],word 0
	push ax
.L97:	
	push word [bp+_i]
	mov bx,word [bp+_size]
	pop dx
	cmp dx,bx
	jl .L98
	mov ax,word 0
	jmp .L99
.L98:	
	mov ax,word 1
.L99:	
	cmp ax,word 0
	je .L96
	push word 0
	mov bx,word [bp+_i]
	pop dx
	add bx,dx
	push bx
	mov bx,[bp+_ptr]
	pop dx
	push bx
	add bx,dx
	push bx
	mov dx,word 0
	pop di
	mov [di],dx
	mov ax,dx
	inc word [bp+_i]
	mov ax,word [bp+_i]
	jmp .L97
.L96:	
	leave
	ret

%undef _i
%undef _ptr
%undef _size

%define _i -2
%define _j -4
%define _ch -6
%define _buffer -1030
%define _name -2054
%define _sector -3078
%define _cmd 4

_findsector2:
	push bp
	mov bp,sp
	sub sp,word 3078
	push word [bp+_cmd]
	push C3
	call _printf
	add sp,word 4
	push 1024
	lea ax,[bp+_buffer]
	push ax
	call _bzero
	add sp,word 4
	push 1024
	lea ax,[bp+_name]
	push ax
	call _bzero
	add sp,word 4
	push 1024
	lea ax,[bp+_sector]
	push ax
	call _bzero
	add sp,word 4
	mov [bp+_i],word 0
	push ax
.L101:	
	push word [bp+_i]
	call _get_fat
	add sp,word 2
	push ax
	mov bx,word '}'
	pop dx
	cmp dx,bx
	jne .L102
	mov ax,word 0
	jmp .L103
.L102:	
	mov ax,word 1
.L103:	
	cmp ax,word 0
	je .L100
	push word [bp+_i]
	call _get_fat
	add sp,word 2
	mov [bp+_ch],ax
	push word 0
	mov bx,word [bp+_i]
	pop dx
	add bx,dx
	push bx
	lea bx,[bp+_buffer]
	pop dx
	add bx,dx
	push bx
	push word [bp+_ch]
	cpop al
	pop di
	mov [di],al
	cpush al
	pop ax
	inc word [bp+_i]
	mov ax,word [bp+_i]
	jmp .L101
.L100:	
	push word 0
	mov bx,word [bp+_i]
	pop dx
	add bx,dx
	push bx
	lea bx,[bp+_buffer]
	pop dx
	add bx,dx
	push bx
	push word '}'
	cpop al
	pop di
	mov [di],al
	cpush al
	pop ax
	lea ax,[bp+_buffer]
	push ax
	push C4
	call _printf
	add sp,word 4
	mov [bp+_j],word 0
	mov [bp+_i],word 1
	push ax
.L105:	
	push word 0
	mov bx,word [bp+_i]
	pop dx
	add bx,dx
	push bx
	lea bx,[bp+_buffer]
	pop dx
	add bx,dx
	mov al,[bx]
	cpush al
	mov bx,word '}'
	pop dx
	cmp dx,bx
	jne .L106
	mov ax,word 0
	jmp .L107
.L106:	
	mov ax,word 1
.L107:	
	cmp ax,word 0
	je .L104
	push word 0
	mov bx,word [bp+_i]
	pop dx
	add bx,dx
	push bx
	lea bx,[bp+_buffer]
	pop dx
	add bx,dx
	mov al,[bx]
	cpush al
	mov bx,word '-'
	pop dx
	cmp dx,bx
	je .L109
	mov ax,word 0
	jmp .L110
.L109:	
	mov ax,word 1
.L110:	
	cmp ax,word 0
	je .L111
	lea ax,[bp+_name]
	push ax
	push C5
	call _printf
	add sp,word 4
	push word [bp+_cmd]
	lea ax,[bp+_name]
	push ax
	call _strcmp
	add sp,word 4
	push ax
	mov bx,word 0
	pop dx
	cmp dx,bx
	je .L113
	mov ax,word 0
	jmp .L114
.L113:	
	mov ax,word 1
.L114:	
	cmp ax,word 0
	je .L115
	push 1024
	lea ax,[bp+_sector]
	push ax
	call _bzero
	add sp,word 4
	inc word [bp+_i]
	mov ax,word [bp+_i]
	mov [bp+_j],word 0
.L117:	
	push word 0
	mov bx,word [bp+_i]
	pop dx
	add bx,dx
	push bx
	lea bx,[bp+_buffer]
	pop dx
	add bx,dx
	mov al,[bx]
	cpush al
	mov bx,word ','
	pop dx
	cmp dx,bx
	jne .L118
	mov ax,word 0
	jmp .L119
.L118:	
	mov ax,word 1
.L119:	
	cmp ax,word 0
	je .L116
	push word 0
	mov bx,word [bp+_j]
	pop dx
	add bx,dx
	push bx
	lea bx,[bp+_sector]
	pop dx
	add bx,dx
	push bx
	push word 0
	mov bx,word [bp+_i]
	pop dx
	add bx,dx
	push bx
	lea bx,[bp+_buffer]
	pop dx
	add bx,dx
	mov al,[bx]
	pop di
	mov [di],al
	cpush al
	pop ax
	inc word [bp+_i]
	mov ax,word [bp+_i]
	inc word [bp+_j]
	mov ax,word [bp+_j]
	jmp .L117
.L116:	
	jmp .L104
	jmp .L112
.L115:	
	mov [bp+_j],word 0
	push 1024
	lea ax,[bp+_name]
	push ax
	call _bzero
	add sp,word 4
	push 1024
	lea ax,[bp+_sector]
	push ax
	call _bzero
	add sp,word 4
	inc word [bp+_i]
	mov ax,word [bp+_i]
.L121:	
	push word 0
	mov bx,word [bp+_i]
	pop dx
	add bx,dx
	push bx
	lea bx,[bp+_buffer]
	pop dx
	add bx,dx
	mov al,[bx]
	cpush al
	mov bx,word ','
	pop dx
	cmp dx,bx
	jne .L122
	mov ax,word 0
	jmp .L123
.L122:	
	mov ax,word 1
.L123:	
	cmp ax,word 0
	je .L120
	push word 0
	mov bx,word [bp+_i]
	pop dx
	add bx,dx
	push bx
	lea bx,[bp+_buffer]
	pop dx
	add bx,dx
	mov al,[bx]
	mov [bp+_ch],ax
	push word 0
	mov bx,word [bp+_j]
	pop dx
	add bx,dx
	push bx
	lea bx,[bp+_sector]
	pop dx
	add bx,dx
	push bx
	push word [bp+_ch]
	cpop al
	pop di
	mov [di],al
	cpush al
	pop ax
	inc word [bp+_i]
	mov ax,word [bp+_i]
	inc word [bp+_j]
	mov ax,word [bp+_j]
	jmp .L121
.L120:	
	mov [bp+_j],word 0
	push 1024
	lea ax,[bp+_sector]
	push ax
	call _bzero
	add sp,word 4
	inc word [bp+_i]
	mov ax,word [bp+_i]
	jmp .L105
.L112:	
	jmp .L108
.L111:	
	push word 0
	mov bx,word [bp+_i]
	pop dx
	add bx,dx
	push bx
	lea bx,[bp+_buffer]
	pop dx
	add bx,dx
	mov al,[bx]
	cpush al
	mov bx,word ','
	pop dx
	cmp dx,bx
	jne .L124
	mov ax,word 0
	jmp .L125
.L124:	
	mov ax,word 1
.L125:	
	cmp ax,word 0
	je .L126
	push word 0
	mov bx,word [bp+_j]
	pop dx
	add bx,dx
	push bx
	lea bx,[bp+_name]
	pop dx
	add bx,dx
	push bx
	push word 0
	mov bx,word [bp+_i]
	pop dx
	add bx,dx
	push bx
	lea bx,[bp+_buffer]
	pop dx
	add bx,dx
	mov al,[bx]
	pop di
	mov [di],al
	cpush al
	pop ax
	inc word [bp+_j]
	mov ax,word [bp+_j]
	jmp .L108
.L126:	
	mov [bp+_j],word 0
	push 1024
	lea ax,[bp+_name]
	push ax
	call _bzero
	add sp,word 4
.L108:	
	inc word [bp+_i]
	mov ax,word [bp+_i]
	jmp .L105
.L104:	
	lea ax,[bp+_buffer]
	push ax
	push C6
	call _printf
	add sp,word 4
	lea ax,[bp+_name]
	push ax
	push C7
	call _printf
	add sp,word 4
	lea ax,[bp+_sector]
	push ax
	push C8
	call _printf
	add sp,word 4
	lea ax,[bp+_sector]
	push ax
	call _atoi
	add sp,word 2
	push ax
	push C9
	call _printf
	add sp,word 4
	lea ax,[bp+_sector]
	push ax
	call _atoi
	add sp,word 2
	leave
	ret
%undef _i
%undef _j
%undef _ch
%undef _buffer
%undef _name
%undef _sector
%undef _cmd

%define _buffer -300
%define _i 4

_get_fat:
	push bp
	mov bp,sp
	sub sp,word 300
	push C0
	lea ax,[bp+_buffer]
	push ax
	call _strcpy
	add sp,word 4
	push word 0
	mov bx,word [bp+_i]
	pop dx
	add bx,dx
	push bx
	lea bx,[bp+_buffer]
	pop dx
	add bx,dx
	mov al,[bx]
	cpush al
	pop ax
	leave
	ret
%undef _buffer
%undef _i

%define _ch -2
%define _i -4
%define _ptr 4

_gets:
	push bp
	mov bp,sp
	sub sp,word 4
	mov [bp+_i],word 0
	call _getch
	mov [bp+_ch],ax
.L82:	
	push word [bp+_ch]
	mov bx,word 13
	pop dx
	cmp dx,bx
	jne .L83
	push 0
	jmp .L84
.L83:	
	push 1
.L84:	
	push word [bp+_ch]
	mov bx,word 10
	pop dx
	cmp dx,bx
	jne .L85
	push 0
	jmp .L86
.L85:	
	push 1
.L86:	
	pop bx
	pop ax
	and ax,bx
	cmp ax,word 0
	je .L81
	push word [bp+_ch]
	mov bx,word 8
	pop dx
	cmp dx,bx
	je .L88
	push 0
	jmp .L89
.L88:	
	push 1
.L89:	
	push word [bp+_i]
	mov bx,word 0
	pop dx
	cmp dx,bx
	jg .L90
	push 0
	jmp .L91
.L90:	
	push 1
.L91:	
	pop bx
	pop ax
	and ax,bx
	cmp ax,word 0
	je .L92
	push word [bp+_ch]
	call _putc
	add sp,word 2
	call _getch
	mov [bp+_ch],ax
	dec word [bp+_i]
	mov ax,word [bp+_i]
	push word 0
	mov bx,word [bp+_i]
	pop dx
	add bx,dx
	push bx
	mov bx,[bp+_ptr]
	pop dx
	push bx
	add bx,dx
	push bx
	mov dx,word 0
	pop di
	mov [di],dx
	mov ax,dx
	jmp .L82
	jmp .L87
.L92:	
	push word [bp+_ch]
	mov bx,word 8
	pop dx
	cmp dx,bx
	je .L93
	mov ax,word 0
	jmp .L94
.L93:	
	mov ax,word 1
.L94:	
	cmp ax,word 0
	je .L95
	call _getch
	mov [bp+_ch],ax
	jmp .L82
	jmp .L87
.L95:	
.L87:	
	push word [bp+_ch]
	call _putc
	add sp,word 2
	push word 0
	mov bx,word [bp+_i]
	pop dx
	add bx,dx
	push bx
	mov bx,[bp+_ptr]
	pop dx
	push bx
	add bx,dx
	push bx
	mov dx,word [bp+_ch]
	pop di
	mov [di],dx
	mov ax,dx
	inc word [bp+_i]
	mov ax,word [bp+_i]
	call _getch
	mov [bp+_ch],ax
	jmp .L82
.L81:	
	push word 0
	mov bx,word [bp+_i]
	pop dx
	add bx,dx
	push bx
	mov bx,[bp+_ptr]
	pop dx
	push bx
	add bx,dx
	push bx
	mov dx,word 0
	pop di
	mov [di],dx
	mov ax,dx
	push C1
	call _printf
	add sp,word 2
	push C2
	call _printf
	add sp,word 2
	push word [bp+_ptr]
	call _printf
	add sp,word 2
	push C1
	call _printf
	add sp,word 2
	leave
	ret

%undef _ch
%undef _i
%undef _ptr

%define _ch 4

_is_digit:
	push bp
	mov bp,sp
	push word [bp+_ch]
	mov bx,word '0'
	pop dx
	cmp dx,bx
	jge .L1
	push 0
	jmp .L2
.L1:	
	push 1
.L2:	
	push word [bp+_ch]
	mov bx,word '9'
	pop dx
	cmp dx,bx
	jle .L3
	push 0
	jmp .L4
.L3:	
	push 1
.L4:	
	pop bx
	pop ax
	and ax,bx
	cmp ax,word 0
	je .L5
	mov ax,word 1
	leave
	ret
	jmp .L0
.L5:	
.L0:	
	mov ax,word 0
	leave
	ret
%undef _ch

%define _reloc_array -60
%define _name -62
%define _word_ptr -64
%define _code_ptr -66
%define _temp_ptr -68
%define _reloc_count -70
%define _name_size -72
%define _entry_point -74
%define _addr -76
%define _size -78
%define _addr0 -80
%define _addr1 -82
%define _addr2 -84
%define _i -86
%define _j -88
%define _fun_size -90
%define _addr_size -92
%define _code_size -94
%define _fun_addr -96
%define _offset -98
%define temp2 -100
%define temp3 -102
%define _code 4

_link_program:
	push bp
	mov bp,sp
	sub sp,word 98
	mov [bp+_reloc_count],word 0
	mov ax,word [bp+_code]
	mov [bp+_word_ptr],ax
	mov di,[bp+_word_ptr]
	mov al,[di]
	cpush al
	pop ax
	mov [bp+_fun_size],ax
	push word [bp+_fun_size]
	push C13
	call _printf
	add sp,word 4
	push 2
	mov bx,[bp+_word_ptr]
	pop dx
	add bx,dx
	mov [bp+_word_ptr],bx
	mov [bp+_i],word 0
	push ax
.L140:	
	push word [bp+_i]
	mov bx,word [bp+_fun_size]
	pop dx
	cmp dx,bx
	jl .L141
	mov ax,word 0
	jmp .L142
.L141:	
	mov ax,word 1
.L142:	
	cmp ax,word 0
	je .L139
	mov di,[bp+_word_ptr]
	mov al,[di]
	cpush al
	pop ax
	mov [bp+_name_size],ax
	push word [bp+_name_size]
	push C14
	call _printf
	add sp,word 4
	push 2
	mov bx,[bp+_word_ptr]
	pop dx
	add bx,dx
	mov [bp+_word_ptr],bx
	mov ax,word [bp+_word_ptr]
	mov [bp+_name],ax
	push word [bp+_name]
	push C15
	call _printf
	add sp,word 4
	push word [bp+_name_size]
	mov bx,[bp+_word_ptr]
	pop dx
	add bx,dx
	mov [bp+_word_ptr],bx
	mov di,[bp+_word_ptr]
	mov al,[di]
	cpush al
	pop ax
	mov [bp+_entry_point],ax
	push word [bp+_entry_point]
	push C16
	call _printf
	add sp,word 4
	push 2
	mov bx,[bp+_word_ptr]
	pop dx
	add bx,dx
	mov [bp+_word_ptr],bx
	mov di,[bp+_word_ptr]
	mov al,[di]
	cpush al
	pop ax
	mov [bp+_addr],ax
	push word [bp+_addr]
	push C17
	call _printf
	add sp,word 4
	push 2
	mov bx,[bp+_word_ptr]
	pop dx
	add bx,dx
	mov [bp+_word_ptr],bx
	mov di,[bp+_word_ptr]
	mov al,[di]
	cpush al
	pop ax
	mov [bp+_size],ax
	push word [bp+_size]
	push C18
	call _printf
	add sp,word 4
	push 2
	mov bx,[bp+_word_ptr]
	pop dx
	add bx,dx
	mov [bp+_word_ptr],bx
	mov [bp+_j],word 0
	push ax
.L144:	
	push word [bp+_j]
	mov bx,word [bp+_size]
	pop dx
	cmp dx,bx
	jl .L145
	mov ax,word 0
	jmp .L146
.L145:	
	mov ax,word 1
.L146:	
	cmp ax,word 0
	je .L143
	mov di,[bp+_word_ptr]
	mov al,[di]
	cpush al
	pop ax
	mov [bp+_addr0],ax
	push 2
	mov bx,[bp+_word_ptr]
	pop dx
	add bx,dx
	mov [bp+_word_ptr],bx
	mov ax,word [bp+_addr0]
	mov [bp+_fun_addr],ax
	push word [bp+_fun_addr]
	push C19
	call _printf
	add sp,word 4
	push word 0
	mov bx,word [bp+_reloc_count]
	pop dx
	add bx,dx
	push bx
	lea bx,[bp+_reloc_array]
	pop dx
	imul dx,word 6
	add bx,dx
	add bx,_reloc._addr0
	push bx
	mov dx,word [bp+_fun_addr]
	pop di
	mov [di],dx
	mov ax,dx
	push word 0
	mov bx,word [bp+_reloc_count]
	pop dx
	add bx,dx
	push bx
	lea bx,[bp+_reloc_array]
	pop dx
	imul dx,word 6
	add bx,dx
	add bx,_reloc._addr1
	push bx
	mov dx,word 0
	pop di
	mov [di],dx
	mov ax,dx
	push word 0
	mov bx,word [bp+_reloc_count]
	pop dx
	add bx,dx
	push bx
	lea bx,[bp+_reloc_array]
	pop dx
	imul dx,word 6
	add bx,dx
	add bx,_reloc._is_label
	push bx
	mov dx,word 0
	pop di
	mov [di],dx
	mov ax,dx
	inc word [bp+_reloc_count]
	mov ax,word [bp+_reloc_count]
	inc word [bp+_j]
	mov ax,word [bp+_j]
	jmp .L144
.L143:	
	inc word [bp+_i]
	mov ax,word [bp+_i]
	jmp .L140
.L139:	
	mov di,[bp+_word_ptr]
	mov al,[di]
	cpush al
	pop ax
	mov [bp+_size],ax
	push 2
	mov bx,[bp+_word_ptr]
	pop dx
	add bx,dx
	mov [bp+_word_ptr],bx
	push word [bp+_size]
	push C18
	call _printf
	add sp,word 4
	mov [bp+_i],word 0
	push ax
.L148:	
	push word [bp+_i]
	mov bx,word [bp+_size]
	pop dx
	cmp dx,bx
	jl .L149
	mov ax,word 0
	jmp .L150
.L149:	
	mov ax,word 1
.L150:	
	cmp ax,word 0
	je .L147
	sub sp,word 4
	mov di,[bp+_word_ptr]
	mov al,[di]
	cpush al
	pop ax
	mov [bp+_addr0],ax
	push 2
	mov bx,[bp+_word_ptr]
	pop dx
	add bx,dx
	mov [bp+_word_ptr],bx
	mov di,[bp+_word_ptr]
	mov al,[di]
	cpush al
	pop ax
	mov [bp+_addr1],ax
	push 2
	mov bx,[bp+_word_ptr]
	pop dx
	add bx,dx
	mov [bp+_word_ptr],bx
	inc word [bp+_i]
	mov ax,word [bp+_i]
	jmp .L148
.L147:	
	mov di,[bp+_word_ptr]
	mov al,[di]
	cpush al
	pop ax
	mov [bp+_code_size],ax
	push word [bp+_code_size]
	push C20
	call _printf
	add sp,word 4
	push 2
	mov bx,[bp+_word_ptr]
	pop dx
	add bx,dx
	mov [bp+_word_ptr],bx
	mov ax,word [bp+_word_ptr]
	mov [bp+_code_ptr],ax
	push word [bp+_code_ptr]
	push C21
	call _printf
	add sp,word 4
	push word [bp+_fun_addr]
	push C22
	call _printf
	add sp,word 4
	push word [bp+_reloc_count]
	push C23
	call _printf
	add sp,word 4
	push word [bp+_code_ptr]
	mov bx,word [bp+_fun_addr]
	pop dx
	add dx,bx
	mov [bp+_temp_ptr],dx
	mov di,[bp+_temp_ptr]
	mov al,[di]
	cpush al
	pop word [bp+temp2]
	mov ax,word _printf
	mov [bp+temp2],ax
	push word [bp+_code_ptr]
	mov bx,word [bp+_addr0]
	pop dx
	add dx,bx
	mov [bp+_temp_ptr],dx
	mov di,[bp+_temp_ptr]
	mov al,[di]
	cpush al
	pop word [bp+temp3]
	push word [bp+_code_ptr]
	mov bx,word [bp+_addr1]
	pop dx
	add dx,bx
	mov [bp+temp3],dx
	mov ax,word [bp+_code_ptr]
	leave
	ret
%undef _reloc_array
%undef _name
%undef _word_ptr
%undef _code_ptr
%undef _temp_ptr
%undef _reloc_count
%undef _name_size
%undef _entry_point
%undef _addr
%undef _size
%undef _addr0
%undef _addr1
%undef _addr2
%undef _i
%undef _j
%undef _fun_size
%undef _addr_size
%undef _code_size
%undef _fun_addr
%undef _offset
%undef temp2
%undef temp3
%undef _code

%define _sector -2
%define _i -4
%define _cmd 4
%define _code 6

_load_program:
	push bp
	mov bp,sp
	sub sp,word 4
	push word [bp+_cmd]
	push C10
	call _printf
	add sp,word 4
	push word [bp+_code]
	push C11
	call _printf
	add sp,word 4
	push word [bp+_cmd]
	call _findsector2
	add sp,word 2
	mov [bp+_sector],ax
	push word [bp+_sector]
	push C12
	call _printf
	add sp,word 4
	push word [bp+_code]
	push word [bp+_sector]
	call _readfile
	add sp,word 4
	leave
	ret

%undef _sector
%undef _i
%undef _cmd
%undef _code

%define _code -16000
%define _cmd -16100
%define _main_ptr -16102
%define _i -16104
%define _rc -16106

_main:
	push bp
	mov bp,sp
	sub sp,word 16106
	mov [bp+_rc],word 0
.L152:	
	mov ax,word 1
	cmp ax,word 0
	je .L151
	push C24
	call _printf
	add sp,word 2
	push 100
	lea ax,[bp+_cmd]
	push ax
	call _bzero
	add sp,word 4
	lea ax,[bp+_cmd]
	push ax
	call _gets
	add sp,word 2
	push C1
	call _printf
	add sp,word 2
	lea ax,[bp+_cmd]
	push ax
	push C25
	call _printf
	add sp,word 4
	push C26
	lea ax,[bp+_cmd]
	push ax
	call _strcmp
	add sp,word 4
	push ax
	mov bx,word 0
	pop dx
	cmp dx,bx
	je .L154
	mov ax,word 0
	jmp .L155
.L154:	
	mov ax,word 1
.L155:	
	cmp ax,word 0
	je .L156
	jmp .L151
	jmp .L153
.L156:	
.L153:	
	lea ax,[bp+_cmd]
	push ax
	push C27
	call _printf
	add sp,word 4
	push 16000
	lea ax,[bp+_code]
	push ax
	call _bzero
	add sp,word 4
	lea ax,[bp+_code]
	push ax
	lea ax,[bp+_cmd]
	push ax
	call _load_program
	add sp,word 4
	lea ax,[bp+_code]
	push ax
	call _link_program
	add sp,word 2
	mov [bp+_main_ptr],ax
	push C28
	call _printf
	add sp,word 2
	push C1
	call _printf
	add sp,word 2
	call [bp+_main_ptr]
	mov [bp+_rc],ax
	push ax
	push C1
	call _printf
	add sp,word 2
	push C29
	call _printf
	add sp,word 2
	push word [bp+_rc]
	push C30
	call _printf
	add sp,word 4
	jmp .L152
.L151:	
	mov ax,word 0
	leave
	ret
%undef _code
%undef _cmd
%undef _main_ptr
%undef _i
%undef _rc

%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
	mov [bp+_ret],word 0
	push word 0
	mov bx,word 0
	pop dx
	add bx,dx
	push bx
	lea bx,[bp+_byte_array]
	pop dx
	add bx,dx
	push bx
	push word '0'
	cpop al
	pop di
	mov [di],al
	cpush al
	pop ax
	push word 0
	mov bx,word 1
	pop dx
	add bx,dx
	push bx
	lea bx,[bp+_byte_array]
	pop dx
	add bx,dx
	push bx
	push word '1'
	cpop al
	pop di
	mov [di],al
	cpush al
	pop ax
	push word 0
	mov bx,word 2
	pop dx
	add bx,dx
	push bx
	lea bx,[bp+_byte_array]
	pop dx
	add bx,dx
	push bx
	push word '2'
	cpop al
	pop di
	mov [di],al
	cpush al
	pop ax
	push word 0
	mov bx,word 3
	pop dx
	add bx,dx
	push bx
	lea bx,[bp+_byte_array]
	pop dx
	add bx,dx
	push bx
	push word '3'
	cpop al
	pop di
	mov [di],al
	cpush al
	pop ax
	push word 0
	mov bx,word 4
	pop dx
	add bx,dx
	push bx
	lea bx,[bp+_byte_array]
	pop dx
	add bx,dx
	push bx
	push word '4'
	cpop al
	pop di
	mov [di],al
	cpush al
	pop ax
	push word 0
	mov bx,word 5
	pop dx
	add bx,dx
	push bx
	lea bx,[bp+_byte_array]
	pop dx
	add bx,dx
	push bx
	push word '5'
	cpop al
	pop di
	mov [di],al
	cpush al
	pop ax
	push word 0
	mov bx,word 6
	pop dx
	add bx,dx
	push bx
	lea bx,[bp+_byte_array]
	pop dx
	add bx,dx
	push bx
	push word '6'
	cpop al
	pop di
	mov [di],al
	cpush al
	pop ax
	push word 0
	mov bx,word 7
	pop dx
	add bx,dx
	push bx
	lea bx,[bp+_byte_array]
	pop dx
	add bx,dx
	push bx
	push word '7'
	cpop al
	pop di
	mov [di],al
	cpush al
	pop ax
	push word 0
	mov bx,word 8
	pop dx
	add bx,dx
	push bx
	lea bx,[bp+_byte_array]
	pop dx
	add bx,dx
	push bx
	push word '8'
	cpop al
	pop di
	mov [di],al
	cpush al
	pop ax
	push word 0
	mov bx,word 9
	pop dx
	add bx,dx
	push bx
	lea bx,[bp+_byte_array]
	pop dx
	add bx,dx
	push bx
	push word '9'
	cpop al
	pop di
	mov [di],al
	cpush al
	pop ax
	push word [bp+_number]
	mov bx,word 0
	pop dx
	cmp dx,bx
	je .L49
	mov ax,word 0
	jmp .L50
.L49:	
	mov ax,word 1
.L50:	
	cmp ax,word 0
	je .L51
	push word '0'
	call _putc
	add sp,word 2
	jmp .L48
.L51:	
.L48:	
	mov [bp+_index],word 0
.L53:	
	mov ax,word [bp+_number]
	cmp ax,word 0
	je .L52
	push word [bp+_number]
	mov bx,word 10
	pop ax
	xor dx,dx
	idiv bx
	mov [bp+_n],dx
	push word [bp+_number]
	mov bx,word 10
	pop ax
	xor dx,dx
	idiv bx
	mov [bp+_number],ax
	push word 0
	mov bx,word [bp+_index]
	pop dx
	add bx,dx
	push bx
	lea bx,[bp+_buffer]
	pop dx
	add bx,dx
	push bx
	push word 0
	mov bx,word [bp+_n]
	pop dx
	add bx,dx
	push bx
	lea bx,[bp+_byte_array]
	pop dx
	add bx,dx
	mov al,[bx]
	pop di
	mov [di],al
	cpush al
	pop ax
	inc word [bp+_index]
	mov ax,word [bp+_index]
	jmp .L53
.L52:	
	dec word [bp+_index]
	mov ax,word [bp+_index]
.L55:	
	push word [bp+_index]
	mov bx,word 0
	pop dx
	cmp dx,bx
	jge .L56
	mov ax,word 0
	jmp .L57
.L56:	
	mov ax,word 1
.L57:	
	cmp ax,word 0
	je .L54
	push word 0
	mov bx,word [bp+_index]
	pop dx
	add bx,dx
	push bx
	lea bx,[bp+_buffer]
	pop dx
	add bx,dx
	mov al,[bx]
	cpush al
	call _putc
	add sp,word 2
	dec word [bp+_index]
	mov ax,word [bp+_index]
	jmp .L55
.L54:	
	mov ax,word [bp+_ret]
	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
	mov [bp+_ret],word 0
	mov ax,word [bp+_fmt]
	mov [bp+_ptr],ax
	mov [bp+_i],word 2
.L59:	
	mov di,[bp+_ptr]
	mov al,[di]
	cmp al,byte 0
	je .L58
	mov di,[bp+_ptr]
	mov al,[di]
	cpush al
	mov bx,word '%'
	pop dx
	cmp dx,bx
	je .L61
	mov ax,word 0
	jmp .L62
.L61:	
	mov ax,word 1
.L62:	
	cmp ax,word 0
	je .L63
	inc word [bp+_ptr]
	mov ax,word [bp+_ptr]
	mov di,[bp+_ptr]
	mov al,[di]
	cpush al
	mov bx,word '%'
	pop dx
	cmp dx,bx
	je .L65
	mov ax,word 0
	jmp .L66
.L65:	
	mov ax,word 1
.L66:	
	cmp ax,word 0
	je .L67
	push word '%'
	call _putc
	add sp,word 2
	inc word [bp+_ptr]
	mov ax,word [bp+_ptr]
	jmp .L64
.L67:	
	mov di,[bp+_ptr]
	mov al,[di]
	cpush al
	mov bx,word 'x'
	pop dx
	cmp dx,bx
	je .L68
	mov ax,word 0
	jmp .L69
.L68:	
	mov ax,word 1
.L69:	
	cmp ax,word 0
	je .L70
	lea ax,[bp+_fmt]
	push ax
	mov bx,word [bp+_i]
	pop dx
	add dx,bx
	mov [bp+_ptr0],dx
	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
	mov [bp+_i],bx
	inc word [bp+_ptr]
	mov ax,word [bp+_ptr]
	jmp .L64
.L70:	
	mov di,[bp+_ptr]
	mov al,[di]
	cpush al
	mov bx,word 'd'
	pop dx
	cmp dx,bx
	je .L71
	mov ax,word 0
	jmp .L72
.L71:	
	mov ax,word 1
.L72:	
	cmp ax,word 0
	je .L73
	lea ax,[bp+_fmt]
	push ax
	mov bx,word [bp+_i]
	pop dx
	add dx,bx
	mov [bp+_ptr0],dx
	push bp
	mov ax,[bp+_ptr0]
	mov bp,ax
	mov dx,[bp]
	pop bp
	push dx
	call _print_short
	add sp,word 2
	push 2
	mov bx,[bp+_i]
	pop dx
	add bx,dx
	mov [bp+_i],bx
	inc word [bp+_ptr]
	mov ax,word [bp+_ptr]
	jmp .L64
.L73:	
	mov di,[bp+_ptr]
	mov al,[di]
	cpush al
	mov bx,word 's'
	pop dx
	cmp dx,bx
	je .L74
	mov ax,word 0
	jmp .L75
.L74:	
	mov ax,word 1
.L75:	
	cmp ax,word 0
	je .L76
	lea ax,[bp+_fmt]
	push ax
	mov bx,word [bp+_i]
	pop dx
	add dx,bx
	mov [bp+_ptr0],dx
	push bp
	mov ax,[bp+_ptr0]
	mov bp,ax
	mov dx,[bp]
	pop bp
	mov [bp+_ptr1],dx
.L78:	
	mov di,[bp+_ptr1]
	mov al,[di]
	cmp al,byte 0
	je .L77
	mov di,[bp+_ptr1]
	mov al,[di]
	cpush al
	call _putc
	add sp,word 2
	inc word [bp+_ptr1]
	mov ax,word [bp+_ptr1]
	jmp .L78
.L77:	
	push 2
	mov bx,[bp+_i]
	pop dx
	add bx,dx
	mov [bp+_i],bx
	inc word [bp+_ptr]
	mov ax,word [bp+_ptr]
	jmp .L64
.L76:	
	inc word [bp+_ptr]
	mov ax,word [bp+_ptr]
.L64:	
	jmp .L60
.L63:	
	mov di,[bp+_ptr]
	mov al,[di]
	cpush al
	call _putc
	add sp,word 2
	inc word [bp+_ptr]
	mov ax,word [bp+_ptr]
.L60:	
	jmp .L59
.L58:	
	mov ax,word 0
	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
	mov [bp+_offset],word 0
	mov [bp+_count],word 2
	lea ax,[bp+_fmt]
	push ax
	mov bx,word [bp+_count]
	pop dx
	add dx,bx
	mov [bp+_ptr],dx
	mov ax,word [bp+_fmt]
	mov [bp+_p],ax
	push ax
.L24:	
	mov di,[bp+_p]
	mov al,[di]
	cmp al,byte 0
	je .L23
	mov di,[bp+_p]
	mov al,[di]
	cpush al
	mov bx,word '%'
	pop dx
	cmp dx,bx
	je .L26
	mov ax,word 0
	jmp .L27
.L26:	
	mov ax,word 1
.L27:	
	cmp ax,word 0
	je .L28
	inc word [bp+_p]
	mov ax,word [bp+_p]
	mov di,[bp+_p]
	mov al,[di]
	cpush al
	mov bx,word 'd'
	pop dx
	cmp dx,bx
	je .L30
	mov ax,word 0
	jmp .L31
.L30:	
	mov ax,word 1
.L31:	
	cmp ax,word 0
	je .L32
	push bp
	mov ax,[bp+_ptr]
	mov bp,ax
	mov dx,[bp]
	pop bp
	mov [bp+_temp],dx
	call _getch
	mov [bp+_ch],ax
	push word [bp+_ch]
	call _putc
	add sp,word 2
	mov [bp+_offset],word 0
.L34:	
	push word [bp+_ch]
	call _is_digit
	add sp,word 2
	push ax
	push word [bp+_ch]
	mov bx,word 13
	pop dx
	cmp dx,bx
	jne .L35
	push 0
	jmp .L36
.L35:	
	push 1
.L36:	
	push word [bp+_ch]
	mov bx,word 10
	pop dx
	cmp dx,bx
	jne .L37
	push 0
	jmp .L38
.L37:	
	push 1
.L38:	
	pop bx
	pop ax
	and ax,bx
	mov bx,ax
	pop ax
	and ax,bx
	cmp ax,word 0
	je .L33
	push word 0
	mov bx,word [bp+_offset]
	pop dx
	add bx,dx
	push bx
	lea bx,[bp+_buffer]
	pop dx
	add bx,dx
	push bx
	push word [bp+_ch]
	cpop al
	pop di
	mov [di],al
	cpush al
	pop ax
	inc word [bp+_offset]
	mov ax,word [bp+_offset]
	call _getch
	mov [bp+_ch],ax
	push word [bp+_ch]
	call _putc
	add sp,word 2
	jmp .L34
.L33:	
	push word 0
	mov bx,word [bp+_offset]
	pop dx
	add bx,dx
	push bx
	lea bx,[bp+_buffer]
	pop dx
	add bx,dx
	push bx
	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
	mov di,[bp+_temp]
	mov [di],ax
	push word [bp+_count]
	mov bx,word 2
	pop dx
	add dx,bx
	mov [bp+_count],dx
	lea ax,[bp+_fmt]
	push ax
	mov bx,word [bp+_count]
	pop dx
	add dx,bx
	mov [bp+_ptr],dx
	jmp .L29
.L32:	
	mov di,[bp+_p]
	mov al,[di]
	cpush al
	mov bx,word 'f'
	pop dx
	cmp dx,bx
	je .L39
	mov ax,word 0
	jmp .L40
.L39:	
	mov ax,word 1
.L40:	
	cmp ax,word 0
	je .L41
	nop
	jmp .L29
.L41:	
	mov di,[bp+_p]
	mov al,[di]
	cpush al
	mov bx,word 's'
	pop dx
	cmp dx,bx
	je .L42
	mov ax,word 0
	jmp .L43
.L42:	
	mov ax,word 1
.L43:	
	cmp ax,word 0
	je .L44
	nop
	jmp .L29
.L44:	
	mov di,[bp+_p]
	mov al,[di]
	cpush al
	mov bx,word 'c'
	pop dx
	cmp dx,bx
	je .L45
	mov ax,word 0
	jmp .L46
.L45:	
	mov ax,word 1
.L46:	
	cmp ax,word 0
	je .L47
	nop
	jmp .L29
.L47:	
.L29:	
	jmp .L25
.L28:	
	nop
.L25:	
	inc word [bp+_p]
	mov ax,word [bp+_p]
	jmp .L24
.L23:	
	mov ax,word 0
	leave
	ret
%undef _ptr
%undef _p
%undef _temp
%undef _buffer
%undef _offset
%undef _ch
%undef _count
%undef _fmt

%define _ret -2
%define _i -4
%define _ch1 -6
%define _ch2 -8
%define _arg1 4
%define _arg2 6

_strcmp:
	push bp
	mov bp,sp
	sub sp,word 8
	mov [bp+_ret],word 0
	mov [bp+_i],word 0
	push ax
.L128:	
	push word 0
	mov bx,word [bp+_i]
	pop dx
	add bx,dx
	push bx
	mov bx,[bp+_arg1]
	pop dx
	push bx
	add bx,dx
	mov al,[bx]
	cpush al
	push word 0
	mov bx,word [bp+_i]
	pop dx
	add bx,dx
	push bx
	mov bx,[bp+_arg2]
	pop dx
	push bx
	add bx,dx
	mov al,[bx]
	cpush al
	pop bx
	pop ax
	and ax,bx
	push ax
	cpop al
	cmp al,byte 0
	je .L127
	push word 0
	mov bx,word [bp+_i]
	pop dx
	add bx,dx
	push bx
	mov bx,[bp+_arg1]
	pop dx
	push bx
	add bx,dx
	mov al,[bx]
	mov [bp+_ch1],ax
	push word 0
	mov bx,word [bp+_i]
	pop dx
	add bx,dx
	push bx
	mov bx,[bp+_arg2]
	pop dx
	push bx
	add bx,dx
	mov al,[bx]
	mov [bp+_ch2],ax
	push word [bp+_ch1]
	mov bx,word [bp+_ch2]
	pop dx
	cmp dx,bx
	je .L130
	mov ax,word 0
	jmp .L131
.L130:	
	mov ax,word 1
.L131:	
	cmp ax,word 0
	je .L132
	nop
	jmp .L129
.L132:	
	push word [bp+_ch1]
	mov bx,word [bp+_ch2]
	pop dx
	cmp dx,bx
	jl .L133
	mov ax,word 0
	jmp .L134
.L133:	
	mov ax,word 1
.L134:	
	cmp ax,word 0
	je .L135
	mov dx,word 1
	neg dx
	mov [bp+_ret],dx
	jmp .L127
	jmp .L129
.L135:	
	push word [bp+_ch1]
	mov bx,word [bp+_ch2]
	pop dx
	cmp dx,bx
	jg .L136
	mov ax,word 0
	jmp .L137
.L136:	
	mov ax,word 1
.L137:	
	cmp ax,word 0
	je .L138
	mov [bp+_ret],word 1
	jmp .L127
	jmp .L129
.L138:	
.L129:	
	inc word [bp+_i]
	mov ax,word [bp+_i]
	jmp .L128
.L127:	
	mov ax,word [bp+_ret]
	leave
	ret
%undef _ret
%undef _i
%undef _ch1
%undef _ch2
%undef _arg1
%undef _arg2

%define _a 4
%define _b 6

_strcpy:
	push bp
	mov bp,sp
.L80:	
	mov di,[bp+_b]
	mov al,[di]
	mov di,[bp+_a]
	mov [di],al
	cmp al,byte 0
	je .L79
	inc word [bp+_a]
	mov ax,word [bp+_a]
	inc word [bp+_b]
	mov ax,word [bp+_b]
	jmp .L80
.L79:	
	leave
	ret

%undef _a
%undef _b

%define _n -2
%define _ptr 4

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



[section .data]

hex db "0x0000",10,13,0
hexc db "0123456789ABCDEF"
C100: db 'OPEN NEXT...',13,10,0
C101: db 'READ NEXT...',13,10,0
C102: db 'CLOSE NEXT...',13,10,0
filename: db 'hello16',0
C0: db '{hello16-0,aout-1,prog-2,c-3,}',0
C1: db 13,10,0
C2: db 'ptr -> ',0
C3: db 'find sector: cmd == "%s"',13,10,0
C4: db 'fat=(%s)',13,10,0
C5: db 'name=(%s)',13,10,0
C6: db 'FAT = (%s)',13,10,0
C7: db 'NAME = (%s)',13,10,0
C8: db 'SECTOR = (%s)',13,10,0
C9: db 'SECTOR = (%d)',13,10,0
C10: db 'LOAD: %s',13,10,0
C11: db 'CODE ADDRESS = %d',13,10,0
C12: db 'SECTOR: %d',13,10,0
C13: db 'fun_size == %d',13,10,0
C14: db 'name_size == %d',13,10,0
C15: db 'name == %s',13,10,0
C16: db 'entry_point == %d',13,10,0
C17: db 'addr == %d',13,10,0
C18: db 'size == %d',13,10,0
C19: db 'FUN_ADDR = %d',13,10,0
C20: db 'code_size == %d',13,10,0
C21: db 'code_ptr == %d',13,10,0
C22: db 'fun_addr == %d',13,10,0
C23: db 'reloc_count == %d',13,10,0
C24: db 'run> ',0
C25: db 'cmd == %s',13,10,0
C26: db 'exit',0
C27: db 'cmd: %s',13,10,0
C28: db 'MAIN[',0
C29: db ']',13,10,0
C30: db 'rc == %d',13,10,0

[section .bss]

file: resw 1
buffer: resw 1
temp_word: resd 1
the_ch: resw 1
answer: resb 20
