Re: Programming language implementation ...
Posted: Fri Nov 04, 2016 3:45 pm
It wouldn't let me attach a .c file, but here is a .zip file as you suggested.
The Commodore Vic 20 Forum
http://sleepingelephant.com/ipw-web/bulletin/bb/
http://sleepingelephant.com/ipw-web/bulletin/bb/viewtopic.php?t=8257
Code: Select all
Enter expression:
1-3+2
0
Enter expression:
1+2-3
0
The concepts taught in school are geared to be easy to grasp, and hopefully correct in most circumstances.Bobbi wrote:I remember learning in school 'BODMAS' Brackets Of (meaning division) Multiplication Addition and Subtraction ... so there is some idea that division has higher precedence than multiplication and addition over subtraction.
Code: Select all
3 + 5 8
----- = --- = 4 = (3 + 5)/(1 + 1) != 3 + 5 / 1 + 1 = 9
1 + 1 2
Code: Select all
1 1 1 1
--- x = --- * x and ------- = -----
2 2 2 * x 2 x
Code: Select all
int name = expression
print expression
quit
# comment
Code: Select all
int vic <- $900f
int bord <- 3
int scrn <- 4
*vic <- (bord<<4)#(scrn&$07)
Code: Select all
call setscrcol
int i <- 99
lbl mainloop
i <- i - 1
print i
if i>1 prstr " bottles of beer"
if i==1 prstr " bottle of beer"
if i>0 jump mainloop
# Set screen color
# to my favorite combo
sub setscrcol
*($900f) <- 254
return
Using the PETSCII left-arrow symbol for assignments is just plain lovely. <3Bobbi wrote:<- is the CBM left arrow key which I use for assignment
One major aspect what "kills" the code size for C on the 65xx is the parameter passing of functions. The cc65 C runtime has to simulate the C stack in all its glory, and that housekeeping blows up the function entry, exit and variable access. You really can't blame this on cc65.It is in reasonable shape now, and I am going to have to stop adding features soon because the available memory is dropping fast! [...] C is not a great language for 6502 / cc65 is not a great compiler. The code is pretty bloated and I have to stop adding functions before I have nothing left from my 32K expansion!