Jump to content
IGNORED

need help with assembler


Thelen

Recommended Posts

I'm learning to program on the atari 800 in assembler. and I want to load a custum character set.but now i have a little problem, i need to load 1024 bytes, how can i do this. with my routine now i can't get passed 256 bytes. who can help ?

 

LDX #$00

KARLOO1 LDA KARAK,X

STA $2400,X

INX

TXA

CMP #255

BNE KARLOO1

 

thanks for your help,

 

Thelen

Link to comment
Share on other sites

LDX #$00

KARLOO1 LDA KARAK,X

STA $2400,X

INX

TXA

CMP #255

BNE KARLOO1

 

this does just copy 255 bytes not 256...

 

can be written as

 

ldx #0

loop1 lda karak,x

sta $2400,x

inx

bne loop1

 

this copies 256 bytes

 

to copy 1024...you can do this loop 4 times...1024/256=4

 

ldx #0

loop1 lda karak,x

sta $2400,x

inx

bne loop1

 

loop2 lda karak+256,x

sta $2400+256,x

inx

bne loop2

 

loop3 lda karak+256+256,x

sta $2400+256+256,x

inx

bne loop3

 

loop4 lda karak+256+256+256,x

sta $2400+256+256+256,x

inx

bne loop4

...

 

bne checks the zero flag... so when a,x,y registers contain zero this flag is set...therefore when the x register is going from 255 back to zero the loop is left...

 

what i have written is called unrolled loop... but you can combine x+y register to copy more than 256 bytes

 

ldy #4 ; copy 4x256 bytes=1024

loop1 ldx #0

loop2 lda chardata,x

ad sta $2400,x

inx

bne loop2 ;256 bytes copied?

inc loop2+2 ; add #1 to highadress

inc ad+2 ;add #1 to destination adress $2400 = $2500

dey

bne loop1

 

this is called selfmodified code...and works just when executed in RAM not from ROM (depends if you code on 5200 f.e.)

 

or you take zero pages:

 

lda #<source ; lo byte of source adress

sta $b0

lda #>source ; hi byte of source

sta $b1

lda #<destin

sta $b2

lda #>destin

sta $b3

 

ldx #4 ;now x register!!!

loop1 ldy #0

loop2 lda ($b0),y

sta ($b2),y

iny

bne loop2

inc $b1

inc $b3

dex

bne loop1

 

you see...thouthands of roads lead to rome... ;)

 

hve

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...