{ lang run-time header file }

proc char hi(int a)
  asm
    mov  ax, [a]
    mov  al, ah
    xor  ah, ah
  end
end

proc char lo(int a)
  asm
    mov  ax, [a]
    xor  ah, ah
  end
end

public proc putchar(char a)
  asm
    mov  ah, 2
    mov  dl, [a]
    int  0x21
  end
end

public proc putstr(word a)
  while lo(^a)>0
    putchar(^a)
    a+=1
  end
end

public proc putcrlf
  putchar(13)
  putchar(10)
end

public proc puthex(int a)
char i
begin
  if a>0
    i=a%16
    if i<10
      i+='0'
    else
      i+='A'-10
    end
    puthex(a/16)
    putchar(i)
  end
end

public proc putword(word a)
  if a>0
    putword(a/10)
    putchar('0'+a%10)
  end
end

public proc putint(int a)
  if a==0
    putchar('0')
    ret
  elsif a>0x7fff
    putchar('-')
    a=-a
  end
  putword(a)
end