Jeśli chcesz wziąć udział w dyskusjach na forum - zaloguj się. Jeżeli nie masz loginu - poproś o członkostwo.
Vanilla 1.1.4 jest produktem Lussumo. Więcej informacji: Dokumentacja, Forum.
Ilmenit:
Wiele języków dla 6502 jak Atalan (...) to "one man show" i gdy autor traci zainteresowanie, to narzędzie kończy swoje życielaoo:
Ale mi też dobry język wysokiego poziomu spędza sen z powiek, bo z Solem czujemy, że np pisanie logiki do gry w asm jest uciążliwe.laoo:
(...) bo w tym wieku czas to jedyna waluta jaką tak naprawdę się płaci.Ilmenit:
Jak dokończę aktualny projekt to napisze artka jak pisać w CC65, aby było "prawie optymalnie".// Type your code here, or load an example.
unsigned int sum(void) {
register unsigned int s;
register const unsigned char* p;
s = 0;
for (p = 0; p != 0; ++p)
{
s += *p;
};
return s;
}
.proc _sum: near
jsr decsp4
ldx #$00
lda #$00
ldy #$02
jsr staxysp
ldx #$00
lda #$00
ldy #$00
jsr staxysp
L0004: ldy #$01
jsr ldaxysp
cpx #$00
bne L000B
cmp #$00
L000B: jsr boolne
jne L0007
jmp L0005
L0007: ldy #$01
jsr ldaxysp
ldy #$00
jsr ldauidx
ldx #$00
ldy #$02
jsr addeqysp
ldy #$00
ldx #$00
lda #$01
jsr addeqysp
jmp L0004
L0005: ldy #$03
jsr ldaxysp
jmp L0001
L0001: jsr incsp4
rts
#pragma bss-name (push,"ZP")
#pragma data-name (push,"ZP")
unsigned int s;
const unsigned char* p;
#pragma bss-name (pop)
#pragma data-name (pop)
#pragma zpsym ("s");
#pragma zpsym ("p");
// Type your code here, or load an example.
unsigned int sum(void) {
s = 0;
for (p = 0; p != 0; ++p)
{
s += *p;
};
return s;
}
_s:
_p:
.proc _sum: near
lda #$00
sta _s
sta _s+1
sta _p
sta _p+1
L000A: lda _p
ora _p+1
beq L000B
lda _p+1
sta ptr1+1
lda _p
sta ptr1
ldy #$00
lda (ptr1),y
clc
adc _s
sta _s
tya
adc _s+1
sta _s+1
inc _p
bne L000A
inc _p+1
jmp L000A
L000B: lda _s
ldx _s+1
rts
#define NO_MONSTERS 32
struct monster {
unsigned char x;
unsigned char y;
};
struct monster monsters[NO_MONSTERS];
#pragma bss-name (push,"ZP")
#pragma data-name (push,"ZP")
unsigned char index;
#pragma bss-name (pop)
#pragma data-name (pop)
#pragma zpsym ("index");
void set_monsters(void) {
for (index=0;index<NO_MONSTERS;++index)
{
monsters[index].x = index;
monsters[index].y = index * 2;
};
};
_monsters:
_index:
.proc _set_monsters: near
lda #$00
sta _index
L001A: lda _index
cmp #$20
bcs L0009
ldx #$00
lda _index
asl a
bcc L0018
inx
clc
L0018: adc #<(_monsters)
sta ptr1
txa
adc #>(_monsters)
sta ptr1+1
lda _index
ldy #$00
sta (ptr1),y
ldx #$00
lda _index
asl a
bcc L0019
inx
clc
L0019: adc #<(_monsters)
sta ptr1
txa
adc #>(_monsters)
sta ptr1+1
lda _index
asl a
iny
sta (ptr1),y
inc _index
jmp L001A
L0009: rts
#define NO_MONSTERS 32
struct monster {
unsigned char x[NO_MONSTERS];
unsigned char y[NO_MONSTERS];
};
struct monster monsters;
#pragma bss-name (push,"ZP")
#pragma data-name (push,"ZP")
unsigned char index;
unsigned char calc_result;
#pragma bss-name (pop)
#pragma data-name (pop)
#pragma zpsym ("index");
#pragma zpsym ("calc_result");
void set_monsters(void) {
for (index=0;index<NO_MONSTERS;++index)
{
monsters.x[index] = index;
calc_result = index * 2;
monsters.y[index] = calc_result;
};
};
_monsters:
_index:
_calc_result:
.proc _set_monsters: near
lda #$00
sta _index
L001C: lda _index
cmp #$20
bcs L000B
ldy _index
lda _index
sta _monsters,y
lda _index
asl a
sta _calc_result
ldy _index
lda _calc_result
sta _monsters+32,y
inc _index
jmp L001C
L000B: rts
_s:
_p:
.proc _sum: near
lda #$00
sta _s
sta _s+1
sta _p
sta _p+1
L000A: lda _p
ora _p+1
beq L000B
lda _p+1
sta ptr1+1
lda _p
sta ptr1
ldy #$00
lda (ptr1),y
clc
adc _s
sta _s
tya
adc _s+1
sta _s+1
inc _p
bne L000A
inc _p+1
jmp L000A
L000B: lda _s
ldx _s+1
rts
lda #$00
sta L000B+1
sta L000A+2
sta L000A+3
L000A clc
adc $FFFF
bcc L000C
inc L000B+1
L000C inc L000A+2
bne L000A
inc L000A+3
bne L000A
L000B: ldx #$ff
rts
mva #$00 RESULT
sta RESULT+1
sta P
mva #$E0 P+1
jmp l_009B
l_009C
ldy #$00
lda RESULT
add (P),y
sta RESULT
scc
inc RESULT+1
inc P
sne
inc P+1
l_009B
lda P+1
jne l_009C
lda P
jne l_009C
function sum: word;
var p: PByte absolute $e0;
begin
Result := 0;
p := pointer(rom);
while p > pointer(0) do begin
inc(Result, p[0]);
inc(p);
end;
end;