DEV Community

Beey
Beey

Posted on

Assembly 6502: Binary Digits

What is a binary digit in assembly 6502

A binary digit is a string of binary and binary code(if needed)

Some examples of why to use a binary digit in assembly 6502

Some common reasons to use a binary digit in assembly 6502 include:

  • Enabling PPU
  • Minimizing code size

Why not use unary?

Unary(base-1) despite being more low-level than even Binary(base-2) Has alot of cons than pros if they added it to assembly 6502

Cons of using unary

Cons:

  • Takes up alot of memory and storage and space
  • typing 256 in unary means typing 256 tally marks(1 or |)
  • Was not meant for computers to read
  • Very easy to learn but so much time wasted typing

Pros of using unary

Pros:

  • Easy to learn
  • Numbers 1 through 4 requires less typing than a hexadecimal digit

How to use the registers to use a binary digit

To make a variable in assembly 6502 that holds a binary digit, you have to create and store it into the register you want(A, X, Y) and put the binary in the variables value/content

To tell assembly its a binary digit in the contents you need to prefix it with what single numbered variable starts with after the register type declaration if you arent using $ to load a value. # and then % after the # to tell the NES its a binary value

Example of using a binary digit variable

An example of using a binary digit variable is:


.export _main

_main:

LDA #%01101 ; binary content
STA $01

Enter fullscreen mode Exit fullscreen mode

Sources

Wikipedia - unary
Wikipedia - binary

Other languages

Wikipedia - unary (spanish/español)
Wikipedia - binary (spanish/español)

Top comments (0)