You are browsing as a guest. Sign up (or log in) to start making projects!

Rust 6502

  • 63 Devlogs
  • 74 Total hours

A MOS-6502 Emulator written in Rust, and with a custom TUI !

Ship #3

Rust 6502

A MOS 6502 emulator TUI with a lot of features

Before reading this Ship you should take a look at Ship 1 & Ship 2

What did you add ?

Here is a list of everything that I have added since the last Ship

Features

  • Breakpoints : press “F” to set a breakpoint at any address, the emulator halts the moment PC reaches it

  • Watchpoints : same idea, but for memory

  • Conditional Breakpoints : halt execution when a register (AC, XR, YR, SP) meets a comparison (!=, ==, >=, <=, >, <) against a target value

  • Step Back : press “B” to rewind execution one instruction at a time, restoring the CPU and memory exactly as they were before

  • Random Number Generator : a memory-mapped register at $BFF3 that returns a random byte from the host PC on every read, so ASM programs can have real random number

  • Keybind Panel : a popup listing every keyboard shortcut and control, and removed the old footer keybind list to make room for it

Demo Program

  • Snake : updated to pull apple placement from the new RNG instead of the old pseudo random method

ദ്ദി(˵ •̀ ᴗ - ˵ ) ✧

What was challenging ?

Wiring the conditional breakpoint into the run loop without breaking the existing breakpoint/watchpoint checks was harder than I though. Also getting a dropdown-style menu to choose the operator working in Ratatui was tought since there’s no native dropdown widget. So I ended up building a little spinner (▲ value ▼) that cycles through the operators instead ദ്ദി(˵ •̀ ᴗ - ˵ ) ✧

What are you proud of ?

I’m proud that my emulator now has real debugging tools like : breakpoints, watchpoints, conditional breakpoints, and step-back.

What should people know so they can test your project ?

A Nerd Font is recommended in your terminal for a better rendering of the UI icons on the Home page

How to test:

  • Install the emulator directly from crates.io by running:
cargo install rust6502
  • Download all the .bin files on the GitHub Releases page.
  • Launch the emulator by running rust6502 and use the built-in Home menu to select one of the demo .bin files!

Things to try

  • Load snake_demo.bin and play :D

  • Set a breakpoint on an address inside a demo program (check the keybind panel for the shortcut!) and watch execution halt exactly there

  • Try a conditional breakpoint : for example, halt whenever XR == 0F and watch it stop right when the register hits that value

  • Press “B” to step backward and rewind the CPU state instruction by instruction

  • Press the keybind panel shortcut to see the full list of controls

  • 6 devlogs
  • 7h
  • 18.98x multiplier
  • 127 Stardust
Try project → See source code →
Open comments for this post

1h 19m 23s logged

+1h20 :yesyes: So… this might be the last devlog for this project. I just released the v1.3.0. And here is what I added since the last devlog :

  • A RNG documentation
  • Snake now use a real RNG
  • I recorded the Asciinema .cast file
  • Update the python tools to generate memory diagrams
  • Update the Memory documentation

So next step is the 3rd Ship :yay: :yesyesyes:

0
0
42
Open comments for this post

1h 37m 58s logged

+ 1h35 :yay: ! This might be the last feature I add to Rust 6502. Since I ran out of idea and for me the project seem to be finished.

Anyway, here are the things I added :

  • A RNG address : $BFF3. The program just read from it and get a random value via the Host computer (4feb4d8)
  • A conditional breakpoint : A top bar in the Breakpoint popup to add a conditional breakpoint (like : If AC != 0F -> Break) (1b7bc81)
3
0
44
Open comments for this post

1h 24m 50s logged

+1h 25 min ! Since the last time I have added the keybind panel. Where there is… all the keybinds :yay:
I also remove the keybind on the footer to only get Keybind “K”

0
0
13
Super Star

As a prize for your great work, look out for a bonus prize in the mail :)

Open comments for this post

51m 57s logged

Okay so… I have added the Breakpoint and the Watchpoint :yay: . When you set the breakpoint to $C00C the CPU will stop before running the instruction at $C00C. The watchpoint stop if a value at an address at been changed.

0
0
38
Open comments for this post

51m 13s logged

I added the step-back function. It work by pressing “B”, it’s just rewinding the emulator up to 500 opcode. Only work when moving in step-by-step mode (with Enter)

0
0
13
Ship #2

=== Rust 6502 ===

A MOS 6502 emulator TUI with a lot of features

============================================
Before reading this Ship you should take a look at Ship #1

== What did you add ? ==

Here is a list of everything that I have added since the last Ship

= Features =

  • Serial Monitor : you connect to localhost:8080 using netcat. Useful for the Apple 1 OS or for debugging with text. The monitor can be used to display text but also to send text like a keyboard (useful for the Apple 1 OS)
  • PS/2 Keyboard : a full PS/2 keyboard emulation (used in Snake)
  • Use the UI with a Mouse: On the Home Menu and in the Emulator you can click on button, toggle, scroll, etc…
  • Interrupt : IRQ & NMI
  • Tips in the Settings Panel
  • Modify speed with Hz & MHz (like a real 6502 chip)
  • Reset Vector: The emulator will look at $FFFC & $FFFD to find the start address of the program (when the Force Address toggle is off)
  • Set PC Address: keyboard shortcut to change the position of the PC (Program Counter)

= Demo Program =

  • Apple 1 OS (Wozmon) : I have modified the orginal Apple 1 code to fit my emulator, like Serial Monitor address, Keyboard etc…
  • Snake : Just the Snake game ദ്ദി(˵ •̀ ᴗ - ˵ ) ✧
  • Keyboard Demo: Print every key press on the screen using a custom font
  • Serial Monitor Demo: Show how the Serial Monitor works

== What was challenging ? ==

The most challenging part of this 2nd ship was creating a Serial Monitor that works via a local port, and making a PS/2 Keyboard emulation.

And of course, modifying the Apple 1 OS to make it work on this emulator ! (I was having a lot of bugs, so I rewrite a big part of the OS) ദ്ദി(˵ •̀ ᴗ - ˵ ) ✧

== What are you proud of ? ==

I am really proud of my self for the implementation of the Serial monitor that run on different CPU thread than the emulator itself and the fact that it work via the local network.

And beyond everything the fact that my emulator can run : games, utility and the Apple 1 OS !!! ദ്ദി(˵ •̀ ᴗ - ˵ ) ✧

I’m also really proud that it’s officially published on crates.io.
== What should people know so they can test your project ? ==

Note: A Nerd Font is recommended in your terminal emulator for a proper rendering of the UI icons on the Home page

How to test:

  • Install the emulator directly from crates.io by running:

    ==================
    cargo install rust6502

  • Download all the .bin files on the GitHub Releases page.

  • Launch the emulator by running rust6502 and use the built-in Home menu to select one of the demo .bin files!

== Things to try ==

  • Load snake_demo.bin to play at a classic game using the 32x32 screen and the PS/2 keyboard emulation

  • Load wozmon.bin to use the Apple 1 OS ! You should see the documentation related to Wozmon : https://github.com/wirenux/Rust-6502/blob/main/AppleI.md

  • Load keyboard_demo.bin to see every key you press show up on the 32x32 screen using a custom font

  • The Debugger: go to the Settings menu inside the TUI and slow down the CPU speed. Then watch the Memory Viewer and Disassembler track exactly what the code is doing in real-time!

  • 13 devlogs
  • 28h
  • 17.86x multiplier
  • 504 Stardust
Try project → See source code →
Open comments for this post

2h 49m 1s logged

Here is what I have done in 2h 50 :aftonsparv: . First I wrote a lot of docs, for the keyboard, Serial Monitor, Wozmon etc… This was so boring :heavysob: . But at least now I will be ready to ship soon ! :yay: Second, I have fixed the Wozmon list content of address. Before when you was doing FF00.FFFF it was just showing the byte at $FF00 and the byte at $FFFF now it list all the byte between !

0
0
10
Open comments for this post

37m 9s logged

Little update, I added a Program Counter (PC) input to move it in when running a program. I also added a cursor for the start input on the Home Screen ! :blabla:

0
0
7
Open comments for this post

1h 54m 16s logged

After 1h50 :aftonsparv: I have added a Snake demo program that use the PS/2 keyboard !!! :ms-snake: I also make a demo program to test the Serial Monitor using netcat nc

0
0
4
Open comments for this post

3h 34m 11s logged

Wow, just WOW. I have added a serial monitor, and Apple 1 OS :wowsers:

Serial Monitor

Here is the way the monitor work, you load character to $BFE0 like this :

lda #'A'
sta $BFE0

Then you run the program in the emulator like normal, then you open another terminal and you connect to localhost port 8080 using netcat nc :cat-comfy: like this :

nc 127.0.0.1 8080

And now if you already launch the program, when you connect to localhost (127.0.0.1 is localhost) you will see a A in your terminal !

You can also type in the serial monitor ! Here is a code that show the number of characters typed by using the pixels in the 32x32 screen !

start:
    ldx #$FF
    txs
    ldx #$00

main_loop:
    bit $BFE1
    bpl main_loop


    lda $BFE0

    sta $BFE0

    
    lda #WHITE_COLOR
    sta $0200, x

    inx
    jmp main_loop

Apple 1 :apple-logo:

This is a very damn big part.

To be short, I have recreated the Apple 1 OS (Wozmon) created by Steve Wozniak. In short I took the code given in the Apple 1 User Manual, modify it to use the Serial Monitor and Keyboard, fix some issue with the prompt. I can even run the classic program from the manual to print all the available characters.

With Wozmon you can also write and read data from the memory so you can show some pixel on the screen !

Here is the program running and the serial monitor.

0
0
20
Open comments for this post

4h 40m 9s logged

Okay soo….. it’s been 4 hours and 35 minutes :wtf-is-going-on-down-there: . I have done so much and not that much at the same time (I know it’s weird :wtf: ) I have added a demo program who print the pressed character ! I have spend 2 hours on a little bug :heavy-fart: but yeah now it’s working ! So with the program I drew all the key on a PS/2 keyboard :ps2hagrid: . I also fixed some little inattention problem in my code.

I also created a little python script to help me convert .png drawing into raw .inc value ! :python:

( Did you find the secret phrase ?)

0
0
8
Open comments for this post

36m 3s logged

I want to create a ASM program who print the pressed key to the screen, and for that I need to create the font/image for each key. There is ~100 key :bruhwazowski: . So here is the first one ! :yay:

0
0
10
Open comments for this post

2h 13m 44s logged

Wow that was… difficult :bad_laptop: . But now there is a PS/2 :ps2hagrid: keyboard Emulation :keyboard-fire: ! :yay:

The I/O port is map on $BFF0-$BBF2. The PS/2 keyboard work with 3 addresses

  • $BFF0 : KBD_DATA
  • $BFF1 : KBD_STATUS
  • $BFF2 : KBD_ACK

To activate to keyboard in the emulator you can press on the screen container and to exit it just click anywhere else !

(The number you can see in the memory viewer at $0000 is the code from different key !)

Maybe next time I will create a program to see each letter

0
0
5
Open comments for this post

1h 28m 29s logged

YAY :yay: ! Now there is :click-sparkle: mouse control on the home screen, this mean that you can click every where to change the focus and in the file explorer you can double-click to open a folder and double-click to open a file directly, you can also with a simple click enable or disable Force Address Mode

0
0
6
Open comments for this post

8h 40m 12s logged

Ok so… it’s been 8h40 :hdheavysob: .
I have done a lot (I mean it’s logic it’s been 8h and 40 minutes)
In time order I have done :

  • Replace self.pc + 1 to self.pc.wrapping_add(1) so it’s like on the real 6502 if the current PC is $FFFF and you add 1 it will be $0000.

  • Added a panic hook, before when the program was crashing (for a bad ASM program by example) the terminal was still in RAW mode (so if you click, move the mouse etc… it will print a bunch of garbage number) but now it exit the raw mode in a clean way !

  • Remove unused import

  • Change the start of the Stack Pointer to $1FFF

  • Added a memory reset function

  • Write a bunch of test programs :yay:

  • Replace IPS (instruction per seconds) by Hz and MHz like in real life :yeah: (so i’ve adapted the UI for the change)

  • Now the disassembler disassemble the whole program (neat right ? :lol_emoticon: ) using .len(). (yes before it was an hard-coded number :hdheavysob:

  • Optimize the screen render method. Before I was refreshing the screen even if nothings has been changed, now i check if somethings have been changed to update the screen :cool-pony:

  • Added address of each “quarter” of the screen in the screen documentation :neon-matrix:

  • Fixed foreground and background color of the Frequency selector (on the Home Screen)

  • Write a program to test IRQ and NMI

  • Keybinds the I and N key to IRQ and NMI :stop:

  • Changed the Hello World program to be rainbow :rainbow-honakana:

  • The emulator will look by it self to the reset vector ($FFFC and $FFFD) to set the PC at the correct address

  • Added a force address toggle to… force the the start address

  • When the force addr toggle is off you can’t modify the start Addr and it’s darker

  • Every file or folder who start by a . (dot) is not shown in the file selector :hide:

  • Moved the hackclub logo raw binary data to a .inc file :idk:

  • Added a self crashing test program :boom-spin:

(Next time I might add a PS/2 keyboard emulation… :shhhhh: )

0
0
14
Ship #1

=== Rust 6502 ===

A legendary 8-bit CPU right in your terminal! 🦀 ᕙ( •̀ ᗜ •́ )ᕗ

== What did you make ? ==

I built a fully functional emulator for the MOS 6502 (the microprocessor that powered the Apple II, Commodre 64, and the NES) from scratch using Rust !
Instead of a standard graphical window, I built a Terminal User Interface (TUI) using Ratatui.

Here is what’s inside:

  • Full CPU Emulation: Execute 6502 machine code with live register (AC, XR, YR, SP) and status flag tracking
  • Virtual Screen: A 32x32 memory-mapped display ($0200-$05FF) rendered right in the terminal using Unicode Half-Block and a custom 16-color palette
  • Live Disassembler & Hex Viewer: Watch the RAM change in real-time and see the raw binary machine code translated back into readable assembly instructions on the fly
  • Built-in File Browser: A visual menu with Nerd Font icons to navigate your system and load compiled .bin ROMs
  • Available on crates.io : You can download it via Cargo

== What was challenging ? ==

  • The Disassembler: Writing a disassembler that parses raw .bin files is tricky because they don’t have headers. I ran into a massive issue where my image data (using the color byte $0A) was being read by the disassembler as infinite ASL A (Shift Left) instructions! I had to engineer a way for the disassembler to properly halt when it hit a BRK instruction so it wouldn’t try to execute my pixel art.

  • Terminal UI Architecture: Designing a dashboard (hex grids, scrolling stacks, changing colors) required a really solid state-management architecture to keep the UI smooth and responsive while the CPU loop spins at thousands of instructions per second.

== What are you proud of ? ==

I am proud of using this project to learn Rust in a fun way!

ദ്ദി(˵ •̀ ᴗ - ˵ ) ✧

I’m also really proud that it’s officially published on crates.io, meaning anyone can install and run my emulator with a single command

== What should people know so they can test your project ? ==

Note: A Nerd Font is recommended in your terminal emulator for a proper rendering of the UI icons on the Home page

How to test:

  • Install the emulator directly from crates.io by running:
    cargo install rust6502

  • Download all the .bin files on the GitHub Releases page.

  • Launch the emulator by running rust6502 and use the built-in Home menu to select one of the demo .bin files!

== Things to try ==

  • Load hackclub_logo_demo.bin to see the terminal render a 32x32 pixel art logo using 6502 assembly

  • Load rainbow_demo.bin to watch a shifting color gradient animation directly manipulating video memory.

  • Load helloworld_demo.bin to watch a centered Hello world message

  • The Debugger: go to the Settings menu inside the TUI and slow down the CPU speed. Then watch the Memory Viewer and Disassembler track exactly what the code is doing in real-time!

  • 44 devlogs
  • 39h
  • 19.83x multiplier
  • 723 Stardust
Try project → See source code →
Open comments for this post

17m 5s logged

Last devlogs before Ship #1 :yay:
Wow 37h of work.

I have made an Asciinema video, Youtube video and update the README.md

Wish me luck !

0
0
14
Open comments for this post

48m 52s logged

I have added a new program called HackClub Logo :yay:
First, I have draw the hackclub logo in aseprite with a 32x32 pixel file using my custom color palette.

Second, I have created a simple python script who take a .png in input and output ASM raw data for the image (using my color palette).

Third, I have create a simple ASM program to print the logo on the screen !

0
0
19
Open comments for this post

3h 53m 12s logged

WOW 4h 😅
I have done the full README.md, documentation about the screen, color palette and fix some little bugs.

0
0
7
Open comments for this post

36m 37s logged

Little bug fix: Now when we select a file in the Home File Selector the filename appear in the Opcode container.
I have also reorganize the tui.rs code !

0
0
9
Open comments for this post

22m 11s logged

WOW already 30 hours ?! 😅
I now have added the home logo ! I also changed the step for the speed selection on Home Menu from 500 to 100 for each step

0
0
8
Open comments for this post

2h 5m 26s logged

Wow that was damn hard 😭. But the Home Menu is finally here 🎉. There is the logo (might change). The select file container with full navigation (folder, parent directory, file), Icon (require a Nerd Font) and Colors. The selected file path update in real time with the absolute path of the file. The start address automatically change if the file selected is a demo file (end with “_demo.bin”) to $C000. The start address it editable with Alpha numeric character (hexadecimal). And the emulation speed work ! There is control on the footer bar.

0
0
4
Open comments for this post

1h 14m 9s logged

New demo program… HelloWorld_demo !
Print Hello World ! centered on the screen all in pure 6502 Assembly. I also modified the way the disassembler work, now even if there is a BRK it will continue to read the file until the end. The ASM part was really really haaarrddd.

0
0
103
Open comments for this post

33m 14s logged

I have update the color from word to RGB value so if a different terminal theme is applied the color are the same. I also added a footer bar with the keybinds.

0
0
5
Open comments for this post

1h 24m 59s logged

New panel 🥁🥁🥁…. the ✨ SETTINGS ✨ !
In this panel there is a smaller version of the Logo and the settings to modify the speed of the CPU. There is also the link to the github repo and stardance project

0
0
3
Open comments for this post

17m 9s logged

Now the name of the file currently running is in the title. I also finished the rainbow program to fill the whole screen.

0
0
3
Open comments for this post

1h 42m 57s logged

New feature 🥁🥁🥁 ✨ THE SCREEN ✨ This was very very hard. The screen use the Unicode half-block character “▀”, to write to the screen you just need to send value like this :

LDA #$02      ; load "02" into the accumulator
STA $0200     ; store it at memory address $0200 (the 1st pixel)

Here the 02 is the color RED.
Here is the color palette:

fn palette_color(index: u8) -> Color {
    match index & 0x0F {
        0 => Color::Black,
        1 => Color::White,
        2 => Color::Red,
        3 => Color::Cyan,
        4 => Color::Magenta,
        5 => Color::Green,
        6 => Color::Blue,
        7 => Color::Yellow,
        8 => Color::Rgb(255, 165, 0), // Orange
        9 => Color::Rgb(153, 76, 0), // Brown
        10 => Color::DarkGray,
        11 => Color::Gray,
        12 => Color::LightRed,
        13 => Color::LightBlue,
        14 => Color::LightGreen,
        _ => Color::Reset, // 15 transparent
    }
}

The color may vary between terminal theme.

I also had created an ASM program to print a rainbow on the 1st quarter of the screen.

I also added the feature that when a BRK instruction is hit the program turn to HALT mode (in the UI).

I also added the indentation system to BEQ, BNE, BCC, BCS, BMI, BPL, BVC, BVS.

I also added a new way of calculating the speed of the program.

0
0
4
Open comments for this post

25m 6s logged

Choosing between a variety of logo (2 first screen shot are in Apple Terminal the last is in ghostty with a Catpuccin Mocha theme)

0
0
30
Open comments for this post

55m 18s logged

I have added a top bar in the memory container with the last part of the address (to be more easy to read).

I also fixed all the scroll bar from scrolling outside the container and just see nothings

0
0
10
Open comments for this post

22m 51s logged

I have fixed the cursor in the Stack Container to scroll automaticly when needed and when running. I also optimised the code !

0
0
5
Open comments for this post

1h 5m 59s logged

A lot has been going on :yay: ! I have added the Memory Viewer, Scroll bar to the Stack Viewer and Memory Viewer (work with the 🥁…. SCROLL WHEEL !). I also reduce the space taken by the opcode list so we can see the memory viewer !

0
0
4
Open comments for this post

28m 15s logged

I have added a Stack Viewer on the left ! The container scroll it self when the “cursor”/current position of the Stack Pointer (SP). I also have fix the text for the SP in the register container

0
0
39
Open comments for this post

30m 9s logged

I have tried to implement multi-threading but realize that it’s not worth it for a simple emulator like this one.

0
0
12
Open comments for this post

1h 15m 49s logged

The UI is going forward one step after another ! :yay:

I have changed a some little like the place where is the Flag Container, now it’s on the left side.

And I also have added a LOT a things like:

  • Register Container (under the Flag Container)
  • Now when there is a JMP (or any type or jump like RST, etc…) the code indent it self
  • Up and Down key move the cursor 🥁…. ✨UP & DOWN ✨
  • New color for the ADDR in the Opcode container

Things I have removed:

  • BYTES section in the Opcode container because I don’t think it’s really useful
1
0
10
Open comments for this post

1h 6m 1s logged

I am now making the TUI part of this emulator ! I am using Ratatui to make the TUI. This mean I have to change all the printing part of my existing program

0
0
8
Open comments for this post

1h 3m 2s logged

I’m being closer and closer of getting all opcode and all Addressing mode implemented :yay:

Here are the list of opcode I have implemented and there Addressing Mode:

  • ADC
    • Zeropage X
    • Absolute
    • Absolute X
    • Absolute Y
    • Indirect X
    • Indirect Y
  • AND
    • Zeropage
    • Zeropage X
    • Absolute
    • Absolute X
    • Absolute Y
    • Indirect X
    • Indirect Y
  • CMP
    • Zeropage
    • Zeropage X
    • Absolute
    • Absolute X
    • Absolute Y
    • Indirect X
    • Indirect Y
  • EOR
    • Zeropage
    • Zeropage X
    • Absolute
    • Absolute X
    • Absolute Y
    • Indirect X
    • Indirect Y

I also fixed the CLD instruction. I was doing a :

cpu.sr |= !CPU::DECIMAL_FLAG;

but the right one was this:

cpu.sr &= !CPU::DECIMAL_FLAG;
0
0
3
Open comments for this post

56m 7s logged

New opcode time ! :yay:

  • LDY

    • ZeroPageX
  • STA

    • ZeroPageX
    • AbsoluteY
    • IndirectX
    • IndirectY
  • STX

    • ZeroPageY
    • Absolute
  • STY

    • ZeroPageX
    • Absolute
0
0
8
Open comments for this post

43m 48s logged

I’ve just passed 40min to fix an interruption problem to final look back and see that my original code what working perfectly fine 😭 . I’ve also change my build tools to ca65 + ld65

0
0
7
Open comments for this post

40m 18s logged

New opcode :pcb:

  • TXS (transfer X to stack pointer)
  • TSX (transfer stack pointer to X)
  • ldx_absolute_Y
  • lda_indirect_x
  • lda_indirect_y
  • ldx_zeropage_y

New Addressing Mode:

  • AbsoluteY
  • ZeroPageY
  • IndirectX
  • IndirectY
0
0
4
Open comments for this post

27m 49s logged

✨ NEW OPCODE ✨ :yay: :

  • PHP (Push Processor Status: push current value of all the flag to the stack)
  • PLP (Pull Processor Status: pull current value of all the flag to the stack)

But I have also add a memory dump with page (at the end of a program) to debug ! (1st screenshot) and i also add a fixed (address) memory viewer when running (2nd screenshot)

0
0
14
Open comments for this post

46m 11s logged

Now there is a pop_stack function who return the top value of the stack (Last In First Out).
I’ve also added those opcode :

  • JSR
  • RST

And made this test code :

0
0
6
Open comments for this post

1h 43m 50s logged

I’ve done a LOT of work.
Added Opcodes:

  • BEQ
  • BNE
  • SBC Immediate + Zeropage

I’ve also done a lot of refractorisation. Code before :

match opcode {
          0x18 => {
                    self.sr &= !CPU::CARRY_FLAG;                                      

                    self.set_instr(format!("{:02X}", opcode), "CLC".to_string(), 2);
          },
          // ... 
}

VS now :


match opcode {
          0x18 => self.clc(opcode),
          // ... 
}

So now every opcode have his own function !

0
0
4
Open comments for this post

31m 11s logged

I’ve added those instruction:

  • ADC (Add with Carry)
  • CLC (Clear Carry Flag)
  • SEC (Set Carry Flag)

I’ve also made this little ASM 6502 program to test those opcode

.org $8000
START:
    SEC         ; to test CLC
    LDA #$FF    ; A = 255
    CLC         ; Clear Carry Flag before addition
    ADC #$02    ; 255 + 2 = 1, Carry is now 1 (0x01FF +                   0x0002 = 0x0201)
    STA $20     ; Store Low Byte result (01) at $20
    LDA #$00    ; Load 0 for the high byte
    ADC #$00    ; 0 + 0 + 1 (Carry from previous instruction) = 1 
    STA $21     ; Store High Byte result (01) at $21
    ; SEC use
    SEC         ; Carry = 1
    LDA #$01    ; A = 1
    ADC #$00    ; 1 + 0 + 1 (Carry) = 2
    BRK

And it work just fine !

0
0
4
Open comments for this post

53m 6s logged

I’ve added a bunch of opcode like : STA, STX, STY (Zero Page, Absolute) LDX, LDY (Immediate, Zero Page, Absolute) JMP (Absolute), JMP (Indirect) (the screen shot is a new program that i’ve made and test on virtual 6502 and my project)

0
0
3
Open comments for this post

4h 18m 35s logged

Hi ! Right now in my project I have added :

  • Bus with ram

    • read & write function
    • load from file function
  • CPU

    • All registry (a, x, y, sp, pc, sr)
    • reset cpu function
    • update Z & N flag function
    • clock_tick with those opcode in it : BRK; DEY; TXA; TYA; TAY; LDA; TAX; INY; DEX; INX; NOP

(1st screenshot is official emulator 2nd is mine)

0
0
8

Delete project?

Are you sure you want to permanently delete this project? This action cannot be undone.

All devlogs, followers, and associated data will be removed.

Followers

Loading…