It is currently Wed Apr 24, 2019 6:48 pm

 All times are UTC - 7 hours

 Page 19 of 24 [ 354 posts ] Go to page Previous  1 ... 16, 17, 18, 19, 20, 21, 22 ... 24  Next
 Print view Previous topic | Next topic
Author Message
 Post subject: Re: Hello, new here, and need best recommandations.Posted: Sun Sep 16, 2018 9:36 pm

Joined: Sun Jun 17, 2018 6:41 pm
Posts: 155
Let see if I got at least 99% right on it...

*********************************************************************************************************
*********************************************************************************************************
*********************************************************************************************************

The limitations of 6502 CPU is 255. The HEX version is FF. The Binary version is 1111 1111 [or 11111111. Space in the middle helps a little?]

The number system in this style is wheels. It means if you go over 255, it will go back to 0.

6502 } 255 + 2 = 001.

It's the same thing in backwards. If you go below 0, it will go back to 255.

6502 } 3 - 5 = 254.

... 253, 254, 255, 0, 1, 2, ...
... 3, 2, 1, 0, 255, 254, 253, ...

Works either way.

The code line is always read from TOP to BOTTOM.

-------------------------
-------------------------
-------------------------

Any number / digit / variable / value = N
The "lever", or on [1] and off [0] = B

HEX number written >>> #\$NN

Normal Number / Immediate Decimals number written >>> #NN

Binary number written >>> %\$BBBBBBBB

Immediate Decimals Minimum Written = #N
Maximum usages Maximum Written = #NNN

----------

The Address [The location, destination, and objective of the code] >>> \$NNNN

\$NN = \$00NN

\$NNN = \$0NNN

\$N = 000N

\$NNNN = \$NNNN

The zeros is not used, while N is.

--------------------------
--------------------------
--------------------------

A label is a type of directive that makes it easier to go "back in time", or go directly to the label that's in the future OR the past of the codings using JMP/BEQ/BNE.

======EXAMPLES=====

cupcakes:
LDA \$03

pancakes:
LDA \$05

toilet:
LDA \$FF
STA \$FFFF

--

Think of something like a magical teleportation pod that said "@GOTO" with the name of the label in front of it. Except a little different.

***

A comment is a type of extremely simple code used to organize things. No matter how much you write in this, it will never be operated nor used inside the comment.

It's always a comment when it's after the [ ; ] symbol.

===EXAMPLES===

LDA \$01 ; Yo man. Wanna go to a stag party?

LDX \$02 ; Sounds dope, bruh! I hope I can bring some grasses in!

LDY \$03 ; I happen to be a vegetarian! I'm so offended you mention grasses; my Dad was a tree trunk!

=============

All the hilarious comments above will never be implemented into the code. So write whatever you want.

--------------------------
--------------------------
--------------------------

Register is simple number carrying system with fancy name that holds number, awaiting for commands to be replaced, or to placed.

The numbers never disappeared once assigned, or given a number, regardless. You always have to replace it to change the number/value/digit/variable.

With this, you can carry up to three numbers, maximum of 255 for each.

-----------

The limitations for each is:

A = You cannot increment, or fancy word of adding one, to the number stored into Register A directly. [INC/INX/INY] You have to do the INC to the Address that got the number from Register A to do that.

X/Y = You cannot transfer numbers from Register X and Y together. [TAX, TAY]
You can only transfer numbers from Y to A, and from X to A. But never X to Y and Y to X back again.

--------------------------
--------------------------
--------------------------

LDA / LDX / LDY - "Load Data into A/X/Y Register"

You put any number into the register A, X, or Y.

===EXAMPLE1===

LDA #\$0F

STA \$0001

---

A = 15 [The F number for HEX.]

The Address \$0001 is now carrying number 15.

===EXAMPLE2===

LDX #13

STA \$0030

---

X = 13

The Address \$0030 is now carrying number 13.

===EXAMPLE3===

LDY %#00001010

STA \$13

---

Y = 10 [The number from Binary]

The Address \$0013 is now carrying number 10.

--------------------------
--------------------------
--------------------------

TAX / TAY = Transfer Register A to X. or. Transfer Register A to Y.

TXA / TXY = Same thing as above, but other way.

Despite the name, the TXA/TXY/TAX/TAY copies the number from one register to another. It never loses its number, just copy.

If there is no program written in A/X/Y, nor any number placed into any Register, than it will copy to targeted Register as zero.

===EXAMPLE1===

LDA #\$10

TAX

---

Register A is carrying number 15, or 10 in HEX number.

Register A has "transfer", or COPY, number 15 into Register X.

Right now, Register A and Register X has number 15 ready to be placed or replaced.

===EXAMPLE 2===

TAY

LDX #18

LDA #\$FF

---

Register A has no number inside it, so it always has zero as default. As such, Register Y is now carrying number 0.

Register X is now carrying number 18.

Register A is now carrying 255 [FF in HEX number, the maximum for 8-bit.]

For this code:

A = 255
X = 18
Y = 0

===EXAMPLE 3===

LDA \$01

TAX

TAY

LDY \$05

TYA

---

Register A is now carrying number 1.

Register A is "copy and paste" number 1 for Register X ::: X is now carrying number 1.

Register A is also "copy and paste" number 1 for Register Y. ::: Y is also carrying number 1.

Register Y is being given number 5 to carry. Because Y already has number 1, it get's replaced and now it's number 5. ::: Y is now carrying number 5.

Register Y is "copying and paste" [TYA] number 5 for A.

A was carrying number 1, but as A is holding number 5 now, it replaces number 1 with number 5. ::: A is now carrying number 5 instead.

As a result from this ----

A = 5

X = 1

Y = 5

--------------------------
--------------------------
--------------------------

Increment - The smarty word for addition by one.

Decrement - The smarty word for subtraction from one.

INC / INX / INY = Increment, or add one, to the Address / Register X / Register Y.

***NOTICE***

For other programs, you could do INC STEP 2, INC STEP 5, to increment by addition of 2, or 5, or any number. Same thing with decrement.

But for 6502 Assembly, you can only do increment / decrement by 1.

************

===EXAMPLE1===

LDX #20

INX

---

X is now carrying number 20.

Increment X. Meaning you add by 1 to the X Register.

X is now carrying number 21.

===EXAMPLE2===

LDA \$#0D

STA \$0010

INC \$0010

---

Put number 13 [D in HEX number] into Register A.

Store number 13 from Register A into Address \$0010

Increment Address \$0010 by one. It does NOT mean \$0011! It only increments/decrements INSIDE the Address that the Register stored!

Address \$0010 is now carrying 14.

===EXAMPLE3===

LDY #02

DEY

DEY

DEY

DEY

STY \$1000

---

Put number 2 into Register Y.

Decrement Register Y FOUR times according to the code.

2 - 1 = 1

1 - 1 = 0

0 - 1 = 255

255 - 1 = 254

[The math is wrong, but it's right ONLY in 6502 CPU programming!]

Store number 254 from Register Y into Address \$1000.

Now Address \$1000 is holding number 254.

--------------------------
--------------------------
--------------------------

JMP = Jump.

VERY simple, but can also be effective. An empty label will also work.

===EXAMPLES===

LDX \$01

letsdoitagain:

INX

JMP letsdoitagain

---

Register X is now carrying number 1.

Increment, or add 1, to Register X. Now carrying 2.

JMMP, [Jump] to the label letsdoitagain. Or in other words, "Go directly to the label named, "letsdoitagain" !!!"

You are now on the label "letsdoitagain".

Increment Register X, now carrying 3.

IT NEVER ENDS!!!!!!!!

Top

 Post subject: Re: Hello, new here, and need best recommandations.Posted: Sun Sep 16, 2018 11:43 pm

Joined: Wed Apr 02, 2008 2:09 pm
Posts: 1283

Quote:
Binary number written >>> %\$BBBBBBBB

It's '%'. (Usually. Many things depend on which assembler you use.)
easy6502 doesn't support binary at all, as far as I know.
'%' = binary.
Neither = decimal.
If you use '#' you want the value. If you leave out the '#' it's an address.
Quote:
than it will copy to targeted Register as zero.

True in easy6502. Not really true in any other context, so do not rely on this. Never rely on any values in RAM/Addresses/Registers or otherwise that you didn't put there yourself, and that aren't a documented part of the hardware. Don't transfer from X without putting a known value there first, for example. Don't rely on RAM to be zero unless you are sure you stored zero there beforehand.

Some examples have read and copied from things without writing there first, but only so the focus could be on addresses rather than the values themselves.
Quote:
Register A is carrying number 15, or 10 in HEX number.

\$10 = 16, not 15.
Quote:
===EXAMPLE 3===

LDA \$01

TAX

TAY

LDY \$05

TYA

---

Register A is now carrying number 1.

No. It's carrying the value inside address 1.
Quote:
Register Y is being given number 5 to carry. Because Y already has number 1, it get's replaced and now it's number 5. ::: Y is now carrying number 5.

Also no. It's carrying the value inside address 5. If you don't precede the number with a '#' it's an address.

Quote:
LDA \$#0D

'#' has to be used before the '\$'.
#\$, not \$#.
Quote:
LDX \$01

letsdoitagain:

INX

JMP letsdoitagain

---

Register X is now carrying number 1.

Nope, it's carrying the value inside address 1. I'm drilling this into your head now, it creates some obscure bugs if you don't get used to using # when you want to load a value rather than from an address.

I'm not sure I caught every error, but you totally do get it even if there are mistakes.

Anyway, next up is a new addressing mode (and a really tiny crash course on loops). We're finally getting back to the face. It's been a while, yeah?

Very early on, I mentioned how one of the differences between the registers are which instructions and addressing modes are available. And that some addressing modes wouldn't make sense for some registers. (Or, at least. I think I did! I'm not gonna look for it.)

We've done quite a lot with Absolute Addressing. That's lda \$0000 or sta \$0000. It deals with the value stored at the given address.

The next thing is, again, very simple. Absolute,x and Absolute,y addressing. They deal with the value stored in the address that is X or Y places away from the given address.

The syntax is LDA \$????,x for absolute,x and LDA \$????,y for absolute,y.
If X is zero, the result of absolute,x will be essentially identical to absolute addressing.
If Y is zero, the result of absolute,y will be essentially identical to absolute addressing.
Code:
ldx #\$00
ldy #\$00

lda \$0200;Fetch the value from address \$0200.
lda \$0200,x;Fetch the value from address \$0200+x. Since X is 0, and \$0200+0=\$0200
;It will still fetch the value from address \$0200.

lda \$0201;Fetch the value fom address \$0201.
lda \$0201,y;Fetch the value from address \$0201+y. Since Y is 0, and \$0201+0=\$0201
;It will still fetch the value from address \$0201.

The magic happens when X or Y is not zero when you use the corresponding addressing mode.

I'll pause here to make one thing clear here. X or Y is added to the address itself, and then that address is used to get the actual value. X or Y is NOT added to the actual value stored inside the address.

Code:
lda #\$0F
sta \$0200
lda #\$02
sta \$0201
lda #\$08
sta \$0202

ldx #1
lda \$0200,x;A now holds the value 2. \$0200+X (which holds 1) is \$0201. Inside \$0201 is #\$02
inx;Now X = 2
lda \$0200,x;A now holds the value 8. \$0200+X (which holds 2) is \$0202. Inside \$0201 is #\$08

Note that wrapping at 255 does NOT apply to the addition or X or Y to the address in this context.
Code:
lda #\$0B
sta \$0300

ldy #\$01
lda \$02FF,y;\$02FF+Y (which holds 1) is \$0300. Inside \$0300 is #\$0B. So now A holds #\$0B

So perhaps now you see one of the reasons for multiple registers. And also why they're slightly different. It'd be a bit weird to do LDY \$0200,Y, but you can do LDY \$0200,X.

What is this addressing mode useful for? It allows you to access data that is grouped in addresses. Remember how the pixels in easy6502 are in sequential addresses? Check out this code.
Code:
lda #\$02
ldx #\$00
loop:
sta \$0200,x
inx
bne loop

This makes 256 pixels of the screen red in easy6502. With your previous knowledge, you would have had to write 256 writes to do that. One for each pixel. Here there's only one write, used for all 256 pixels.

How does it work?
It gets the color to draw with in A.
It starts X with the value 0.
It stores the value in A to \$0200+x, which colors one pixel red.
Then in adds one to X. Because 1 is not zero, it goes back to the loop label.
It stores the value in A to \$0200+x. But because this time X is 1 and not zero, it is coloring a different pixel than before.

It does 256 pixels because eventually X gets to 255. The inx will then make it zero. And then the branch won't go to the label and the program ends.

This concept is a "loop" in programming. It's one of the fundamental concepts. They are usually set up to do the same (or nearly) the same operation on slightly different pieces of data.

And you may have already noticed how this will tie back to the face.
this post
Contains your code for the face. Any horizontal line can be done with a loop.

Let's take a look at how to turn your top horizontal line code:
Code:
lda #\$04
sta \$0200
sta \$0201
sta \$0202
sta \$0203
sta \$0204
sta \$0205
sta \$0206
sta \$0207
sta \$0208
sta \$0209
sta \$020A
sta \$020B
sta \$020C
sta \$020D
sta \$020E
sta \$020F
sta \$0210
sta \$0211
sta \$0212
sta \$0213
sta \$0214
sta \$0215
sta \$0216
sta \$0217
sta \$0218
sta \$0219
sta \$021A
sta \$021B
sta \$021C
sta \$021D
sta \$021E
sta \$021F

into a loop.

First, load X with how many pixels across the line is minus 1. (That is, if you want to draw 32 pixels, you must load X with 31). Then load A with the color you want. Then, store the value in A using absolute,x addressing (the address should be the one for the leftmost pixel in the horizontal line.) Then decrement X, and branch if not equal above the store. Immediately after the loop, store to the address of the leftmost pixel (using absolute addressing.)
Code:
lda #\$04
ldx #\$1F
toplineloop:
sta \$0200,x
dex
bne toplineloop
sta \$0200

Way shorter, yes? And to briefly explain this one. Imagine you want to draw a 2 pixel line.
You'd load X with 1. After a single dex, there wouldn't be a branch and you've only drawn one pixel. So you draw the next one after the loop. If you had loaded X with 2, it would take two dex before the branches would stop. ETC.

Your assignment this time is to convert ALL horizontal lines in your old face code to loops like this.

PS: Perhaps this helps with the adding numbers exercise?

To be honest, I'm not entirely sure what to cover next. Most of the remaining concepts get a little denser, and I'm not sure which is best to do first.

There's pointers. (The two hardest addressing modes. One of two, I have actually never used, so I wouldn't teach it. The other one is super useful, but hard to explain immediately how. It's abstract...)

There's addition/subtraction/comparing. (This is easyish to give a quick explanation to, but hard to really cover.)

There's signed/unsigned numbers. (The above somewhat relies on this? Hmm...)

There's bitwise logic. (Easy so long as you don't overthink it)

And the stack. (easyish to give a quick explanation to, but hard to really cover...)

I'll think about it! I guess technically the addition circuit gives you the most fun tools, and starts to get meaty... and from there bitwise logic gets easier, with those then you'll know basically all the instructions.

_________________
https://kasumi.itch.io/indivisible

Top

 Post subject: Re: Hello, new here, and need best recommandations.Posted: Mon Sep 17, 2018 1:59 pm

Joined: Thu Apr 23, 2009 11:21 pm
Posts: 981
Location: cypress, texas
DocWaluigean wrote:
unregistered wrote:
DocWaluigean wrote:
That's kind of true,
I was going to say I was only speaking truth about my life but, now I realize that you ment, "That's kind of true about me,"

DocWaluigean wrote:
Also, thanks on never giving up! And praise God too.
You're welcome. And

DocWaluigean wrote:
P.S. I don't trust Lumosity who uses knowledges and brain training for monetary gains. I agree on Brain Age though.
Lumos Labs spent and spends lots of time creating the many brain training games that improve my brain. They also bought and maintain the countless servers that allow Lumosity users all over the world to log in and train their brains daily, if people want to. They created LPI Lumosity Points Index which is a number that helps each user to know how well their brain is doing. They employ a help center staff that answers questions. It's a pretty extravagant outreach to help us improve our brains and it's very helpful and so much fun, for me, so I am more than happy to spend the subscription fee. That's why I recommend the service.

Brain Age is cheaper, but, for me, it's like eating sand. Sand is not nutritious for me. I seriously hope Brain Age helps you tons more than it helped me. And it could, I guess, cause I've been playing Lumosity and haven't played Brain Age in many years.

eoLumosity talk.

Ya didn't mention the sandwich, did ya?

Also, there's a question I got for you: Imagine a world without free knowledge. Would you love it?
It's good there's Lumosity about it, but it's also bad making profit by forces about it excluding free trials when it should really help the people instead.
Lumos Labs is a company; they provide a service; that service does help many people. People like my uncle, for instance, whose brain has improved. He has thanked me many times for introducing him to Lumosity. He says their service keeping all parts of his brain active helps him think more clearly when he needs it to... like when he runs his business/company, which provides service that helps people too. His business/company collects money too.

Top

 Post subject: Re: Hello, new here, and need best recommandations.Posted: Sat Sep 22, 2018 10:01 am

Joined: Sun Jun 17, 2018 6:41 pm
Posts: 155
Sorry for looong time. You pretty much know why. It's bad luck days for me earlier.

Could you give me another examples or mnemonics about the ,x ,y stuff? I been reading it and I don't get it.

---

-So the ,x ,y situations is that it allows you to copy from one Address Code into another Address Code upon the directions of what 'Address Code + X/Y = 2ND Address Code'?

\$0001 has 5

\$0004 has 10

-
LDX #2

LDA \$1, x ; === \$0003 now has number 0

INX ; Making X = 3

LDA \$0001, X ; Now copied number 5 from Address \$0001 into the "additions of X locations", which means Address \$0004 now is carrying number 5, replacing the previous number, 10.

-

I'm guessing I'm going to call it, "Map Comma" tech. Or "Sextant Comma" or "Charter Comma" or something that involves map and directions to Address. Maybe Compass Comma.

Been wondering if I should give every tech. new names so anyone can learn more easier with mnemonic or idioms.

Top

 Post subject: Re: Hello, new here, and need best recommandations.Posted: Sat Sep 22, 2018 2:11 pm

Joined: Wed Apr 02, 2008 2:09 pm
Posts: 1283
Whenever it seems complicated, take a step back.

The mnemonic is separate from the addressing mode.

LDA always copies a new number into A. It reads, rather than writes. It does nothing else. So LDA absolutely anything will never change a value stored at an address. (Well... in some specific hardware cases a read can appear to change the value stored at an address, but it's something else. And the something else affects all reads, not just ,x or ,y ones. )

In LDA's case, the addressing mode specifies how to get the value to copy to A.
In STA's case, the addressing mode specifies how to get the address to write A's value to.

LDA \$0000 means copy the value from \$0000. \$0000 is the "given address".
STA \$0002 means write the value in A into address \$0002. \$0002 is the "given address".

Let's call the address that LDA ends up copying from/the address STA ends up writing to the "final address." In the \$???? addressing mode, the given address and the final address are always the same.

Like in
LDA \$0001,x
\$0001 is the given address, but what's in \$0001 doesn't matter for the calucation of the final address. X is added to the given address' number itself (\$0001 in the example) to get the final address, and then A gets the value stored at that final address as usual.

For STA, similarly, the value in A would get written to that final address.

If X is 0, the final address is the given address just like the \$???? addressing mode. If X is 1, the final address is the given address + 1.

If X is 5, and the address is \$0100, the final address is \$0105 because \$0100+5=\$0105.
Code:
ldx #5
lda \$0100,x
;will use the same address to get the value for A as
lda \$0105
inx;Now X is 6
;So now
lda \$0100,x
;will use the same address to get the value for A as
lda \$0106

If X is 7 and the address is \$02FF, the address used is \$0306 because \$02FF+7=\$0306.
Code:
ldx #7
lda \$02FF,x
;will use the same address to get the value for A as
lda \$0306

dex;Now X is 6
lda \$02FF,x
;will use the same address to get the value for A as
lda \$0305

_________________
https://kasumi.itch.io/indivisible

Top

 Post subject: Re: Hello, new here, and need best recommandations.Posted: Wed Sep 26, 2018 11:45 pm

Joined: Sun Jun 17, 2018 6:41 pm
Posts: 155
Kasumi wrote:
Whenever it seems complicated, take a step back.

The mnemonic is separate from the addressing mode.

LDA always copies a new number into A. It reads, rather than writes. It does nothing else. So LDA absolutely anything will never change a value stored at an address. (Well... in some specific hardware cases a read can appear to change the value stored at an address, but it's something else. And the something else affects all reads, not just ,x or ,y ones. )

In LDA's case, the addressing mode specifies how to get the value to copy to A.
In STA's case, the addressing mode specifies how to get the address to write A's value to.

LDA \$0000 means copy the value from \$0000. \$0000 is the "given address".
STA \$0002 means write the value in A into address \$0002. \$0002 is the "given address".

Let's call the address that LDA ends up copying from/the address STA ends up writing to the "final address." In the \$???? addressing mode, the given address and the final address are always the same.

Like in
LDA \$0001,x
\$0001 is the given address, but what's in \$0001 doesn't matter for the calucation of the final address. X is added to the given address' number itself (\$0001 in the example) to get the final address, and then A gets the value stored at that final address as usual.

For STA, similarly, the value in A would get written to that final address.

If X is 0, the final address is the given address just like the \$???? addressing mode. If X is 1, the final address is the given address + 1.

If X is 5, and the address is \$0100, the final address is \$0105 because \$0100+5=\$0105.
Code:
ldx #5
lda \$0100,x
;will use the same address to get the value for A as
lda \$0105
inx;Now X is 6
;So now
lda \$0100,x
;will use the same address to get the value for A as
lda \$0106

If X is 7 and the address is \$02FF, the address used is \$0306 because \$02FF+7=\$0306.
Code:
ldx #7
lda \$02FF,x
;will use the same address to get the value for A as
lda \$0306

dex;Now X is 6
lda \$02FF,x
;will use the same address to get the value for A as
lda \$0305

LDA always copies a new number into A. It reads, rather than writes. It does nothing else. So LDA absolutely anything will never change a value stored at an address. (Well... in some specific hardware cases a read can appear to change the value stored at an address, but it's something else. And the something else affects all reads, not just ,x or ,y ones. )

In LDA's case, the addressing mode specifies how to get the value to copy to A.
In STA's case, the addressing mode specifies how to get the address to write A's value to.

LDA \$0000 means copy the value from \$0000. \$0000 is the "given address".
STA \$0002 means write the value in A into address \$0002. \$0002 is the "given address".

Why does everything need to have complex explanation, when people like I could understand it more if the wording was much simpler? Re-reading in my calm mood, it's basically unnecessary-complex repeat of the early tutorials of what we learnt. Like I said earlier, it's more of a "Map Comma", "Carto-Comma" "Cartographic Comma" to me. If I somehow forgot and reread the previous post about Register, I'd understand it more than this...

=====

Code:
LDA #\$04
LDX #\$1F

TOPHAT1:
STA \$0200, X
DEX
BNE TOPHAT1

SIDEHAT:
sta \$0200
sta \$0220
sta \$023F
sta \$0240
sta \$025F
sta \$0260
sta \$027F
sta \$0280
sta \$029F
sta \$02A0
sta \$02BF
sta \$02C0
sta \$02DF
sta \$02E0
sta \$02FF
sta \$0300
sta \$031F
sta \$0320
sta \$033F
sta \$0340
sta \$035F
sta \$0360
sta \$037F
sta \$0380
sta \$039F

;-------

HATLOOP:

STA \$03A0, X
DEX
BNE HATLOOP

Top

 Post subject: Re: Hello, new here, and need best recommandations.Posted: Thu Sep 27, 2018 2:51 am

Joined: Wed Apr 02, 2008 2:09 pm
Posts: 1283
I/easy6502/Nerdy Nights/whatever think way more about how to present information than I think you give us credit for. To be really frank, I do not think the simplest explanations are the ones that have had the most success here. "LDA will never change the value stored at an address." is a valid and simple response to your last post. I spent extra time presenting something I thought would be more helpful.

Remember that how I present the information in my posts is based on your posts. If I explain something again, reexamine if you really know it or just think you do because it means something you said implied to me that you didn't understand. If I thought you understood it, why would I spend time trying to explain it a different way especially after the 18th when I said I'd help much less?

Always think about this. "Why did they spend the time?" If ever you think an explanation is complex (and not just one of mine), it can be very helpful to think about what factors may have gone into deciding to spend more time to present the explanation that way. Often when someone thinks something can be made simpler, they're missing something. Flipping the perspective can help one realize the holes in one's understanding without needing to ask.

If you think you've got the concepts, then complete the assignment.

_________________
https://kasumi.itch.io/indivisible

Top

 Post subject: Re: Hello, new here, and need best recommandations.Posted: Thu Sep 27, 2018 10:28 am

Joined: Sun Jun 17, 2018 6:41 pm
Posts: 155
Kasumi wrote:
I/easy6502/Nerdy Nights/whatever think way more about how to present information than I think you give us credit for. To be really frank, I do not think the simplest explanations are the ones that have had the most success here. "LDA will never change the value stored at an address." is a valid and simple response to your last post. I spent extra time presenting something I thought would be more helpful.

Remember that how I present the information in my posts is based on your posts. If I explain something again, reexamine if you really know it or just think you do because it means something you said implied to me that you didn't understand. If I thought you understood it, why would I spend time trying to explain it a different way especially after the 18th when I said I'd help much less?

Always think about this. "Why did they spend the time?" If ever you think an explanation is complex (and not just one of mine), it can be very helpful to think about what factors may have gone into deciding to spend more time to present the explanation that way. Often when someone thinks something can be made simpler, they're missing something. Flipping the perspective can help one realize the holes in one's understanding without needing to ask.

If you think you've got the concepts, then complete the assignment.

I don't understand the concepts. There's an error I found which draws the entire line like paintbrush I submitted a while ago.

EDIT: Sorry for my behaviour though.

Top

 Post subject: Re: Hello, new here, and need best recommandations.Posted: Thu Sep 27, 2018 1:00 pm

Joined: Wed Apr 02, 2008 2:09 pm
Posts: 1283
Help me help you. What specifically don't you understand about the concepts? Assume whenever I make a post, I feel I have already made it as simple and clear as I can.

So telling me the explanation is complicated is not really feedback I can use beyond trying to explain some different way which may not target the part you don't understand. If I reexplain addressing modes (which I've done in the the rest of the post), but your issue is with looping then no one has won. You've got to be specific about the issues you're having or I have to guess.

In the ,x addressing mode. X is treated as a number. The 16 bit address before the ,x (not the value stored in that address) is treated as a number. These two numbers are added together to get a new number. This new number is the address that gets used.

In LDA, the value from the new address is copied to A.
In STA, the value in A is stored to the new address.

Edit: To help you help me, with the descriptions above, look at the code examples. The behavior exactly matches. Which of the steps from which example gives you a result you do not fully understand? Walk through each step of what should happen. (X is added to the address. So the result in the example should be this.) And stop whenever your result following the steps is different than what I said the result should be. And then I'll try to explain that difference.

Edit2: Assuming the paintbrush error you described was in your last piece of code. Above the "TOPHAT1" label, you initialize X to 31. Then you use dex and bne in a loop together. This loops 31 times, because to get below the bne, X must be zero.

Above the "HATLOOP" label, you do not initialize X. This means it is still zero from after the TOPHAT1 loop. You still use dex and bne in a loop together. This loops 256 times, because to get below the bne, X must be zero.

It starts at 0. 1 is subtracted to get 255. 255 is not equal to zero, so it loops.
Then 254, etc.

_________________
https://kasumi.itch.io/indivisible

Top

 Post subject: Re: Hello, new here, and need best recommandations.Posted: Thu Sep 27, 2018 8:11 pm

Joined: Sun Jun 17, 2018 6:41 pm
Posts: 155
Kasumi wrote:
Help me help you. What specifically don't you understand about the concepts? Assume whenever I make a post, I feel I have already made it as simple and clear as I can.

So telling me the explanation is complicated is not really feedback I can use beyond trying to explain some different way which may not target the part you don't understand. If I reexplain addressing modes (which I've done in the the rest of the post), but your issue is with looping then no one has won. You've got to be specific about the issues you're having or I have to guess.

In the ,x addressing mode. X is treated as a number. The 16 bit address before the ,x (not the value stored in that address) is treated as a number. These two numbers are added together to get a new number. This new number is the address that gets used.

In LDA, the value from the new address is copied to A.
In STA, the value in A is stored to the new address.

Edit: To help you help me, with the descriptions above, look at the code examples. The behavior exactly matches. Which of the steps from which example gives you a result you do not fully understand? Walk through each step of what should happen. (X is added to the address. So the result in the example should be this.) And stop whenever your result following the steps is different than what I said the result should be. And then I'll try to explain that difference.

Edit2: Assuming the paintbrush error you described was in your last piece of code. Above the "TOPHAT1" label, you initialize X to 31. Then you use dex and bne in a loop together. This loops 31 times, because to get below the bne, X must be zero.

Above the "HATLOOP" label, you do not initialize X. This means it is still zero from after the TOPHAT1 loop. You still use dex and bne in a loop together. This loops 256 times, because to get below the bne, X must be zero.

It starts at 0. 1 is subtracted to get 255. 255 is not equal to zero, so it loops.
Then 254, etc.

I'll try...

Code:
HATLOOP:

STA \$03A0, X
DEX
BNE HATLOOP

On this part of code, as you did say it's exactly as it's exampled, it just colored it all in, but I am not sure how BNE is useful when I want to make a line in the middle of the number of the code instead from any number to zero. And I'm not sure how to write it in a way it can go vertically [up and down] instead of always left and right.

-

Is there any history or motivation about programming and 6502 beside the one posted before this? I want to force myself to be encouraged, but I keep feeling it's just myself, and it's not other stuff..

Top

 Post subject: Re: Hello, new here, and need best recommandations.Posted: Thu Sep 27, 2018 8:48 pm

Joined: Sat Feb 12, 2005 9:43 pm
Posts: 11297
Location: Rio de Janeiro - Brazil
DocWaluigean wrote:
And I'm not sure how to write it in a way it can go vertically [up and down] instead of always left and right.

Drawing horizontally is easier because the screen is arranged in rows, so adding one goes one pixel to the right, subtracting one goes one pixel to the left. To move up and down, you need to skip an entire row. Each row is 32 pixels, so you need to add (to go down) or subtract (to go up) 32 to/from the current position in order to move vertically.

What makes this slightly more complicated is that the entire screen doesn't fit in 256 bytes (it's actually 1024 bytes), so you can't go everywhere using just one 8-bit index register (X or Y) as you can with horizontal lines.

The best way to do this would be to use indirect indexed addressing, but I'm not sure if you learned that yet. The basic idea is that the address to access is not in the instruction, it's in the memory location indicated by the instruction. That's why it's called "indirect". LDA \$0050, Y will load a byte from the address \$0050+y, while LDA (\$50), Y will load a byte from the address formed by the numbers at \$0050 and \$0051, plus Y (e.g. if \$0050 contains \$07, \$0051 contains \$90, and Y contains \$04, LDA (\$50), Y will read the byte at \$9007 + \$04 = \$900B).

I'm not gonna show any code for drawing vertical lines because it might not be time for that yet, but keep in mind that it is somewhat more complex and will most likely require the new addressing mode I mentioned before (indirect indexed). It might be a good idea to make a subroutine to draw lines too, to encapsulate that complexity so that the code that does the drawing can remain simple, just making calls to this subroutine whenever a line is needed.

Top

 Post subject: Re: Hello, new here, and need best recommandations.Posted: Fri Sep 28, 2018 3:06 am

Joined: Wed Apr 02, 2008 2:09 pm
Posts: 1283
Quote:
as you did say it's exactly as it's exampled,

Except for the ldx #\$1F above it. Like I said, you did not initialize X above the HATLOOP label.

Compare:
Code:
LDA #\$04
LDX #\$1F

TOPHAT1:
STA \$0200, X
DEX
BNE TOPHAT1

to
Code:
HATLOOP:

STA \$03A0, X
DEX
BNE HATLOOP

At the TOPHAT1 label, X is #\$1F, so it draws 31 pixels.
At the HATLOOP label, X is #\$00 (because it never changes after BNE TOPHAT1 doesn't branch), so it loops 256 times.

To fix it, add an ldx #\$1F above the HATLOOP label.

Quote:
I am not sure how BNE is useful when I want to make a line in the middle of the number of the code instead from any number to zero.

Use an address that's the middle of a line. If X is 0, you get the given address. The given address doesn't have to be at the start of a line.
2 pixels starting from the top left corner:
Code:
LDA #\$04;Color
LDX #\$02;2 pixels

loop:
STA \$0200, X
DEX
BNE loop
STA \$0200;Do the last pixel

2 pixels starting from three pixels to the right of the top left corner.
Code:
LDA #\$04;Color
LDX #\$02;2 pixels

loop:
STA \$0203, X
DEX
BNE loop
STA \$0203;Do the last pixel

Tokumaru covered why vertical is trickier. This is why I assigned only horizontal lines since you don't yet have those concepts.
Quote:
I want to force myself to be encouraged

I may have said this before, but I feel like that's a backwards way to go about motivation. If you don't already have something that motivates you to learn, why are you learning it? Learning 6502 isn't the difference between getting a degree or not, or something like that. If what you want to use it for isn't motivating enough, you can stop or take a break or anything else. There are no consequences for stopping.

I only understand forcing motivation if it's to do something you don't want to do AND there are consequences for not doing it. Here you're no worse off if you stop for a day, for a week or forever.

Edit: If you learn the things vertical lines will require, you can actually start making a pixel "character" move around. But I make no commitment to teaching those things, I am still here because I felt it'd be pretty bad to not check the last assignment after the deadline.

_________________
https://kasumi.itch.io/indivisible

Top

 Post subject: Re: Hello, new here, and need best recommandations.Posted: Sun Sep 30, 2018 6:20 pm

Joined: Sun Jun 17, 2018 6:41 pm
Posts: 155
Kasumi wrote:
Quote:
as you did say it's exactly as it's exampled,

Except for the ldx #\$1F above it. Like I said, you did not initialize X above the HATLOOP label.

Compare:
Code:
LDA #\$04
LDX #\$1F

TOPHAT1:
STA \$0200, X
DEX
BNE TOPHAT1

to
Code:
HATLOOP:

STA \$03A0, X
DEX
BNE HATLOOP

At the TOPHAT1 label, X is #\$1F, so it draws 31 pixels.
At the HATLOOP label, X is #\$00 (because it never changes after BNE TOPHAT1 doesn't branch), so it loops 256 times.

To fix it, add an ldx #\$1F above the HATLOOP label.

Quote:
I am not sure how BNE is useful when I want to make a line in the middle of the number of the code instead from any number to zero.

Use an address that's the middle of a line. If X is 0, you get the given address. The given address doesn't have to be at the start of a line.
2 pixels starting from the top left corner:
Code:
LDA #\$04;Color
LDX #\$02;2 pixels

loop:
STA \$0200, X
DEX
BNE loop
STA \$0200;Do the last pixel

2 pixels starting from three pixels to the right of the top left corner.
Code:
LDA #\$04;Color
LDX #\$02;2 pixels

loop:
STA \$0203, X
DEX
BNE loop
STA \$0203;Do the last pixel

Tokumaru covered why vertical is trickier. This is why I assigned only horizontal lines since you don't yet have those concepts.
Quote:
I want to force myself to be encouraged

I may have said this before, but I feel like that's a backwards way to go about motivation. If you don't already have something that motivates you to learn, why are you learning it? Learning 6502 isn't the difference between getting a degree or not, or something like that. If what you want to use it for isn't motivating enough, you can stop or take a break or anything else. There are no consequences for stopping.

I only understand forcing motivation if it's to do something you don't want to do AND there are consequences for not doing it. Here you're no worse off if you stop for a day, for a week or forever.

Edit: If you learn the things vertical lines will require, you can actually start making a pixel "character" move around. But I make no commitment to teaching those things, I am still here because I felt it'd be pretty bad to not check the last assignment after the deadline.

I'm not sure what you mean about motivation if I think way too hard.

I'm learning it because why not? I said before that when I saw DahrkDaiz, when I saw Shiru, then I saw NIKI homebrews about NES, along with NESMaker which I still can't do atm, it's a form of childhood reasons why I am still trying to learn; can't explain why I want to learn, but something in heart [originated from childhood] knows why I REALLY want to learn. Looking at DSi games like WarioWare: D.I.Y. graphics kind of helps me, then I remember about the lessons, which I still feel iffy about it.

After this lesson, can we learn about how to turn program on from scratch with blank screen before we can go on to the next lesson? I don't want to feel like I'm learning only by reading, and then I feel I didn't code at all. I re-read about branching yesterday, and I understand way more, as I'm believing Unregistered was right.

So my question on the lecture:

-Do I ALWAYS have to put LDX #\$## at the start of each? or Each label always reset if outside of the labels or the BME/BDA labels stuff?

[I'm re-reading this lesson, as it takes time a little since I keep getting different result like the code I show earlier.]

Top

 Post subject: Re: Hello, new here, and need best recommandations.Posted: Sun Sep 30, 2018 7:33 pm

Joined: Tue Jun 24, 2008 8:38 pm
Posts: 2275
Location: Fukuoka, Japan
@DocWaluigean

If your goal is to make a nes game only then you don't need to write code in asm: you can write it in C too. This is a lot easier to write actually.

Even though I understand enough 6502 asm, I write my code in C and asm based on my need. For experimenting with the nes, you don't need asm, C is more than enough. Since you mention Shiru, most of his game were in C too so it's possible to write C only code and only write ASM when there is no other way.

So if you goal is only making game, asm is not required. Just my opinion, the rest is up to you. It will make you life a lot easier.

Top

 Post subject: Re: Hello, new here, and need best recommandations.Posted: Sun Sep 30, 2018 7:55 pm

Joined: Sun Jun 17, 2018 6:41 pm
Posts: 155
Banshaku wrote:
@DocWaluigean

If your goal is to make a nes game only then you don't need to write code in asm: you can write it in C too. This is a lot easier to write actually.

Even though I understand enough 6502 asm, I write my code in C and asm based on my need. For experimenting with the nes, you don't need asm, C is more than enough. Since you mention Shiru, most of his game were in C too so it's possible to write C only code and only write ASM when there is no other way.

So if you goal is only making game, asm is not required. Just my opinion, the rest is up to you. It will make you life a lot easier.

Since I'm complex to understand or explain [If you weren't reading the whole thread], I'll try to explain this:

When I see more what I could do with 6502 Assembly, I admire and value the code more and more as time progresses. If I change my learning desires, I would feel terrible losing my knowledge or wasting my skills from 6502 to C. I believe you when C is easier; there's C++, there's C# which is hybrid of Java, and the C code is often the answer for everyone who want's to, BY BASE, get started on learning to code. But for 6502, there aren't many good tutorials or really effective tutorials for people who is "down-to-earth" determined to try and pay attention and know how it works. [At least for me.]

What I see for 6502, that language is much more than a toy. Much more than Minecraft if on hypnosis attitude [Or like Steve Jobs when he stare at program and see extreme potentials.]
On usual random days of taking breaks, I see JP homebrews utilizing NES not just for games, but also for image slideshow, for music, for other things. Maybe I'm wrong because I haven't see image slideshows, but maybe I'm right if I saw the music-only programs made by NIKI/NIKKI.

Or I'm being delusional. Again. By saying the same thing earlier. But to the point:

I would feel waste of time if I go to C/C++/C#, and 6502 is one of the least elementary-documented popular languages for homebrews, [at least for me], and I want to help out in any way to make it understand not just for me, but for all. If I want to learn C, I want to learn 6502 first to understand comparison. Alongside, I understand enough that it's too late for me to go back. Register, Program Counter, etc.

I don't know why I feel avoidances on this assignment... Going to try and re-read it the third time. If I finally understood the Branching, I could finally understand this. I said earlier I don't want anyone going through what I've been through..

Top

 Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending
 Page 19 of 24 [ 354 posts ] Go to page Previous  1 ... 16, 17, 18, 19, 20, 21, 22 ... 24  Next

 All times are UTC - 7 hours

#### Who is online

Users browsing this forum: Nicole and 2 guests

 You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum

Search for:
 Jump to:  Select a forum ------------------ NES / Famicom    NESdev    NESemdev    NES Graphics    NES Music    Homebrew Projects       2018 NESdev Competition       2017 NESdev Competition       2016 NESdev Competition       2014 NESdev Competition       2011 NESdev Competition    Newbie Help Center    NES Hardware and Flash Equipment       Reproduction    NESdev International       FCdev       NESdev China       NESdev Middle East Other    General Stuff    Membler Industries    Other Retro Dev       SNESdev       GBDev    Test Forum Site Issues    phpBB Issues    Web Issues    nesdevWiki