[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 _printf

[segment .text]

%include "io.asm"


%define _a -2
%define _b -4
%define _c -6

_main:
	push bp
	mov bp,sp
	sub sp,word 6
	mov [bp+_b],word 1
	mov [bp+_c],word 100
	push word [bp+_b]
	mov bx,word [bp+_c]
	pop dx
	add dx,bx
	mov [bp+_a],dx
	push word [bp+_b]
	push C0
	call _printf
	add sp,word 4
	push word [bp+_c]
	push C1
	call _printf
	add sp,word 4
	push word [bp+_a]
	push C2
	call _printf
	add sp,word 4
	push word [bp+_b]
	mov bx,word [bp+_c]
	pop dx
	sub dx,bx
	mov [bp+_a],dx
	push word [bp+_a]
	push C3
	call _printf
	add sp,word 4
	push word [bp+_b]
	mov bx,word [bp+_c]
	pop dx
	imul bx,dx
	mov [bp+_a],bx
	push word [bp+_a]
	push C4
	call _printf
	add sp,word 4
	push word [bp+_b]
	mov bx,word [bp+_c]
	pop ax
	xor dx,dx
	idiv bx
	mov [bp+_a],ax
	push word [bp+_a]
	push C5
	call _printf
	add sp,word 4
	push word [bp+_b]
	mov bx,word [bp+_c]
	pop ax
	xor dx,dx
	idiv bx
	mov [bp+_a],dx
	push word [bp+_a]
	push C6
	call _printf
	add sp,word 4
	mov ax,word 0
	leave
	ret
%undef _a
%undef _b
%undef _c



[section .data]

C0: db 'b == %d',10,0
C1: db 'c == %d',10,0
C2: db 'b + c == %d',10,0
C3: db 'b - c == %d',10,0
C4: db 'b * c == %d',10,0
C5: db 'b / c == %d',10,0
C6: db 'b % c == %d',10,0

[section .bss]

answer: resb 20
