; memory headers

%define chseg(x,y)      _chseg x,y    ; chseg :: reg *seg -> int16 new -> void
%define sret(x)         _sret x         ; sret :: reg *seg -> void
%define palloc(x)       _palloc x       ; palloc :: int8 _blocks -> int32 *addr


%ifdef xmemory
  global Palloc
%else
  extern Palloc
%endif

%macro _chseg 2
   mov ax,%1
   push ax
   cmp word ax,%2
   je %%eq
 %%neq:
   mov ax,%2   ; ax=new seg
   mov %1,ax
 %%eq:
%endmacro

%macro _sret 1
   pop bx
   mov cx,%1
   cmp bx,cx
   je %%eq
 %%neq:
   mov %1,bx
 %%eq:
%endmacro

%macro _palloc 1
  mov ax,%1
  push ax
  call Palloc
  add sp,0x0002
%endmacro
