# Skeetendo

’Cause all games were better on the GBC

You are not logged in.

## #1 2011-07-10 05:09:14

Miksy91
Member
Registered: 2010-10-16
Post 470/2,348

### ASM School

I think this site should be linked here.
I found it extremely useful and happened to find it by accident of Sawakita's Rby hacking document.

http://gameboy.mongenel.com/asmschool.html

Last edited by Miksy91 (2011-07-10 05:10:14)

Offline

## #2 2011-07-10 11:20:19

Sawakita
Registered: 2010-10-16
Post 158/366

### Re: ASM School

kkj1116 wrote:

Could you explain a little about what the AND, OR, and XOR instructions do (in Lesson 2)?

Those are bit-wise operations.

AND: Takes only the set bits that the two bytes have in common, reset all other bits.

``````Example:
\$F4 AND \$63
=
%11110100 AND
%01100011  =
------------------
%01100000  =  \$60``````

OR: Resets only the zero-bits that the two bytes have in common, sets all other bits.

``````Example:
\$F4 OR \$63
=
%11110100 OR
%01100011  =
------------------
%11110111  =  \$F7``````

XOR (eXclusive OR): Resets  the set bits that the two bytes have in common; takes, unchanged, the other bits.

``````Example:
\$F4 XOR \$63
=
%11110100 XOR
%01100011  =
------------------
%10010111  =  \$97``````

Offline

## #3 2011-07-10 14:01:51

Miksy91
Member
Registered: 2010-10-16
Post 472/2,348

### Re: ASM School

If you know mathematical logic, those terms shouldn't be that hard to be understood (AND and OR are introduced in it).

Offline

## #4 2011-07-11 00:30:55

238/704

### Re: ASM School

And/or/xor are easy to remember if you realize what the names mean.

A and B: if A and B are 1, then the result is 1. Else the result is 0.
A or B: if A or B (or both) are 1, then the result is 1. Else the result is 0.
A xor B: if A or B (but not both; they’re mutually exclusive), then the result is 1. Else the result is 0.

Miksy91 wrote:

If you know mathematical logic, those terms shouldn't be that hard to be understood (AND and OR are introduced in it).

Specifically, Boolean logic.

## #5 2011-08-05 11:44:35

Sawakita
Registered: 2010-10-16
Post 174/366

### Re: ASM School

I'll put my two cents: I didn't know C when I learned ASM; even now I only have basic knowledge of C/C++, but am pretty fluent in ASM. So, I don't think it's a fundamental requirement.

Offline

## #6 2011-08-06 04:01:44

258/704

### Re: ASM School

I attempted to learn C when I was younger, but didn’t understand it, and thus never got anywhere.

Then I taught myself Game Boy assembly, which made a lot of sense because it is at a lower level.

After that, learning C was a breeze. In particular, I noticed many of the design choices of C were made due to the problems with assembly.

## #7 2011-08-12 13:40:37

262/704

### Re: ASM School

Say you have a hexadecimal number like 0x5A. In binary, the same number looks like 01011010.

So say your carry contains 1, and register a contains 0x5A. When you do “rla a”, the leftmost bit of a (0) goes to the carry, the carry (1) becomes the rightmost bit of a, and everything else is shifted to the left one place. So at the end, the carry is 0 and a contains 10110101 (0xB5).

## #8 2011-08-12 15:10:12

visionseeming
New member
Registered: 2011-07-19
Post 2/7

### Re: ASM School

kkj1116 wrote:

I did not know I needed to know mathematical logic/boolean logic to tackle ASM.......
I have seen somewhere that one should learn C before tackling ASM.
Should one really learn C before tackling ASM?
(If yes, I think OP should add "Suggested: C Programming Language before trying ASM")

Knowing C or any other procedurally oriented language helps since to do anything complicated in assembly you will be spitting the code into various routines/procedures/functions to allow code reuse and to simplify things with the modular approach--the "black box" approach.  One thing I think you should know before learning assembly, though this might just be my electrical engineering background kicking in, is some basic "how does a CPU work" knowledge.  Since you are working right at the hardware level with ASM, knowing what the hardware is and/or how it works at a basic level(e.g. what are instructions, registers, and what is a CPU and what does it do with these).

FWIW, I'm also going through the GB Programmers Manual and trying to learn GB ASM as well.  The first few chapters are dedicated to the hardware and what it does so I would think that whoever compiled that document figured it is important too.

"To some people, Pokemon hacks are just games. Others use them for battling/trading. Us? We study the hacks like a profession. But we don't know everything yet. There are still many mysteries left to be solved. That's why we hack Pokemon every day."--Mateo

Offline

## #9 2011-08-13 13:13:38

Sawakita
Registered: 2010-10-16
Post 178/366

### Re: ASM School

Obviously, ASM knowledge is pretty useless without hardware's architecture knowledge.

Offline

## #10 2012-12-15 06:18:08

rick-fle
New member
Registered: 2012-12-15
Post 1/1

### Re: ASM School

Thanks

Last edited by rick-fle (2012-12-15 06:23:26)

Offline

## #11 2013-10-20 10:47:19

Airikita
Member
Registered: 2013-10-16
Post 18/41

### Re: ASM School

Ew, you guys are making my head hurt... it's way easier to look at it in the debugger and figure things out:
http://youtu.be/y8zbuw-dmqg
7/15 shiny rate by removing JR's, AND bit 8, and change the last JR NZ to a JR Z, because anything lower than 08 will thus be excluded... by AND-ing bit 8, that means I will only accept values with the 4th bit in: 1000(bit)

That means 8,9,A,B,C,D,E, and F are accepted. Then JR Z will skip the SCF that makes Pokemon shiney when the value is less.

If you choose 0x04 to and with, you will get: 04, 05, 06, 07, 0C, 0D, 0E, and 0F, which will give a 8/15 rate. Any other value other than 01, 02, 04, or 08 will increase the odds. 0F would just make all Pokemon shiny.

You can probably change the rate other ways, perhaps by nop-ing out both ANDs, and making it AND different 8-bit combinations. Possibly the simplest way to increase shinies more.

PRO TIP: don't over-complicate ASM, as it is usually simpler to do... changing the code is not a bad idea, but it's messy... it helps to know programming first, and binary/hex math especially.

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

EDIT:
My next change was to AND A,80 | JR Z, 5070, and then AND A,08 | JR Z, 5070. This makes two checks, increasing the odds squared... this makes my odds of finding a shiny 7/225, a lower rate than before.

EDIT2:
Here's a better video showing the concept of the code, simplified to work with a 7.5/225 rate: