Emulating a CPU in C++ #27 (6502) - Arithmetic Shift Left

  Рет қаралды 2,989

Dave Poo

Dave Poo

Күн бұрын

In this video i implement all the addressing modes for ASL "Arithmetic Shift Left" instruction, in the 6502 emulator .
Links:
Source for this project: github.com/davepoo/6502Emulator
Google Test: github.com/google/googletest
6502 Information: www.obelisk.me.uk/6502/
Music is from the Amiga version of Toki
Timestamps
0:00 ASL Description
0:50 Tidy up
1:39 ASL Accumulator test
4:25 ASL Accumulator implemented
7:16 Another ASL Accumulator test
8:58 ASL Zero Page test
11:10 ASL Zero Page implemented
14:48 Factoring code
17:36 Other addressing modes
18:27 Closing comments

Пікірлер: 6
@twobob
@twobob 3 жыл бұрын
err. Do you right click on the CMD window and then in settings you can adjust the Global COMMAND HISTORY to like 999? I seem to recall it was something like that
@rob876
@rob876 3 жыл бұрын
I'm waiting for the video where you convert the giant switch statement to a Dictionary (Hash Map)/array(?) of function pointers to turn the instruction search from O(n) to O(1). Way back when, the maximum cases in a switch statement in the Microsoft C compiler was limited to 255. If there are close to 255 instructions, an array would be ideal.
@DavePoo
@DavePoo 3 жыл бұрын
The compiler should be able to optimise that switch to O(1) as a jump table, which would be exactly the same as the array method. The array method might actually be slower as then you then have the overhead of the function call, which the compiler can do inline in the optimised switch case. A hash map lookup would be way slower than the switch or the array as you have to compute the hash then look in the bucket for the correct function to call. The opcodes could never be bigger than 255 on this CPU (because the opcodes are 8-bit), so the switch should work even way back when. So you might be waiting a while for that video, sorry.
@gshingles
@gshingles 3 жыл бұрын
@@DavePoo As you've mentioned in a couple of videos now, there is some structure or logic to assignment of the opcodes (eg all the Abs and AbsX are 9, D and E in the lo nibble) so you could try and test all of that. I don't see the point though in an emulator so it would purely be an intellectual exercise and probably doesn't gain anything. The distribution of opcodes was probably governed by what they were doing on the silicon, and doesn't seem to make 100% logical sense anyway... eg see www.masswerk.at/6502/6502_instruction_set.html
@rob876
@rob876 3 жыл бұрын
@@DavePoo Thanks for this. I had to do some catch-up learning to see how a jump table is implemented and I'm amazed by how much compilers have advanced. Way back when, we were advised never to rely on the compiler being too clever. Now that you have a 6502 emulator, would it be possible to implement the 6502 emulator in 6502 assembly language? Of course you would have to omit the tests.
@kaletaa1949
@kaletaa1949 3 жыл бұрын
interesting
Emulating a CPU in C++ #28 (6502) -  Logical Shift Right
9:43
Dave Poo
Рет қаралды 2,6 М.
WHY IS THE STACK SO FAST?
13:46
Core Dumped
Рет қаралды 121 М.
Which one will take more 😉
00:27
Polar
Рет қаралды 60 МЛН
Айттыңба - істе ! | Synyptas 3 | 7 серия
21:55
kak budto
Рет қаралды 1,4 МЛН
You don't need libraries to write a game engine in C++ | OpenGL | Devlog
2:50
computers suck at division (a painful discovery)
5:09
Low Level Learning
Рет қаралды 1,5 МЛН
Why are Bluescreens Blue?
16:27
Dave's Garage
Рет қаралды 860 М.
How a Manual Transmission and Clutch Works
10:23
Animagraffs
Рет қаралды 3 МЛН
A Introduction to Handles (in C++)
42:23
Dave Poo
Рет қаралды 10 М.