Dark Bit Factory & Gravity
ARCHIVE => Archive => Useful links => Topic started by: Hotshot on April 01, 2008
-
6502 Assembler for someone who know all about them like Shockwave who used code in assembler in old days ;D
http://www.6502asm.com/
-
nop
6502C was the Commodore 64 CPU, as well as the one used in the BBC Micro range.
It was crap in a lot of ways, even in the day. To access a 16bit address, to address 64kb, it needed 2 instructions and it only had 3 8bit registers (compare with variables) called X,Y,A. Most of the instructions could only operate on A. The Z80, in the competing products, had 16bit addressing and 10 times as many registers.
Here endeth another history lesson.
Jim
-
What a coincidence :) I'm currently writing a 6502 Simulator, in Forth.
I still have my old Apple IIe, Atari 800XL and I recently bought a replica Apple I kitset, which I've yet to put together.
Actually, the very first computer I ever owned was a Sinclair ZX81, but I never much liked the Z80.
What I really want is to build my own Atari 800 laptop, like Ben Heckendorn.
Yep the 6502 was pretty basic alright, but it was so dirt cheap when it came out, all the home computer vendors (and hobbyists) jumped for it, so it really helped foment the golden era of home computing.
However, IMO the best CPU of the 8-bit era was undoubtedly the 6809.
-
The old NES had one of these too didnt it? and I think I heard that there was no multiply command but I may be wrong here. 8 bit Chips really were minimalistic
-
My c64 assembler was on a cartridge, and as crappy as it was it was great too.
C64 basic was so utterly horrible that you may as well have just learned 6502 instead.. And many did :D
-
Yup, no multiply command on the 6502, or the Z80 for that matter. Lots of people wrote routines that used self generating, self modifying code to do multiplies.
I remember reading an article about Nodes of Yesod for the ZX Spectrum. The programmer says he allocated 20bytes for the data structure for each object but ended up only using 19bytes. But he never bothered fixing it because the x20 routine was shorter and faster than the x19 one :)
Jim
-
To access a 16bit address, to address 64kb, it needed 2 instructions
I had an electron (actually still got it somewhere) and although it had 32k RAM (&0000-&7FFF) it also had 32k ROM (&8000-&FFFF) all of which I thought could be addressed directly with absolute addressing even though you couldn't write to the ROM.
-
This has just reminded me of something else, I had to write a multiplication routine among other things on a 6800 (very similar to the 6502). The thing was a PCB with the cpu and some ram and an eprom nailed onto a bit of wood with a 6 digit hex display and keypad, that's the british defence industry for ya.
-
ahhh great memories! I remember the hours I spend writing an integer division routine for my 65816 assembler (brother of the 6502)... endless headaches.. and I'm not sure I fully understood the algorithm at that time ??? ??? ???
-
It was god like working in ASM on the C64 between the ages of 10 and 20.
Removing cycle flicker, destroying borders, adding sprites and building basic maths routines for 3d and line drawing.
I want a VIC II chip for my Pentium.
Sweet memories.
-
As I've metioned in the 'dungeon crawler' thread, I'm thinking about trying something out in 6502. I have some ideas about how to go about the final drawing stage but going to have to look into dealing with transforms and divides for perspective and things like that. I imagine fixed point is most likely the way to go and would probably prefer performance over precision as it's going to be a bit wobbly anyway.
Has anyone got any links that might be relevant? And would anyone be interested in helping out?
-
Hugi number 15 has a really good artical about it. BTW fixed point can be more acurate than floating point within a given range so long as you dont overflow or underflow because its basically integer math. But of course Floats allow for greater precision.
Hero are some x86 implementations that work using 16:16 fixed point most are from the Hugi artical but the division routines were given to me by a member of the FASM board cos the divide in Hugi didnt work unless the result was garaunteed to be an integer :
*ff ... fixed point to fixed point
*fi ... fixed point to integer
name 'fixedpoint.inc'
fixfi macro B,A
mov eax,[A]
shl eax,10h
mov [B],eax
fixfi endm
intif macro B,A
mov eax,[A]
shr eax,10h
mov [B],eax
intif endm
fracf macro B,A
mov edx,[A]
xor eax,eax
xchg ax,dx
mov [B],eax
fracf endm
modff macro C,A,B
mov eax,[A]
mov edx,eax
sar edx,16
shl edx,16
idiv [B]
xor edx,edx
xchg eax,edx
xchg ax,dx
mov [C],eax
modff endm
addff macro C,A,B
mov eax,[A]
add eax,[B]
mov [C],eax
addff endm
addfi macro C,A,B
mov eax,[A]
shl eax,16
add eax,[B]
mov [C],eax
addfi endm
subff macro C,A,B
mov eax,[A]
sub eax,[B]
mov [C],eax
subff endm
subfi macro C,A,B
mov eax,[A]
shl eax,16
sub eax,[B]
mov [C],eax
subfi endm
mulff macro C,A,B
mov eax,[A]
mov edx,[B]
imul edx
shrd eax,edx
mov [C],eax
mulff endm
mulfi macro C,A,B
mov eax,[A]
mov edx,[B]
imul edx
mov [C],eax
mulfi endm
divff macro C,A,B
mov eax,[A]
mov edx,eax
sar edx,16
shl edx,16
idiv [b]
mov [C],eax
divff endm
divfi macro C,A,B
mov eax,[A]
cdq
idiv [B]
mov [C],eax
divfi endm
Heres a link to the divison fix
http://board.flatassembler.net/topic.php?t=7681
-
Thanks rain_storm. There's going to be a fair bit more work with it though as the 6502 only has 3 8 bit registers and no divide or multiply instruction. I may have to make some compromises and got for something less than 16:16 too.
-
Yeah that does make it more complicated perhaps there is already functions for fixed point math in 6502. Im interested in fixed point too so if I see something of interest i'll post it here
-
'perhaps there is already functions for fixed point math in 6502'
It has 8 bit add and subtract :( that is all.
-
Sorry I ment code on the web for 6502 that provides that functionality lol
-
Ah LOL, I get ya now. That's the sort of thing I was meaning when I asked if anyone had any links to anything too.
-
I've dug out my old manual, it has some examples of multiply and divide, only for 8 bit but it's a start.
-
http://6502.org/source/ <- has something of interest
Natural Log - LOG
Common Log - LOG10
Exponential - EXP
Floating Add - FADD
Floating Subtract - FSUB
Floating Multiply - FMUL
Floating Divide - FDIV
Convert Floating to Fixed - FIX
Convert Fixed to Floating - FLOAT
-
Hmmmm, very cool, thanks rain_storm K+.