Video: Lesson 2 - Addressing modes on the 6502

6502, 65c02, and 6280 CPU programming
Post Reply
User avatar
akuyou
Posts: 563
Joined: Mon Apr 22, 2019 3:19 am
Contact:

Video: Lesson 2 - Addressing modes on the 6502

Post by akuyou » Tue Apr 23, 2019 12:58 pm

https://youtu.be/nOPI0Xbj_Yc

www.chibiakumas.com/6502/#Lesson2

The 6502 has very few registers - but it makes up for this with a mind boggling number of addressing modes!

You won't need them all at first, but you should at least understand what they all do - lets see some examples of how they work!

Lets try them all out with some simple examples!
Chibi Akuma(s) Comedy-Horror 8-bit Bullet Hell shooter! // 「チビ悪魔」可笑しいゴシックSTG ! // Work in Progress: ChibiAliens

Interested in CPU's :Z80,6502,68000,6809,ARM,8086,RISC-V
Learning: 65816,ARM,8086,6809

Super_Maryo_53
Posts: 2
Joined: Thu May 23, 2019 1:59 am

Re: Video: Lesson 2 - Addressing modes on the 6502

Post by Super_Maryo_53 » Thu May 23, 2019 5:18 am

Hey @Akuyou, i commented on this lessons video today, about having problems running the program through the BBC emulator and i was thinking asking here would be better.
so when i try to run the lesson prog (the test data,the chunk code and example 8), it loads up correctly for a split second then goes to this: https://imgur.com/gallery/7KPvm5F
i haven't changed any of the code and i have re-downloaded the devtools; so i think it might be because i am using win 10. But i don't really know. :|
Anyway, any help would be amazing.

User avatar
akuyou
Posts: 563
Joined: Mon Apr 22, 2019 3:19 am
Contact:

Re: Video: Lesson 2 - Addressing modes on the 6502

Post by akuyou » Thu May 23, 2019 8:54 am

Yes, the same problem is happening my end too... it looks like a bug has crept in somewhere in the 'Monitor' code...

This should only take an hour or two to figure out... give me a moment!
Chibi Akuma(s) Comedy-Horror 8-bit Bullet Hell shooter! // 「チビ悪魔」可笑しいゴシックSTG ! // Work in Progress: ChibiAliens

Interested in CPU's :Z80,6502,68000,6809,ARM,8086,RISC-V
Learning: 65816,ARM,8086,6809

User avatar
akuyou
Posts: 563
Joined: Mon Apr 22, 2019 3:19 am
Contact:

Re: Video: Lesson 2 - Addressing modes on the 6502

Post by akuyou » Thu May 23, 2019 9:46 am

Ok, I think I got it sorted... please re-download the sources file:
http://www.chibiakumas.com/6502/sources.7z

Technical bit - no need to worry about this!

I've added some more code to the common functions, and it meant the code of the example was using the areas as the 'test writes'... so the test code was corrupting the functions of the code!

I've changed the start address from $1000 to $0200, which makes enough space for the problem no longer occur
Chibi Akuma(s) Comedy-Horror 8-bit Bullet Hell shooter! // 「チビ悪魔」可笑しいゴシックSTG ! // Work in Progress: ChibiAliens

Interested in CPU's :Z80,6502,68000,6809,ARM,8086,RISC-V
Learning: 65816,ARM,8086,6809

Super_Maryo_53
Posts: 2
Joined: Thu May 23, 2019 1:59 am

Re: Video: Lesson 2 - Addressing modes on the 6502

Post by Super_Maryo_53 » Fri May 24, 2019 6:47 am

Hey Akuyou, i just got a chance to try out the new source and i'm still having the same problem :cry:
Although it's now lasting a few more seconds before going into the black screen, so now i can actually see the code in action .
I have moved on to the other lessons, since this one is more about the theory and i haven't come across any problems yet :)
Thanks again for your help and hard work! It has helped a lot.

rumothy
Posts: 2
Joined: Sat May 16, 2020 8:36 pm

Re: Video: Lesson 2 - Addressing modes on the 6502

Post by rumothy » Tue May 19, 2020 3:20 am

Akuyou, thanks a lot for doing this! This a really good tutorial and you are a really good teacher.

After copying the sources from the newest link, I cannot change the accumulator with an lda instruction.
Using the tools from https://www.chibiakumas.com/6502/6502DevTools.php and running Vasm SNS instead of Vasm BBC (still crashes) does work though.
Attachments
lesson2_1A_error.png
lesson2_1A_error.png (40.98 KiB) Viewed 8776 times

Voyager_sput
Posts: 15
Joined: Tue Jan 07, 2020 11:45 am

Re: Video: Lesson 2 - Addressing modes on the 6502

Post by Voyager_sput » Tue May 19, 2020 3:28 pm

Hi rumothy,

Did you also download the latest sources.7z to go along with the devtools? I just tried running example 2 from the Lesson2_AddressingTest.asm file in my version of the devtools/sources and it ran just fine:

it loaded $08 into the assembler, printed the values with the monitor function, then it did a LSR (logical shift right), bit shifting the bits to the right, effectively deviding 8 by 2, with another monitor printing the number 4 as expected:
Attachments
lesson2.PNG
lesson2.PNG (37.58 KiB) Viewed 8769 times

Voyager_sput
Posts: 15
Joined: Tue Jan 07, 2020 11:45 am

Re: Video: Lesson 2 - Addressing modes on the 6502

Post by Voyager_sput » Tue May 19, 2020 3:32 pm

Oh, and the SNES version doesn't crash for me. Sure it complains about a bad checksum in the ROM file, but Snes9X loads just fine for me, with the same results.

rumothy
Posts: 2
Joined: Sat May 16, 2020 8:36 pm

Re: Video: Lesson 2 - Addressing modes on the 6502

Post by rumothy » Thu May 21, 2020 11:33 am

Yep, I downloaded the latest devtools and sources from the first two links on the devtools page and I get the same result.
a: 1A

devtools page: https://www.chibiakumas.com/6502/6502DevTools.php
link1: https://www.chibiakumas.com/6502/6502DevTools.7z
link2: https://www.chibiakumas.com/6502/sources.7z

User avatar
akuyou
Posts: 563
Joined: Mon Apr 22, 2019 3:19 am
Contact:

Re: Video: Lesson 2 - Addressing modes on the 6502

Post by akuyou » Sun May 24, 2020 9:59 am

The problem with the monitor not showing the correct value of A was a bug in the monitor asm file... I've fixed it in the latest sources.7z - please re-download and give it another go.

I'm not sure why the SNES emulator is crashing - it's working OK here, I wonder if it's an issue with the emulator on your machine.
Chibi Akuma(s) Comedy-Horror 8-bit Bullet Hell shooter! // 「チビ悪魔」可笑しいゴシックSTG ! // Work in Progress: ChibiAliens

Interested in CPU's :Z80,6502,68000,6809,ARM,8086,RISC-V
Learning: 65816,ARM,8086,6809

Post Reply

Return to “General 6502 Programming”