Fix crash in 2006/toledo2 + partial format README

The problem is that 'int's were being used instead of 'FILE *'s. It did
not seem to crash in linux (at least fedora) but it did in macOS which
prevented it from working. Now it works in both. I got the feeling that
it did crash in some linux distros as well as apparently Yusuke Endoh
fixed it as well though he did it by changing the ints to longs. I'm not
sure if that would work for macOS; I fixed it prior to seeing this fix.
Some -includes were added to the Makefile too that might or might not be
relevant to the fix in macOS. It very well could be relevant though.

I did a partial format fix in README.md but I will have to finish this
tomorrow as I have to leave for the rest of the day.
This commit is contained in:
Cody Boone Ferguson committed 2023-04-30 12:55:58 -07:00
1 parent d2c3ded4f9
commit 385570c5b7
4 files changed
+43 -16

No files matched your search

+1 -1
View File
@@ -64,7 +64,7 @@ CDEFINE=
# Include files that are needed to compile # Include files that are needed to compile
# #
CINCLUDE= CINCLUDE= -include unistd.h -include stdlib.h
# Optimization # Optimization
# #
+37 -14
View File
@@ -1,10 +1,7 @@
# Best of Show # Best of Show
Oscar Toledo Oscar Toledo
Av. Santa Cruz del Monte 9-304 Mexico
Ciudad Satelite. Edo. de Mexico
CP. 53110
Mexico
## To build: ## To build:
@@ -18,19 +15,42 @@ make
./toledo2 ./toledo2
``` ```
[Cody Boone Ferguson](/winners.html#Cody_Boone_Ferguson) fixed a segfault in
this program which was making it fail to work under macOS - it did not seem to
be a problem under linux, at least not fedora. The problem was wrong variable
types - `int`s instead of `FILE *`s. It now works under both macOS and linux.
Thank you Cody for your assistance!
### INABIAF - it's not a bug it's a feature! :-)
By design this program is supposed to crash on termination.
## Try: ## Try:
```sh ```sh
echo "Do or do not. There is no try." ./toledo2
``` ```
and then type in the following:
```
10 PRINT "HELLO WORLD!"
LIST
RUN
```
To end the program hit ctrl-z.
## Judges' remarks: ## Judges' remarks:
We're impressed! Last year, it was a 6502 emulator; this year, We're impressed! Last year, it was a
it's 8080! It requires an input file ("C") to be present, but [6502](https://en.wikipedia.org/wiki/MOS_Technology_6502) emulator; this year,
it does not have to be one of C.BASIC or C.BIOS - you're welcome it's [8080](https://en.wikipedia.org/wiki/Intel_8080)! It requires an input file
to write a standalone 8080 program yourself! How about C.FORTH (`C`) to be present, but it does not have to be one of `C.BASIC` or `C.BIOS` -
or C.LISP? you're welcome to write a standalone 8080 program yourself! How about `C.FORTH`
or `C.LISP`?
In addition to the functionality you could expect from a program In addition to the functionality you could expect from a program
of this size, it allows importing files from the host file of this size, it allows importing files from the host file
@@ -44,7 +64,8 @@ the code!
## Author's remarks: ## Author's remarks:
This program emulates a complete Intel(r) 8080 This program emulates a complete [Intel(r)
8080](https://en.wikipedia.org/wiki/Intel_8080)
processor, along with a teletype and a disk processor, along with a teletype and a disk
controller, just like at the start of the personal controller, just like at the start of the personal
computers revolution (circa 1975). computers revolution (circa 1975).
@@ -54,12 +75,13 @@ usable, so along it you will find two files
(C.BASIC and C.BIOS). Rename C.BASIC to C and run (C.BASIC and C.BIOS). Rename C.BASIC to C and run
the emulator, and et voila! you have the public the emulator, and et voila! you have the public
domain Palo Alto Tiny BASIC (by Li-Chen Wang), domain Palo Alto Tiny BASIC (by Li-Chen Wang),
published on the very first volume of Dr. Dobb's published on the very first volume of [Dr. Dobb's
Journal. Journal](https://en.wikipedia.org/wiki/Dr._Dobb%27s_Journal).
Type using uppercase letters, here are three example Type using uppercase letters, here are three example
programs, press Enter after each line: programs, press Enter after each line:
```
10 PRINT "Hello, world!" 10 PRINT "Hello, world!"
LIST LIST
RUN RUN
@@ -69,6 +91,7 @@ programs, press Enter after each line:
30 NEXT A 30 PRINT A+B 30 NEXT A 30 PRINT A+B
LIST LIST LIST LIST
RUN RUN RUN RUN
```
Press Ctrl+Z to quit, by the way, the segmentation fault is Press Ctrl+Z to quit, by the way, the segmentation fault is
normal at this point. normal at this point.
+1 -1
View File
@@ -17,7 +17,7 @@
unsigned char o[10],l[78114],*c=l,*k=l unsigned char o[10],l[78114],*c=l,*k=l
#define d(e)o[e]+256*o[e-1] #define d(e)o[e]+256*o[e-1]
#define h(l)s=l>>8&1|128&y|!(y&255)*64|16&z|2,y^=y>>4,y^=y<<2,y^=~y>>1,s|=y&4 #define h(l)s=l>>8&1|128&y|!(y&255)*64|16&z|2,y^=y>>4,y^=y<<2,y^=~y>>1,s|=y&4
+64506; e,V,v,u,x,y,z,Z; main(r,U)char**U;{ +64506; FILE *u, *e, *V, *v;x,y,z,Z; main(r,U)char**U;{
{ { { } } } { { { } } } { { { } } } { { { } } } { { { } } } { { { } } } { { { } } } { { { } } }
{ { { } } } { { { } } } { { { } } } { { { } } } { { { } } } { { { } } } { { { } } } { { { } } }
+4
View File
@@ -1783,6 +1783,10 @@ Incorrect formulas will ungracefully crash the program.
This program will very likely crash or do something funny if the file does not This program will very likely crash or do something funny if the file does not
exist or cannot be opened. exist or cannot be opened.
## [2006/toledo2](2006/toledo2/toledo2.c) ([README.md](2006/toledo2/README.md))
## STATUS: INABIAF - please **DO NOT** fix
By design this program is supposed to crash on termination.
# 2007 # 2007
# 2008 # 2008