asc.asm 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. ; Returns the ascii code for the given str
  2. #include once <free.asm>
  3. ;
  4. __ASC:
  5. ;- PROC
  6. ;- LOCAL __ASC_END
  7. ldx z80_ap ;- ex af,af' ; Saves free_mem flag
  8. sta z80_ap
  9. txa
  10. lda z80_h ;- ld a,h
  11. sta z80_a
  12. ora z80_l ;- or l
  13. bne *+3 ;- ret z ; NULL? return
  14. rts
  15. ldy #$00 ;- ld c,(hl)
  16. lda (z80_hl),y
  17. sta z80_c
  18. inc z80_l ;- inc hl
  19. bne *+4
  20. inc z80_h
  21. ldy #$00 ;- ld b,(hl)
  22. lda (z80_hl),y
  23. sta z80_b
  24. lda z80_b ;- ld a,b
  25. sta z80_a
  26. ora z80_c ;- or c
  27. jeq __ASC_END ;- jr z, __ASC_END ; No length? return
  28. inc z80_l ;- inc hl
  29. bne *+4
  30. inc z80_h
  31. ldy #$00 ;- ld a,(hl)
  32. lda (z80_hl),y
  33. sta z80_a
  34. ;- dec hl
  35. __ASC_END:
  36. ;- dec hl
  37. ldx z80_ap ;- ex af,af'
  38. sta z80_ap
  39. txa
  40. ora z80_a ;- or a
  41. beq *+5 ;- call nz, __MEM_FREE ; Free memory if needed
  42. jsr __MEM_FREE
  43. ldx z80_ap ;- ex af,af' ; Recover result
  44. sta z80_ap
  45. txa
  46. rts ;- ret
  47. ;- ENDP