/kernel_words.fth

https://github.com/august0815/forthos · Forth · 47 lines · 39 code · 8 blank · 0 comment · 1 complexity · 22cc2c5e16b454ae13b8d01fa8ce1a50 MD5 · raw file

  1. ; program: kernel_words
  2. ; Useful words for kernel management.
  3. ; License: GPL
  4. ; José Dinuncio <jdinunci@uc.edu.ve>, 12/2009.
  5. %include "forth.h"
  6. [BITS 32]
  7. ; function: outb
  8. ; Executes an out assembly instruction
  9. ;
  10. ; Stack:
  11. ; val port --
  12. ;
  13. ; Parameters:
  14. ; val - The value to out. Byte.
  15. ; port - The port to output the value. int16.
  16. defcode "outb", outb, 0
  17. pop edx
  18. pop eax
  19. out dx, al
  20. next
  21. ; function: inb
  22. ; Executes an IN assembly instruction
  23. ;
  24. ; Stack:
  25. ; port -- val
  26. defcode "inb", inb, 0
  27. pop edx
  28. xor eax, eax
  29. in al, dx
  30. push eax
  31. next
  32. ; b3b2b1b0 -- 0000b1b0
  33. : lo
  34. 0xFFFF and
  35. ;
  36. ; b3b2b1b0 -- 0000b1b0
  37. : hi
  38. 16 shr 0xFFFF and
  39. ;