A85: Re: Assembling problems.


[Prev][Next][Index][Thread]

A85: Re: Assembling problems.




> 1. I'm now making a program for Usgard and I'd like to
> know how to do HL*16. Here's part of the code, I made,
> but now I realized it should do the rl for HL not only
> L. Can you help me here?
As far as I remember there is no 16 bit shift instruction, so the following
is probably a pretty good solution

ld a,l ; 1M
rlac ; 1M 1st shift
rl h ; 2M
rlac ; 1M 2nd shift
rl h ; 2M
rlac ; 1M 3rd shift
rl h ; 2M
rlac ; 1M 4th shift
rl h ; 2M
and $0f ; 2M
ld l,a ; 1M
; 16 M cycles

you could also just do:
sla l ; 2M
rl h ; 2M
sla l
rl h
sla l
rl h
sla l
rl h
; 16 M cycles

In this case it does not matter what you use, if you do <4 shifts the second
is fastest, if you do more the first is (use the second since it is
smaller). If you instead of having the data in HL have HL point to the data
the following is a  better solution:

xor a ; 1M
rld ;5 M
inc hl ; 1M
rld ; 5 M
; 12 M cycles

So it is faster and uses and operand in mem so you do not have to load it


> 2. Is there a smaller/faster way to draw a vertical
> line(ok, this is my first program, so...)?
> ;---------------
> ld bc,$4001 ;height=$40:byteofset%00000001
> ld de,$0010 ;next line is vidmem+16...
> ld hl,VIDEO_MEM+3
>
> Lineloop:
>         ld a,(hl)
> or c            ;I want to OR the PixelOnScreen
> ld (hl),a
>         add hl,de
>         djnz Lineloop

What you do in the loop is
ld a,(hl) ; 2 M
or c ; 1 M
ld (hl),a ; 2 M
; 5 M cycls

Another way to do it is
or (hl) ; 2 M
ld (hl),a ;  2 M
; 4 M cycles
So the last methos is probably better (you need to load a with 1 instead of
c).

Dines




References: