A86: Re: Re: Re: Re: Re: Re: divide by 2
[Prev][Next][Index][Thread]
A86: Re: Re: Re: Re: Re: Re: divide by 2
Try something like this...
StoreNumbers:
ld hl,StorageEnd ; point to end of storage
ld b,0 ; clear value counter
loop:
; ***load A with value here
ld (hl),a ; put A into storage
dec hl ; decrease pointer (not what it's pointing
to!)
inc b ; increase value counter (number of A's)
; ***test if done here
jr nz,loop ; if not done, loop
PrintNumbers:
ld hl,StorageEnd
xor a ; set A to 0 and clear carry flag
ld d,a ; clear high byte
ld e,b ; load value counter
sbc hl,de ; calc beginning
loop:
ld a,(hl) ; load value
call DispA ; print it
inc hl ; move to next item
djnz loop ; loop for all items
This is just a rough idea and you'll have to worry about saving registers
and all that other stuff. But I think it helps if you see the code in asm,
rather than basic (since basic is nothing like asm). This kind of stuff is
VERY similiar to using arrays in C, so if you learn the concepts with that
first, you might be surprised at how easy the actual asm coding is. I find
that concepts are the problem most of the time, not the actual asm...
>
> Basically what I want to do is to store between 25 and about 255 values
>(ranging from 0-9). This was the only way I could think of. I don't want
>to do all the .db 's because the amount of values I store will be different
>every time.
>
> What I want to do hopefully is:
>
>---------------------------------------------------------------------------
-
>-
>initially "hl" points to the end of _asm_exec_ram
>------------------------------------------------------------------------
> *execute some code and store a value 0-9 in "a"*
>-------------------------------------------------------------------------
> ld (hl),a
>--------------------------------------------------------------------------
>LOOP:
>
>*execute some code and store a value 0-9 in "a"*
>*also do something to set a flag or something to leave the loop if it's
>done*
>-------------------------------------------------------------------------
> dec (hl)
>
> ld (hl),a
>
> jp LOOP
>--------------------------------------------------------------------------
>
>-i want to write in in backwards then read it forwards!?!?
>
>-When I'm done If what has been placed in "a" in order is:
>0,1,2,3,4,5,6,7,8,9
>-At the end (hl) will point to 9 (it was the last number put in)
>-mem from (hl) to end of _asm_exec_ram will be 9,8,7,6,5,4,3,2,1,0
>-so to write it I could (using that nice routine to display the value of
"a"
>to the screen)
> then do a loop on: ld a,(hl), (display "a" to screen) inc (hl)
until
>(hl) == end of _asm_exec_ram, else redo
> loop.
>
>
>DOES ANY OF THIS LOOK REMOTELY CORRECT? If it does I promise I'll stop
>bugging everyone for a while with all these questions...
>
>thanks very much!
>
> ,billybobIV
> chad@dirks.com
> http://chad.dirks.com
>
>
>
>----- Original Message -----
>From: David Phillips <david@acz.org>
>To: <assembly-86@lists.ticalc.org>
>Sent: Thursday, March 04, 1999 4:06 PM
>Subject: A86: Re: Re: Re: Re: divide by 2
>
>
>>
>>Umm...
>>
>>_asm_exec_ram starts at $d748 and ends wherever your stack ends (starts?).
>>The stack begins (ends) at $fbff and grows DOWNWARDS into _asm_exec_ram.
>>Why they chose to do this, I have no idea. IMHO, memory should have been
>>layed out with ram page 7 being located (and swapable!) at $8000, like the
>>85. Then your asm program could execute at the end of it and have almost
>>30k of contiguous ram. And putting the stack right below video ram is bad
>>also, because if you want two contiguous grayscale planes, you have to
move
>>the stack. No big deal, but why should you have to waste space when the
>>program loader could do it?
>>
>>Do you mean you want to fill an area with a number? Do this...
>>
>> ld hl,Start
>> ld de,Start+1
>> ld bc,Length-1
>> ld (hl),n
>> ldir
>>
>>>
>
>
>
>
>