The error Oracle returns when a procedure runs into a numeric or value error. Looks like this:

ORA-06502: PL/SQL: numeric or value error

A 6502 is returned by PL/SQL when fetching a select-list item whose length is not determined at compile time (e.g. 'a'||'b' into a %rowtype variable).

Since the size of "Teach yourself 'Hello, world!' in 24 Languages" skyrocketed above the GTKYN level, I'll put this one here. More appropriate place, right?

Teach yourself "Hello, World!" in 6502 assembly

This example is for Commodore 64, and it's compileable with xa.

 
        .word $c000	; file header
*=$c000
MAIN:	LDX #$00
Loop:	LDA hello,x
	CMP #$00
	BEQ Out
	JSR CHROUT
	INX
	JMP Loop
Out:	RTS

hello:	.asc "hELLO, WORLD!"
	.byt 13,0

fUNNY cAPITALIZATION is because of PETSCII character set.

(CHROUT is a kernal (sic) routine that prints the character in accumulator to screen - I didn't bother to write a direct-screen-memory-addressing thing here, even when that would have been more portable to other 6502 systems...)

Another version that uses BASIC ROM routine (for those who are not afraid to use those eeeeevil Microsoft APIs):

 
        .word $c000	; file header
*=$c000
MAIN:	LDA #<hello
	LDY #>hello
	JSR $AB1E	; STROUT
Out:	RTS

hello:	.asc "hELLO, WORLD!"
	.byt 13,0

Some technical bits

Then, to make the node a bit more interesting, here is some information of the processor.

The processor has only stack space of 256 bytes in the first page ($0100-$01FF). Also note that it has only three actually usable registers (A,X,Y) and those are 8-bit registers! This poses some worthy challenges for the programmers, who so far have been extremely clever to overcome them...

Whether 6502 is RISC or CISC is very much debated. It does have quite a few CISCy things, notably the addressing modes, but there's a relatively small number of possible instructions and very limited number of processor registers (though that in other circles is considered a CISC thing), and the rumored non-existence of any kinds of microcode, which would indicate that design of 6502 was indeed very RISCy. Many insist calling it RISC, some say it's between them. Many call it CISC, probably quite justifiedly - there's a difference between "RISC" and "just quite damn headache-inducingly incapable processor" =)

6502 derivatives can address 64 kilobytes of memory. Too many lazy coders rely on this, which may be problematic for users of 65816...

6510 and other processors in Commodore 64 also had a "processor channel" at memory addresses $0000 and $0001; these memory locations had many interesting bits. Well, only three, actually: the first three bits of $0001 that toggled the "visibility" of BASIC, Kernal and Character ROM banks, respectively; if turned off, the RAM "underneath" them could be used for other purposes.

6502 versions

6502
Used in Commodore floppy drives, other 8-bit machines (VIC-20, Atari, Apple II)
6510
Used in older C64s
8500
Used in newer C64's - same processor, different pin layout
8502
Used in Commodore 128s.

Not 100% compatible versions:

65C02
C16, C116, Plus/4
65SC02
Small version of 65C02
65CE02
Extension of 65C02, used in Commodore 65 (the legendary not-widely-released machine)
65816
Extended 6502 with new opcodes and 16-bit operation modes

(the genealogy part taken from: http://www.chez.com/apple1/Docs/m6502/6502-6510-8500-8502%20Opcodes.htm )

Recently I have realised a Profound Truth; the 6502
microprocessor, which we all know and love, is fully compliant with the
Law of Fives. Look at this for proof:

1) One of the most common sequences of instructions on the 6502
is "LDA #$baz ; STA $foobar"; in machine language this is (as
anyone who has typed in source listings from old Commodore
magazines will know) 169 baz 141 bar foo. There are _five_
bytes in this, _two_ in the first instruction and _three_ in
the second. The bicycle and the tricycle, as Adam Weishaupt
named them; this has the same rhythm as "abracadabra", and
the Crowleyan "Io Pan! Io Pan Pan!", and "Annuit Coeptis;
Novus Ordo Saeclorum", and "Hail Mary, Full of Grace".
Need I say more?

2) The opcode for "LDA #$" is 169, the opcode for "STA $"
(non-zero-page) is 141. 169-141=28, which is 23+5. Go figure.
The 6502 is the model number of a computer chip that made its way into many of the original microcomputers. It is fondly remembered by many people as a capable (for its time) and quirky processor.

History

MOS Technology hired a group of ex-Motorola engineers in August 1974. Their plan was to create a better 6800. By the fall of 1976 they had two models ready: the 6501 was pin-compatible with the 6800, and the 6502 was similar but had an on-chip clock. Both used a new instuction set that was similar, but incompatible with the 6800. Even so, Motorola sued, and MOS withdrew the 6501 in a settlement.

The 6502 was immediately successful. The Atari 2600 featured a 6507, a specialized 6502. But the 6502's big breakthrough occured when a hacker named Steve Wozniak picked up some cheap $25 samples and built his Apple I computer around it. At the time, Motorola and Intel charged hundreds of dollars for it's comparable chips in small quantities. MOS practically gave away their chips, making it far more accessible for the growing microcomputer hobbyist community.

Commodore, another microcomputer maker, chose the 6502 for its machines. The famous Commodore PET, VIC-20, and Commodore 64 computers all ran on 6502 family chips. In 1976, Commodore bought MOS, but eventually hit hard times and shut down its semiconductor division. Rockwell International, a 6502 design lisencee, became the only producer of the chips.

Other popular designs that featured 6502 or 6502 family chips include the entire Apple II series of computers, the Atari 8-bit computer family including the Atari 400/800, the original Nintendo NES and the BBC Micro.

Later, one of the ex-Motorola and ex-MOS engineers, Bill Mensch, resurrected the 6502. He founded Western Design Center and redesigned the 6502 using a low-powered CMOS design. The result was 65c02. The new processor also had a few new instructions specially designed to address some shortcomings of the original design. The 65c02 was used in the Apple IIc and a later redesign, the 65C816, was in the Apple IIgs and the Super Nintendo. Commodore, however, sued WDC for theft of trade secrets, but settled for the right to make the chip at half the usual licence fee.

The Technical Details

The 6502 is an 8-bit microprocessor with a 16-bit address bus. In other words, its registers are 8-bits wide, but it has 16-bit addresses. It has a 16-bit program counter and five 8-bit registers: an accumulator (A), two index registers (X and Y), a status register and a stack pointer. The stack is hardwired to the second page of 256 bytes.

The 6502 is the epitome of CISC design: it has many, complex addressing modes: zero-page, absolute, accumulator, (indirect,x), (indirect),y, immediate, and various additional combinations. The original 6502 also has a number of unassigned instructions opcodes which try to do two operations at once, sometimes even producing useful results. This was the source of many incompatibilities between the the original and the later revisions like the 65c02, which added new instructions that replaced these "undocumented" opcodes.

The 6502 instruction set is relatively simple: four logical instructions, AND, BIT, ORA, EOR; four shifts and rotates, ASL, LSR, ROL, ROR; two arithmetic instructions, ADC, SBC; six increment and decrement instructions, DEC, DEX, DEY, INC, INX, INY; three comparisions, CMP, CPX, CPY; six register transfers, TAX, TAY, TSX, TXA, TXS, TYA; six loads and stores, LDA, LDX, LDY, STA, STX, STY; four stack operations, PHA, PHP, PLA, PLP; eleven branches, jumps and returns, BCC, BCS, BEQ, BMI, BNE, BPL, BVC, BVS, JMP, JSR, RTS; seven flag sets and clears, CLC, CLD, CLI, CLV, SEC, SED, SEI; two for interrupts, BRK, RTI; and the ubiquitous no operation NOP.


Sources:
The 6502's Long Path to The Western Design Center, Michael Slater
http://www.6502.org/

Gosh darn, it's been a while... You might find this to be marginally more efficient.

.word $c000 ; file header

*=$c000

MAIN: LDX #$00

Loop: LDA hello,x

; CMP #$00 - no need for explicit compare as zero

; flags are set on LDA

BEQ Out

JSR CHROUT

INX

; JMP Loop - 3 bytes. Why waste of a byte and cycle...

BNE Loop ; when this will do just as well...

Out: RTS

hello: .asc "hELLO, WORLD!"

.byt 13,0

Saving 3 bytes and cycles might seem a bit odd to some of you people out there but it was the ethos of the 6502 hacker...

Log in or register to write something here or to contact authors.