Search found 42 matches

by paul_nicholls
Fri Apr 26, 2024 9:28 am
Forum: Programming
Topic: Pas6502 - Pascal dialect compiler -> 6502 assembly code
Replies: 17
Views: 18128

Re: Pas6502 - Pascal dialect compiler -> 6502 assembly code

I recently updated my pas6502 Pascal -> 6502 compiler again. It now supports c64, c128, vic20, BBC micro, Atari 8-bit, and soon NES (hopefully).
Syntaxerrorsoftware.itch.io/pas6502
by paul_nicholls
Fri Apr 05, 2024 10:44 pm
Forum: Programming
Topic: Pas6502 - Pascal dialect compiler -> 6502 assembly code
Replies: 17
Views: 18128

Re: Pas6502 - Pascal dialect compiler -> 6502 assembly code

Thanks for the info mate :)
cheers,
Paul
by paul_nicholls
Mon Apr 01, 2024 2:33 am
Forum: Programming
Topic: Pas6502 - Pascal dialect compiler -> 6502 assembly code
Replies: 17
Views: 18128

Re: Pas6502 - Pascal dialect compiler -> 6502 assembly code

Proxy wrote:
damn if this worked for the 65816 then it could maybe be possible to port ORCA-C to a more generic system instead of being Apple IIgs specific
Interesting, I'll have a look at the 65816 CPU to see what that is like for possibly adding to Pas6502 :)

cheers,
Paul
by paul_nicholls
Sat Dec 01, 2018 3:53 am
Forum: Programming
Topic: Pas6502 - Pascal dialect compiler -> 6502 assembly code
Replies: 17
Views: 18128

Re: Pas6502 - Pascal dialect compiler -> 6502 assembly code

I'm writing it using Embarcadero Delphi.

I guess it would run under Wine in Linux, and you could use any text editor to create the source code files, but currently, you would have to load it into the compiler window (or copy/paste) prior to compiling it to a .prg file.

It uses kick assembler (runs ...
by paul_nicholls
Fri Nov 30, 2018 8:11 am
Forum: Programming
Topic: Pas6502 - Pascal dialect compiler -> 6502 assembly code
Replies: 17
Views: 18128

Re: Pas6502 - Pascal dialect compiler -> 6502 assembly code

I've now added if and while statements to #Pas6502, and here is the obligatory infinite loop incrementing the border color lol

If anyone is wondering, I've been basing my code on the classic " Let's build a compiler " tutorial series by Jack W. Crenshaw here:
http://www.penguin.cz/~radek/book/lets ...
by paul_nicholls
Wed Nov 28, 2018 7:20 am
Forum: Programming
Topic: Pas6502 - Pascal dialect compiler -> 6502 assembly code
Replies: 17
Views: 18128

Re: Pas6502 - Pascal dialect compiler -> 6502 assembly code

More #Pas6502 compiler progress...can now do basic math, store values into variables and absolute addresses (1 or 2 byte) [including arrays], and Poke() command added. More optimisation needed, but am very happy :) <committing to version control now lol>

Input example:
http://forum.6502.org/images ...
by paul_nicholls
Tue Nov 20, 2018 8:19 am
Forum: Programming
Topic: Pas6502 - Pascal dialect compiler -> 6502 assembly code
Replies: 17
Views: 18128

Re: Pas6502 - Pascal dialect compiler -> 6502 assembly code


I have made a start where I can parse expressions using standard Pascal syntax, or expressions including mixed maths & boolean logic for tricky equations like the Dirac delta function (one line):

a := -(x=0)

or the absolute value function (definitely tricky code!):

x := x*(1+2*(x<0))

Just ...
by paul_nicholls
Mon Nov 19, 2018 2:28 am
Forum: Programming
Topic: Pas6502 - Pascal dialect compiler -> 6502 assembly code
Replies: 17
Views: 18128

Re: Pas6502 - Pascal dialect compiler -> 6502 assembly code

I was just parsing the expression into postfix format using an expression tree and not optimising it before...

Is that what you meant?
cheers,
Paul
by paul_nicholls
Sun Nov 18, 2018 9:24 am
Forum: Programming
Topic: Pas6502 - Pascal dialect compiler -> 6502 assembly code
Replies: 17
Views: 18128

Re: Pas6502 - Pascal dialect compiler -> 6502 assembly code

I've now added some optimizations like simplifying to a numerical value where possible, division with a power of 2 to a shift, and multiplication to shifts & additions. Will do * 0, * 1, + 0 optimizations too amongst others.
by paul_nicholls
Sun Nov 18, 2018 5:53 am
Forum: Programming
Topic: Pas6502 - Pascal dialect compiler -> 6502 assembly code
Replies: 17
Views: 18128

Re: Pas6502 - Pascal dialect compiler -> 6502 assembly code

What does

x := (x<0)*x*2+x
compile to?

That currently compiles to:
main:
:loadIntRegMem(x,0)
:loadIntRegIm(0,1)
:cmpIntRegLss(0,1,0)
:loadIntRegMem(x,1)
:mulIntReg(0,1,0)
:loadIntRegIm(2,1)
:mulIntReg(0,1,0)
:loadIntRegMem(x,1)
:addIntReg(0,1,0)
:storeIntRegMem(0,x)
rts


:)
by paul_nicholls
Sat Nov 17, 2018 12:39 am
Forum: Programming
Topic: Pas6502 - Pascal dialect compiler -> 6502 assembly code
Replies: 17
Views: 18128

Pas6502 - Pascal dialect compiler -> 6502 assembly code

Hi all,
I'd thought I'd mention that I'm working on a project (part fun/learning/useful) called Pas6502 which will compile a dialect of Pascal into 6502 assembly code (using Kick Assembler macros and asm code). I will be starting with the C64.

I know there have been others, but I wanted to do this ...
by paul_nicholls
Tue Oct 16, 2018 6:50 am
Forum: Programming
Topic: Signed 16-bit right shift question with -1 shift check
Replies: 19
Views: 6644

Re: Signed 16-bit right shift question with -1 shift check

Thanks for all the answers everyone, much appreciated :)

I think I'm good now :D

cheers,
Paul
by paul_nicholls
Mon Oct 08, 2018 5:18 am
Forum: Programming
Topic: Signed 16-bit right shift question with -1 shift check
Replies: 19
Views: 6644

Re: Signed 16-bit right shift question with -1 shift check

As was already suggested, you can test for -1 before the division.
My question is, does the -1 result cause a problem with your program? In other words, does your program require symetrical integer division or can you use floored integer division?
With floored integer division, if the real result ...
by paul_nicholls
Sun Oct 07, 2018 9:15 am
Forum: Programming
Topic: Signed 16-bit right shift question with -1 shift check
Replies: 19
Views: 6644

Re: Signed 16-bit right shift question with -1 shift check

I had a fiddle (not a short as your version) and got something to work:

.macro div2_16bit(address) {
// is the value -1 at the start?
lda address + 1
cmp #255
bne divBy2
lda address + 0
cmp #255
bne divBy2

// yes, so set to zero and exit
lda #0
sta address + 1
sta address + 0
jmp done ...
by paul_nicholls
Sun Oct 07, 2018 9:03 am
Forum: Programming
Topic: Signed 16-bit right shift question with -1 shift check
Replies: 19
Views: 6644

Re: Signed 16-bit right shift question with -1 shift check

Thanks Mike B :)

That seems to work ok if the value is -1 before the macro, but if the value is -2 before the macro then the result becomes 0 right away instead of -1 as I would have expected.

cheers,
Paul