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.

45 lines
1.1KB

  1. ; Parse string in (HL) and return its numerical value whether its a number
  2. ; literal or a symbol. Returns value in IX.
  3. ; Sets Z if number or symbol is valid, unset otherwise.
  4. parseNumberOrSymbol:
  5. call parseLiteral
  6. ret z
  7. ; Not a number.
  8. ; Is str a single char? If yes, maybe it's a special symbol.
  9. call strIs1L
  10. jr nz, .symbol ; nope
  11. ld a, (hl)
  12. cp '$'
  13. jr z, .returnPC
  14. cp '@'
  15. jr nz, .symbol
  16. ; last val
  17. ld ix, (DIREC_LASTVAL)
  18. ret
  19. .symbol:
  20. push de ; --> lvl 1
  21. call symFindVal ; --> DE
  22. jr nz, .notfound
  23. ; value in DE. We need it in IX
  24. push de \ pop ix
  25. pop de ; <-- lvl 1
  26. cp a ; ensure Z
  27. ret
  28. .notfound:
  29. pop de ; <-- lvl 1
  30. ; If not found, check if we're in first pass. If we are, it doesn't
  31. ; matter that we didn't find our symbol. Return success anyhow.
  32. ; Otherwise return error. Z is already unset, so in fact, this is the
  33. ; same as jumping to zasmIsFirstPass
  34. ; however, before we do, load IX with zero. Returning dummy non-zero
  35. ; values can have weird consequence (such as false overflow errors).
  36. ld ix, 0
  37. jp zasmIsFirstPass
  38. .returnPC:
  39. push hl
  40. call zasmGetPC
  41. push hl \ pop ix
  42. pop hl
  43. ret