Assembly: How to save RAM, and how to print RAM to the screen

Tutorials and help articles.

(Posts require approval. See pinned post.)
Forum rules
Post guides, tutorials, and other instructional content here.

This topic area requires approval, so please be patient while we review content to make sure it fits the expectations for this topic area.

Tech support questions should be asked in Hardware or Software support.
rje
Posts: 1263
Joined: Mon Apr 27, 2020 10:00 pm
Location: Dallas Area

Assembly: How to save RAM, and how to print RAM to the screen

Post by rje »


Thank you Stefan — I didn’t know that.

I had the ADC in mind, if I stored 1 in A, then I’d be incrementing with carry.  Then I’d have to BCS or whatever that’s called, which is still messy I suppose.

rje
Posts: 1263
Joined: Mon Apr 27, 2020 10:00 pm
Location: Dallas Area

Assembly: How to save RAM, and how to print RAM to the screen

Post by rje »


Found hints of this on the infowebs...

But I may be very wrong.

 

clc

Lda #01

adc >my-address

adc <my-address

 

Its probably really slow, right?  4 clocks each for the ADC $$$$.  Or there’s a fundamental flaw in my logic.

rje
Posts: 1263
Joined: Mon Apr 27, 2020 10:00 pm
Location: Dallas Area

Assembly: How to save RAM, and how to print RAM to the screen

Post by rje »


This makes me think about SWEET16

Stefan
Posts: 454
Joined: Thu Aug 20, 2020 8:59 am

Assembly: How to save RAM, and how to print RAM to the screen

Post by Stefan »


I guess you could use ADC, but it would be more code and slower.

Assuming you are using r0 as zero page vector, this might work (not tested):


ldx #<$8000



ldy #>$8000



stx r0



sty r0+1

 


loop:



clc



lda r0



adc #1



sta r0



lda r0+1



adc #0 ;Adding carry



sta r0+1

 


lda (r0) ;Indirect addressing mode without Y, not supported by original 6502



beq end



jsr $ffd2 ;Print char



bra loop

 


end:



rts


 

Ed Minchau
Posts: 499
Joined: Sat Jul 11, 2020 3:30 pm

Assembly: How to save RAM, and how to print RAM to the screen

Post by Ed Minchau »



On 12/25/2021 at 8:40 AM, rje said:




Found hints of this on the infowebs...



But I may be very wrong.



 



clc



Lda #01



adc >my-address



adc <my-address



 



Its probably really slow, right?  4 clocks each for the ADC $$$$.  Or there’s a fundamental flaw in my logic.



You're just looking to increment a 16 bit index spread across two bytes.  The INC and INX and INY operations set the Z flag if the result is zero and sets the N flag if the most significant bit of the result is 1.

So, if your 16 bit value is stored in say zero page addresses 7E (low byte) and 7F (high byte) then

INC 7E

BNE# 02

INC 7F

And @ZeroByte is correct, the easiest way to save something from VRAM to file is to copy it to low RAM and save it from there.  Or if it is a big file, copy it to consecutive banks of banked RAM and save it from there.

ZeroByte
Posts: 714
Joined: Wed Feb 10, 2021 2:40 pm

Assembly: How to save RAM, and how to print RAM to the screen

Post by ZeroByte »



On 12/23/2021 at 9:53 PM, Greg King said:




That's BASIC's way of doing it.  In Assembly, SETLFS doesn't take anything in the accumulator for LOAD/SAVE calls.  And, the "VRAM bank + 2" is put into the accumulator of the LOAD call (i.e., the 17-bit VRAM address is given directly to the LOAD call).



I knew better than that - it's the .A value of LOAD, not SETLFS. Whoops. (fixed my post)

Thanks for pointing it out.

Post Reply