Re: A86: String Writing
[Prev][Next][Index][Thread]
Re: A86: String Writing
In a message dated 10/19/99 20:30:07 Eastern Daylight Time,
akdjr@softhome.net writes:
> i have a question. suppose i have the following string:
>
> text:
> .db "Welcome to EB"
>
> if i do the following:
>
> ld b,0
> ld hl,text
> start:
> push hl
> ld d,0
> ld e,b
> add hl,de
> ld a,(hl)
> call _putc
> pop hl
> push bc
> ld b,10
> hloop:
> halt
> djnz hloop
> pop bc
> inc b
> ld a,b
> cp 14
> jp z, done
> jp start
> done:
> ret
>
> will it output the string on the screen? You can assume that i have
already
> set the curCol and curRow. Also if it won't work, do i have the right idea
> about it? Basically, i want to be able to write the string out letter by
> letter.
>
It would be FAR more efficient to make the string null-terminated. That way
you can use the routine on any string, and frankly the code is smaller even
if you're using it once.
put_string:
ld a,(hl)
or a
ret z ;return when (hl)=0
call _putc ;display char
inc hl
ld b,10
put_string_delay:
halt ;delay
djnz put_string_delay
jr put_string
and call it like this:
ld hl,text
call put_string
;...more code
text:
.db "Welcome to EB",0
----
Jonah Cohen
<ComAsYuAre@aol.com>
http://linux.hypnotic.org/~jonah/