include	libmacro.inc

beglib 'math'

item 'inc','*'
  pop bx
  xchg ax, bx
  inc word ptr [bx]

item 'dec','*'
  pop bx
  xchg ax, bx
  dec word ptr [bx]

item '++','*'
  pop bx
  xchg ax, bx
  inc word ptr [bx]

item '--','*'
  pop bx
  xchg ax, bx
  dec word ptr [bx]

item 'hi','*'
  xchg al,ah
  xor ah,ah

item 'lo','*'
  xor ah,ah

item 'bhi','*'
  xor ah,ah
  and al,11110000b
  mov cl,4
  shr ax,cl

item 'blo','*'
  xor ah,ah
  and al,00001111b

item '+','*',5
  pop bx
  add ax,bx

item '-','*',5
  pop bx
  xchg ax, bx
  sub ax,bx

item '*','*',4
  pop bx
  imul bx

item '<<','*',3
  pop cx
  xchg ax, cx
  shl ax, cl

item '>>','*',3
  pop cx
  xchg ax,cx
  shr ax, cl

item '/','*',4
  cwd
  pop bx
  xchg ax,bx
  idiv bx

item '%','*',4
  cwd
  pop bx
  xchg ax,bx
  div bx
  mov ax,dx

item '>','*',6
  pop bx
  cmp bx,ax
  setg al

item '<','*',6
  pop bx
  cmp bx,ax
  setl al

item '=','*',10
  pop	bx
  mov	[bx], ax
  pop	ax

item 'letb','*',9
  pop bx
  mov [bx],al
  pop ax

item '<=','*',6
  pop bx
  cmp bx,ax
  setle al

item 'byte','*',1
  mov bx,ax
  xor ah,ah
  mov al,[bx]

item 'word','*',1
  mov bx,ax
  mov ax,[bx]
 
item 'long','*',2
  mov bx,ax
  push word ptr [bx+2]
  mov ax,[bx]

item '>=','*',6
  pop bx
  cmp bx,ax
  setge al

item '==','*',6
  pop bx
  cmp bx,ax
  sete al

item '<>','*',6
  pop bx
  cmp bx,ax
  setne al


item '&','*',7
  pop bx
  and ax,bx

item '|','*',7
  pop bx
  or ax,bx

item '^','*',7
  pop bx
  xor ax,bx

item '~','*',7
  not ax

endlib

