Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

6502 Assy question

41 views
Skip to first unread message

lloyd1...@yahoo.com

unread,
Feb 18, 2013, 4:25:04 PM2/18/13
to
I've been searching for the answer to this assy language problem. I have 800H bytes of RAM memory that I want to fill with a value. It seems there is no easy way to do this since it appears that I have to work at it 100H bytes at a time which is 1 page of memory. and this operation would take 8 pages. Do I need to write a routine that makes a pass a page at a time or is there an easier way?
Thx in advance...

James Harris

unread,
Feb 18, 2013, 5:18:25 PM2/18/13
to
On Feb 18, 9:25 pm, lloyd16mm-...@yahoo.com wrote:
> I've been searching for the answer to this assy language problem. I have 800H bytes of RAM memory that I want to fill with a value. It seems there is no easy way to do this since it appears that I have to work at it 100H bytes at a time which is 1 page of memory. and this operation would take 8 pages. Do I need to write a routine that makes a pass a page at a time or is there an easier way?
> Thx in advance...

That takes me back a bit - a few decades I think! I remember trying to
clear a screen on a 6502 machine and having similar queries.

You can do it as you suggest. If you parameterise a routine it
probably won't be too awkward in the main code.

Alternatively, if you have some zero-page locations available I think
you might be able to use the (xxxx),Y addressing mode. IIRC it is
designed to access arbitrary locations in the 16-bit address space -
though it might be a bit slower.

Either way there is some work to do. From vague memory the best I
think you can do is set up some subroutines to do the work and call
them as needed. Then the limitations of the 6502 addressing become
less important.

James

Robert Wessel

unread,
Feb 18, 2013, 5:38:23 PM2/18/13
to
On Mon, 18 Feb 2013 13:25:04 -0800 (PST), lloyd1...@yahoo.com
wrote:

>I've been searching for the answer to this assy language problem. I have 800H bytes of RAM memory that I want to fill with a value. It seems there is no easy way to do this since it appears that I have to work at it 100H bytes at a time which is 1 page of memory. and this operation would take 8 pages. Do I need to write a routine that makes a pass a page at a time or is there an easier way?


You can use zero page indirect addressing to effectively create a 16
bit pointer. Then loop around a STA using that.

Something like is a fairly general purpose solution:


lda #$34 ;start at $1234
sta $60 ;pointer in $60/$61
lda #$12
lda $61

lda #$00 ;$800 bytes
sta $62 ;counter in $62/$63
lda #$08
lda $63

ldy #0
lda #0
loop:
sta ($60),y ;store to address in $60/61

clc ;increment pointer
lda $61
adc #1
sta $61
lda $60
adc #0
sta $60

sec ;decrement pointer
lda $63
sbc #1
sta $63
lda $62
sbc #0
sta $62

bcs loop


Mind you, it's been probably a couple of decades since I've written
any actual 6502 code, so the above likely has some errors, but that's
the basic idea.

OTOH if you always had $800 byes at a fixed location, a loop around
eight STAs would do the trick too:


ldx,#0
lda #0

loop:
sta addr+$0,x
sta addr+$100,x
sta addr+$200,x
sta addr+$300,x
sta addr+$400,x
sta addr+$500,x
sta addr+$600,x
sta addr+$700,x
inx
beq loop


Various optimizations are possible of course.

Robert Wessel

unread,
Feb 18, 2013, 8:25:10 PM2/18/13
to
On Mon, 18 Feb 2013 16:38:23 -0600, Robert Wessel
<robert...@yahoo.com> wrote:

>On Mon, 18 Feb 2013 13:25:04 -0800 (PST), lloyd1...@yahoo.com
>wrote:
>
>>I've been searching for the answer to this assy language problem. I have 800H bytes of RAM memory that I want to fill with a value. It seems there is no easy way to do this since it appears that I have to work at it 100H bytes at a time which is 1 page of memory. and this operation would take 8 pages. Do I need to write a routine that makes a pass a page at a time or is there an easier way?
>
>
>You can use zero page indirect addressing to effectively create a 16
>bit pointer. Then loop around a STA using that.
>
>Something like is a fairly general purpose solution:
>
(...)
>
>Mind you, it's been probably a couple of decades since I've written
>any actual 6502 code, so the above likely has some errors, but that's
>the basic idea.
>
>OTOH if you always had $800 byes at a fixed location, a loop around
>eight STAs would do the trick too:
>
>
> ldx,#0
> lda #0
>
>loop:
> sta addr+$0,x
> sta addr+$100,x
> sta addr+$200,x
> sta addr+$300,x
> sta addr+$400,x
> sta addr+$500,x
> sta addr+$600,x
> sta addr+$700,x
> inx
> beq loop


Obviously that should be a bne...

wolfgang kern

unread,
Feb 19, 2013, 2:32:13 PM2/19/13
to
IFAIR: the C-64-graphic-chip got a single command to clear or fill the
screen with a given pattern. Sorry for I cant remember in details yet.
Too many time passed since I wrote 6502 code for C-64 graphic/sound chips.

There is of course the brute force way of writing to memory blocks in a
loop, but I think there were also 16-bit capabilities with indexed
addressing which could reduce multiple 256-byte loops to a single loop.

Please don't kill me if I'm too far off with my old brain ... :)
__
wolfgang


lloyd1...@yahoo.com

unread,
Feb 22, 2013, 9:13:33 PM2/22/13
to
Thank you Robert, I found the error when I debugged the code with
my logic analyzer. I used your last example and it did the job.

My occupation these days is servicing antique jukeboxes. Many of the late 70's and early 80's machines use these legacy microprocessors and I am fascinated by this early stuff. I have had to learn assembler for many of these in order to repair the hardware. It is nice to be able write self test routines for these old controller boards to test ram chips and peripherals. The code I asked for help with was for a ram test routine. Thanks for your expertise and input from the rest of the group,
Kurt
arcade-antiques.com

jondane

unread,
Mar 24, 2013, 4:26:28 AM3/24/13
to
I responded to "ad" (uh-oh, you KNOW there is more than that to it...), I
just wanted to do it. *it* was good from *my*, well hey, are you SURE you
want me to "be in your "company""? *I* digress? Don't make me make cheap
shots at you in which you can .... what exactly is your M.O. anyway... as if
anyone did not know.

The idiocy of the Presidency of the United States of America, rape is rape.
Barrack Obama said, "rape is rape". Is there an out of context to take that?
(rhetorical).
I hate "America".
I think, Bill Clinton, Barrack Obama, are banking on PEOPLE falling
(FALLING) for it.
Do I hate them?

yes
I hate rapists.

That said, and aside, you rob pemberton, annoy me to holy hell. So shut the
fuck up. That said, I don't wanna be you? You see, I am a visionary. I know
exactly (not hardly) how, well if you would work for me, in a company ...
yada... FREEDOM!!

Is Barack Obama bad? Isn't it bad that I "pick on him"? For he has "the law"
on his side. Scuze me, was that "democracy"?

Rape is rape.

****

*I* have to what? Beg for "freedom of speech?".

No I am not (affording anyone reason to promogulate their "aristocracy" (no,
I don't know what that means)) .... now I forgot what I was "not" doing.
lol!

That "said", I am certainly here NOT doing something!


0 new messages