Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

283 řádky
6.2KB

  1. ; E03-S01: parser test in x128.
  2. ;
  3. ; For each fixture: src_load, names_init, diag_init (screen off), parse_file,
  4. ; diag_finish. Rejected fixtures leave NAME.ERR on the disk for the host to
  5. ; compare; accepted fixtures must leave none. The dump records:
  6. ; $FF, fixture index, src_load result, diagnostic count
  7. ; per declared top-level type: kind, line lo, line hi, spelling length,
  8. ; spelling bytes
  9. ; $FD
  10. ; then $FE at the end. Mailbox: MB_DATA+0/1 dump address, +2/3 length.
  11. .setcpu "6502"
  12. .include "../../src/common/c128.inc"
  13. .include "../../src/common/mailbox.inc"
  14. .include "../../src/common/parser.inc"
  15. .import mmu_init, mmu_bank0, mmu_shutdown, mmu_peek1, kcall_inline
  16. .importzp mmu_ptr
  17. .import src_load
  18. .import names_init, name_get, names_count, name_out, name_out_len
  19. .import diag_init, diag_finish, diag_screen
  20. .import parse_file, type_kind, type_line_lo, type_line_hi
  21. DUMP_SIZE = $2000
  22. .segment "LOADADDR"
  23. .word $1C01
  24. .segment "EXEHDR"
  25. .word basic_end
  26. .word 10
  27. .byte $9E
  28. .byte "7181"
  29. .byte $00
  30. basic_end:
  31. .word $0000
  32. .segment "MAILBOX"
  33. .res MB_SIZE
  34. .segment "ZEROPAGE"
  35. dump_ptr: .res 2
  36. fx_ptr: .res 2
  37. .segment "STARTUP"
  38. .export test_entry, dump
  39. test_entry:
  40. php
  41. sei
  42. ldx #MB_SIZE - 1
  43. lda #$00
  44. @clr: sta MB_BASE,x
  45. dex
  46. bpl @clr
  47. lda #MB_MAGIC0_VALUE
  48. sta MB_MAGIC0
  49. lda #MB_MAGIC1_VALUE
  50. sta MB_MAGIC1
  51. lda #MB_PROD_PLATFORM
  52. sta MB_PRODUCER
  53. lda #MB_ST_RUNNING
  54. sta MB_STATUS
  55. jsr mmu_init
  56. jsr mmu_bank0
  57. lda #<dump
  58. sta dump_ptr
  59. lda #>dump
  60. sta dump_ptr+1
  61. lda #<fixtures
  62. sta fx_ptr
  63. lda #>fixtures
  64. sta fx_ptr+1
  65. lda #$00
  66. sta failures
  67. sta overflow
  68. sta fx_index
  69. @fixture:
  70. lda #$FF
  71. jsr emit
  72. lda fx_index
  73. jsr emit
  74. ldy #0
  75. lda (fx_ptr),y
  76. sta name_lo
  77. iny
  78. lda (fx_ptr),y
  79. sta name_hi
  80. iny
  81. lda (fx_ptr),y
  82. sta name_len
  83. lda name_lo
  84. ldx name_hi
  85. ldy name_len
  86. jsr src_load
  87. pha
  88. jsr emit
  89. pla
  90. beq @parse
  91. inc failures
  92. lda #$00
  93. jsr emit
  94. jmp @advance
  95. @parse: jsr names_init
  96. lda name_lo
  97. ldx name_hi
  98. ldy name_len
  99. jsr diag_init
  100. lda #$00 ; ERR files are the evidence; keep it fast
  101. sta diag_screen
  102. jsr parse_file
  103. jsr diag_finish
  104. jsr emit
  105. jsr dump_types
  106. @advance:
  107. lda #$FD
  108. jsr emit
  109. clc
  110. lda fx_ptr
  111. adc #3
  112. sta fx_ptr
  113. bcc :+
  114. inc fx_ptr+1
  115. : inc fx_index
  116. lda fx_index
  117. cmp #FIXTURE_COUNT
  118. bne @fixture
  119. lda #$FE
  120. jsr emit
  121. lda #<dump ; report while the private ZP is mapped
  122. sta MB_DATA+0
  123. lda #>dump
  124. sta MB_DATA+1
  125. sec
  126. lda dump_ptr
  127. sbc #<dump
  128. sta MB_DATA+2
  129. lda dump_ptr+1
  130. sbc #>dump
  131. sta MB_DATA+3
  132. lda failures ; everything above $3FFF disappears behind
  133. ora overflow ; BASIC ROM after mmu_shutdown: report first
  134. sta MB_CODE
  135. bne @fail
  136. lda #MB_ST_PASS
  137. ldy #ok_msg - messages ; may be 0: do not branch on it
  138. jmp @report
  139. @fail: lda #MB_ST_FAIL
  140. ldy #fail_msg - messages
  141. @report:
  142. sta MB_STATUS
  143. : lda messages,y
  144. beq @end
  145. sty print_y
  146. jsr kcall_inline
  147. .word CHROUT
  148. ldy print_y
  149. iny
  150. bne :-
  151. @end: jsr mmu_shutdown
  152. plp
  153. rts
  154. .segment "CODE"
  155. ; Emit every name ID that the parser recorded as a top-level type.
  156. dump_types:
  157. lda #$01
  158. sta id
  159. @next: lda id
  160. cmp names_count
  161. beq :+
  162. bcs @done
  163. : lda #<type_kind
  164. sta mmu_ptr
  165. lda #>type_kind
  166. sta mmu_ptr+1
  167. ldy id
  168. jsr mmu_peek1
  169. beq @skip
  170. jsr emit
  171. lda #<type_line_lo
  172. sta mmu_ptr
  173. lda #>type_line_lo
  174. sta mmu_ptr+1
  175. ldy id
  176. jsr mmu_peek1
  177. jsr emit
  178. lda #<type_line_hi
  179. sta mmu_ptr
  180. lda #>type_line_hi
  181. sta mmu_ptr+1
  182. ldy id
  183. jsr mmu_peek1
  184. jsr emit
  185. lda id
  186. jsr name_get
  187. lda name_out_len
  188. jsr emit
  189. ldx #$00
  190. : cpx name_out_len
  191. beq @skip
  192. lda name_out,x
  193. stx emit_x
  194. jsr emit
  195. ldx emit_x
  196. inx
  197. bne :-
  198. @skip: inc id
  199. bne @next
  200. @done: rts
  201. emit: ldy dump_ptr+1
  202. cpy #>(dump + DUMP_SIZE)
  203. bcc @room
  204. lda #$01
  205. sta overflow
  206. rts
  207. @room: sty emit_y
  208. ldy #$00
  209. sta (dump_ptr),y
  210. ldy emit_y
  211. inc dump_ptr
  212. bne :+
  213. inc dump_ptr+1
  214. : rts
  215. .segment "RODATA"
  216. .macro FIXTURE name
  217. .local text, done
  218. .word text
  219. .byte done - text
  220. .pushseg
  221. .segment "DATA"
  222. text: .byte name
  223. done:
  224. .popseg
  225. .endmacro
  226. fixtures:
  227. FIXTURE "MINIMAL.N8"
  228. FIXTURE "DECLS.N8"
  229. FIXTURE "ARRAYS.N8"
  230. FIXTURE "EXPRS.N8"
  231. FIXTURE "FORWARD.N8"
  232. FIXTURE "NULLS.N8"
  233. FIXTURE "STMTS.N8"
  234. FIXTURE "BADCHAR.N8"
  235. FIXTURE "BADCLASS.N8"
  236. FIXTURE "BADIFACE.N8"
  237. FIXTURE "BADMETHOD.N8"
  238. FIXTURE "DUPDECL.N8"
  239. FIXTURE "IFACEBODY.N8"
  240. FIXTURE "LINECONT.N8"
  241. FIXTURE "MISSCLASS.N8"
  242. FIXTURE "MISSEND.N8"
  243. FIXTURE "MISSIF.N8"
  244. FIXTURE "MISSMETH.N8"
  245. FIXTURE "MULTISTMT.N8"
  246. FIXTURE "ORDER.N8"
  247. FIXTURE "UNKNOWN.N8"
  248. FIXTURE "RECOVER.N8"
  249. FIXTURE "NOPROG.N8"
  250. FIXTURE "EOFCLASS.N8"
  251. FIXTURE_COUNT = 24
  252. messages:
  253. ok_msg: .byte "NOVA128 PARSER TEST OK", $0D, $00
  254. fail_msg: .byte "NOVA128 PARSER TEST FAIL", $0D, $00
  255. .segment "BSS"
  256. failures: .res 1
  257. overflow: .res 1
  258. fx_index: .res 1
  259. name_lo: .res 1
  260. name_hi: .res 1
  261. name_len: .res 1
  262. id: .res 1
  263. emit_x: .res 1
  264. emit_y: .res 1
  265. print_y: .res 1
  266. dump: .res DUMP_SIZE

Powered by TurnKey Linux.