Mirror of CollapseOS
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

89 lines
2.1KB

  1. ; zasm
  2. ;
  3. ; Reads input from specified blkdev ID, assemble the binary in two passes and
  4. ; spit the result in another specified blkdev ID.
  5. ;
  6. ; We don't buffer the whole source in memory, so we need our input blkdev to
  7. ; support Seek so we can read the file a second time. So, for input, we need
  8. ; GetC and Seek.
  9. ;
  10. ; For output, we only need PutC. Output doesn't start until the second pass.
  11. ;
  12. ; The goal of the second pass is to assign values to all symbols so that we
  13. ; can have forward references (instructions referencing a label that happens
  14. ; later).
  15. ;
  16. ; Labels and constants are both treated the same way, that is, they can be
  17. ; forward-referenced in instructions. ".equ" directives, however, are evaluated
  18. ; during the first pass so forward references are not allowed.
  19. ;
  20. ; *** Requirements ***
  21. ; strncmp
  22. ; addDE
  23. ; addHL
  24. ; upcase
  25. ; unsetZ
  26. ; intoDE
  27. ; intoHL
  28. ; writeHLinDE
  29. ; findchar
  30. ; parseHex
  31. ; parseHexPair
  32. ; blkSel
  33. ; blkSet
  34. ; fsFindFN
  35. ; fsOpen
  36. ; fsGetC
  37. ; cpHLDE
  38. ; parseArgs
  39. ; _blkGetC
  40. ; _blkPutC
  41. ; _blkSeek
  42. ; _blkTell
  43. ; printstr
  44. ; FS_HANDLE_SIZE
  45. ; BLOCKDEV_SIZE
  46. #include "user.h"
  47. ; *** Overridable consts ***
  48. ; Maximum number of symbols we can have in the global and consts registry
  49. .equ ZASM_REG_MAXCNT 0xff
  50. ; Maximum number of symbols we can have in the local registry
  51. .equ ZASM_LREG_MAXCNT 0x40
  52. ; Size of the symbol name buffer size. This is a pool. There is no maximum name
  53. ; length for a single symbol, just a maximum size for the whole pool.
  54. ; Global labels and consts have the same buf size
  55. .equ ZASM_REG_BUFSZ 0x1000
  56. ; Size of the names buffer for the local context registry
  57. .equ ZASM_LREG_BUFSZ 0x200
  58. ; ******
  59. #include "err.h"
  60. .org USER_CODE
  61. jp zasmMain
  62. #include "zasm/const.asm"
  63. #include "lib/util.asm"
  64. #include "zasm/util.asm"
  65. .equ IO_RAMSTART USER_RAMSTART
  66. #include "zasm/io.asm"
  67. .equ TOK_RAMSTART IO_RAMEND
  68. #include "zasm/tok.asm"
  69. #include "lib/parse.asm"
  70. .equ INS_RAMSTART TOK_RAMEND
  71. #include "zasm/instr.asm"
  72. .equ DIREC_RAMSTART INS_RAMEND
  73. #include "zasm/directive.asm"
  74. #include "zasm/parse.asm"
  75. #include "zasm/expr.asm"
  76. .equ SYM_RAMSTART DIREC_RAMEND
  77. #include "zasm/symbol.asm"
  78. .equ ZASM_RAMSTART SYM_RAMEND
  79. #include "zasm/main.asm"