Commit graph

8128 commits

Author SHA1 Message Date
Tee-Kiah Chia ea8097d866 doc/em/app.codes.nr: fix "139: no real data" error under GNU tbl
Before the patch, running the GNU tbl(1) preprocessor on the
troff file app.codes.nr would give a warning

	$ tbl app.codes.nr >app.codes.nr.2
	tbl:app.codes.nr:139: no real data
	tbl:app.codes.nr:139: giving up on this table

and the table of suffixes

	.z	no arguments
	.l	16-bit argument
	...	...

would be left out of the tbl output.
2021-05-04 16:21:33 +00:00
David Given 0b1f81fbfe
Merge pull request #231 from tkchia/tkchia/ego-il-unused
util/ego: inlining pass now tries to remove unused procedures
2021-04-26 23:16:16 +02:00
David Given 7286c67e8f
Merge pull request #224 from nick-less/default
fix compile error under macos
2021-04-26 17:34:09 +02:00
Tee-Kiah Chia 4d5b1ec115 util/ego: inlining pass now tries to remove unused procedures
This addresses issue #230, though only partially.
2021-04-26 14:27:45 +00:00
David Given a740f476c2
Merge pull request #229 from tkchia/tkchia/msdos86
Add support for compiling MS-DOS .com programs (msdos86).
2021-04-13 12:51:43 +02:00
Tee-Kiah Chia 85953022b5 README: mention msdos86 target platform 2021-04-01 14:42:02 +00:00
Tee-Kiah Chia a6c7ac2a28 plat/msdos86: add gettimeofday( ) 2021-03-29 15:15:13 +00:00
Tee-Kiah Chia f2c8828a4b plat/msdos86: copy stubs kill( ), signal( ), from plat/pc86 2021-03-28 17:21:54 +00:00
Tee-Kiah Chia 466cf20805 plat/msdos86: add open( ), lseek( ), and getpid() 2021-03-28 17:21:53 +00:00
Tee-Kiah Chia 0d2b55cd29 plat/msdos86: add isatty( ), _setmode( ), read( ), write( ) 2021-03-28 17:21:52 +00:00
Tee-Kiah Chia 2dfddf3fa8 libcc.ansi: add support for O_TEXT, O_BINARY file status flags 2021-03-27 19:12:35 +00:00
Tee-Kiah Chia aaf3ef695b plat/msdos86: implement close( ) function & proper errno setting 2021-03-27 13:23:44 +00:00
Tee-Kiah Chia 4c678ca210 Adding MS-DOS .com program support (msdos86). Still incomplete. 2021-03-27 13:15:56 +00:00
David Given 3dcd16e0a0
Merge pull request #227 from tkchia/tkchia/sepid
Add .seek asm pseudo-op, advances location counter to fixed offset
2021-03-20 19:05:14 +01:00
Tee-Kiah Chia 5d3ef4568a Add .seek pseudo-op and fix .base pseudo-op in uni_ass(6) manual 2021-03-20 17:03:12 +00:00
Tee-Kiah Chia 64a74b4e09 Add .seek asm pseudo-op, advances location counter to fixed offset
The new .seek assembler pseudo-op advances the location
counter to a fixed offset within a section --- or to a fixed
address, if the section is a .base'd section.  It works
somewhat like the GNU assembler's .org pseudo-op, though
with a hopefully less confusing name.

This pseudo-op lets us avoid having to manually compute the
needed boot sector padding in the pc86 start-up code
plat/pc86/boot.s .
2021-03-19 13:36:24 +00:00
David Given ced1e91800
Merge pull request #226 from tkchia/tkchia/sepid
aslod: fix: use section alignments when computing section sizes
2021-03-18 19:38:16 +01:00
Tee-Kiah Chia a29507d9e4 aslod: fix: use section alignments when computing section sizes
The follows( ) function uses pa->os_lign when determining
whether an output section pa immediately follows another
section pb.

However, emits( ) was not using this alignment information
when laying out and padding the output sections.  This seems
to be a bug.

I suspect that mach/arm/cv/cv.c might need a similar fix.
2021-03-18 18:25:04 +00:00
nick-less 2ae1f01f36 fix compile error under macos 2021-03-17 20:01:44 +01:00
David Given bda4239464
Merge pull request #223 from tkchia/tkchia/devel
Fix static buffer overflow in genname( ) in LLgen
2021-03-16 20:37:56 +01:00
Tee-Kiah Chia 9c7ce04cec Fix static buffer overflow in genname( ) in LLgen
This should fix at least some instances of the "undefined
reference to `LLnc_recover'" error that happens in some
builds (https://github.com/davidgiven/ack/issues/218).

The bug was that genname( ) used a static `namebuf' buffer
and did not properly check for overflow when writing into
it.  The result was that the `non_corr' variable was
sometimes overwritten with a non-zero value when it should
be zero, causing bogus results later.

This proposed patch makes genname( ) dynamically allocate
and resize a buffer for holding a target file name.

I also take this chance to fix a typo in correct_prefix().
2021-03-16 17:59:29 +00:00
David Given 7c51d86c4e
Merge pull request #221 from davidgiven/codeanalysis
Experiment with code analysis.
2020-10-09 18:08:43 +02:00
David Given b1f0038033
Typo fix? 2020-10-09 17:54:15 +02:00
David Given 05fafdd2d2
Try and make things build properly. 2020-10-09 17:52:31 +02:00
David Given b398abdd98
Experiment with code analysis. 2020-10-09 17:45:59 +02:00
David Given ec47148b85
Merge pull request #220 from davidgiven/dtrg-fixes
Don't rely on COMMON variable linkage.
2020-09-14 23:13:12 +02:00
David Given 3eed6db007 Fix some issues caused by, I think, COMMON variables no longer working in
recent gccs?
2020-09-14 22:38:01 +02:00
David Given cb540ec917
Merge pull request #217 from tevorbl/default
update platform linux68k
2020-06-13 18:41:12 +02:00
tevorbl cd36c3526b minor formatting changes
sim.c:
remove stray tracing statements
make formatting consistently leading tabs

Makefile:
restore ACK_TEMP_DIR & CC to default settings
2020-06-13 14:33:14 +01:00
tevorbl 6fe335b9e9 another fix for printf(float) on m68k platform
bug caused by this instruction:

  fmove.l fp0,d0 

problem was caused by a conflict between the fpu emulator (softfloat) and the compiler.

the emulator implemented this as a purely arithmetic move & conversion,
but the compiler assumed that the result could be interpreted as a logical (ie unsigned) conversion.
rightly or wrongly.


for example, if fp0 contained the value 2576980377.0  which is unsigned integer -1717987328
the emulator would treat this as an integer overflow and move 0x7fffffff (INT_MAX) into d0.

The complier on the other hand would assume that d0 contained 2576980377 (the unsigned value).

I don't know which is correct, but this is my fix for the time being.
2020-06-02 13:00:03 +01:00
tevorbl 04fe0aa53e fixed floats in printf in linux59k platform
problem was implementation of fint & fintrz floating point ops in m68kfpu.c
Both these ops truncated the integer to 32 bits instead of leaving it as an extended precision floating point number

Changed the implementation to use 64 bit ints instead of 32 bit ints.
2020-06-01 20:53:29 +01:00
tevorbl e5da3227d9 fpu bug fix for fgetmant op
- inserted missing break
- use temp variable instead of manipulating dest register

fgetexp changed to directly convert int to floatx80
2020-05-30 13:37:04 +01:00
tevorbl 799900f45a update platform linux68k
latest version of musashi engine
includes floating point emulation
(plus a few patches to add in missing opcodes needed by ack - see tags JFF & TBB)

added a few missing linux syscalls in sim.c

pascal now runs pretty well
quick test with modula2 passes

c gets the floating point numbers wrong, so more work needed here

other languages untested

plat/linux68k/emu/build.lua is probably not quite right - the softfloat directory is compiled in the wrong place
2020-05-28 13:06:08 +01:00
David Given 53a3630d2c Don't try to allocate a ridiculous 1025 bytes on the stack (which completely
explodes on CP/M).
2020-02-05 23:05:33 +01:00
David Given dea8e6f334 Make the Pascal example look the same as the other hilo examples. 2020-02-05 23:05:10 +01:00
David Given 97bed6c0a5 Fix incorrect instruction in the emulator disassembler. 2020-02-05 22:43:27 +01:00
David Given 1101922563 Add the deblocking parameter to cpm_bios_write(). 2020-02-05 22:05:03 +01:00
David Given 191c4a30e2
Merge pull request #214 from davidgiven/dtrg-cpm2
Enhance the CP/M libsys.
2019-11-23 11:53:26 +01:00
David Given 17fa773f04 Update CP/M libsys. 2019-11-23 11:31:03 +01:00
David Given 5e2974a23e
Merge pull request #213 from kernigh/kernigh-bug-203
Fix #203: ack -O3 crash from strength reduction
2019-11-16 11:34:48 +01:00
George Koehler 32e60ea994 Add test case for #203
left_shift() adapts the example from @davidgiven that caused `ack -O3`
to crash.  multiply() is a similar example.

Edit the build system to use -O3 for this test.  It now takes -O3 from
the test's filename, and still defaults to -O0.
2019-11-15 15:33:15 -05:00
George Koehler e841adf970 Fix END pseudo in util/ego/sr; closes #203
The strength reduction (SR) phase mishandled the END pseudo when SR
found at least 2 different expressions in the same loop, and SR made a
new header for the loop.

Since 1987 (commit 159b84e), SR appended the new header to the end of
the procedure.  Later, SR fixed the header by adding a BRA branch to
the loop's entry, and moving the END pseudo from the previous basic
block to the header.  If SR found multiple expressions, it called
fix_header() multiple times, and tried to move the END again.  The
extra move failed assert(INSTR(e) == ps_end), or moved another line
after the END, so opt2 (the peephole optimizer) would crash.

Fix by removing fix_header() and moving the code to make_header(), so
SR adds the BRA and moves the END when it makes the header, and does
so only once for each header.

Adjust init_code(), which inserts code into a header.  Stop checking
for an empty header, because make_header() now adds BRA.  After
inserting code before BRA, don't move LP_INSTR, because later
insertions should go before BRA, not after END.
2019-11-15 11:50:05 -05:00
George Koehler fc1476c88b Add -DDEBUG to enable assertions in util/ego
Our build enables assertions in some other ACK tools (like assemblers
and LLgen), but disabled them in ego until now.  Bug #203 becomes a
failed assertion in ego's SR phase:

    sr: util/ego/sr/sr_reduce.c:483: fix_header: Assertion
    `INSTR(e) == ps_end' failed.

Comment out 2 assertions in util/ego/share, because they fail on
systems with 4-byte int, 8-byte long.
2019-11-14 17:17:24 -05:00
David Given 0bcbaf848a
Merge pull request #211 from kernigh/kernigh-warn
Fewer clang warnings
2019-11-09 23:52:44 +01:00
George Koehler 3f3bf1e164 Reduce warnings, adjust format strings in util/led
Calls like `debug("something\n", 0, 0, 0, 0)` cause clang warnings,
because debug() is a macro that passes its arguments to printf(), and
clang warns about extra 0s to printf().  Silence the warnings by
hiding the printf() in a new function do_debug().  The code still
passes extra 0s to printf(), but clang can't warn.

Macros debug() and verbose() should use C99 __VA_ARGS__, so they don't
require the extra 0s; but ACK doesn't use __VA_ARGS__ yet.

Adjust some format strings for debug() or fatal(), or cast their
arguments, to match their types.  I don't know whether uint32_t is
unsigned int or unsigned long, so I cast it to unsigned long, and
print it with "%lx".

In util/led/sym.c, #include "save.h" to declare savechar(), and use
parentheses to silence a clang warning in hash().
2019-11-01 18:27:34 -04:00
George Koehler 17bc9cdef7 More void, fewer clang warnings in util/ego
Most warnings are for functions implicitly returning int.  Change most
of these functions to return void.  (Traditional K&R C had no void
type, but C89 has it.)

Add prototypes to most function declarations in headers.  This is
easy, because ego declares most of its extern functions, and the
comments listed most parameters.  There were a few outdated or missing
declarations, and a few .c files that failed to include an .h with the
declarations.

Add prototypes to a few function definitions in .c files.  Most
functions still have traditional K&R definitions.  Most STATIC
functions still don't have prototypes, because they have no earlier
declaration where I would have added the prototype.

Change some prototypes in util/ego/share/alloc.h.  Functions newmap()
and oldmap() handle an array of pointers to something; change the
array's type from `short **` to `void **`.  Callers use casts to go
between `void **` and the correct type, like `line_p *`.  Function
oldtable() takes a `short *`, not a `short **`; I added the wrong type
in 5bbbaf4.

Make a few other changes to silence warnings.  There are a few places
where clang wants extra parentheses in the code.

Edit util/ego/ra/build.lua to add the missing dependency on ra*.h; I
needed this to prevent crashes from ra.
2019-11-01 15:27:16 -04:00
George Koehler be1662dd15 Change the optional parameter of n_coerc() to a pointer
Fixes https://github.com/davidgiven/ack/issues/188

One call to n_coerc() omits the 6th and last argument.  This worked in
traditional K&R C, but stops working if we declare n_coerc() with a
prototype of all 6 parameters.

Change the last parameter to a pointer.  Declare n_coerc() with
prototype, so it now requires all 6 arguments.  Pass NULL when have no
iocc_t.  This NULL exists only to satisfy the prototype; n_coerc()
will not use this NULL.

A different fix would declare n_coerc() with 5 parameters and `...`,
then use <stdarg.h> to read the 6th argument when it exists.
2019-10-30 18:36:56 -04:00
George Koehler 7ab4794a05 Reduce clang warnings from ncg
If a .c file included "types.h" before "mach.h", then it missed the
declaration of mach_option().  Fix by adding "xmach.h".

Fix mach/powerpc/ncg/mach.h and mach/vc4/ncg/mach.h to use the correct
type in their printf() format strings.
2019-10-30 18:36:55 -04:00
George Koehler 0576641cae Reduce clang warnings from top
Also add `static` and remove `register` in mach/proto/top/top.c.  A
static function is only in one file, so its function declaration may
go in that file, instead of a header file.
2019-10-30 18:36:55 -04:00
George Koehler 51e34acab1 Add a syntax to declare functions in a top table
Use the new syntax in the mips, pdp, powerpc tables to declare
functions before calling them.  These declarations prevent compiler
warnings about implicitly declaring functions.  They also provide
prototypes of the function parameters.

Also fix a warning in the powerpc table: use `bsearch(...) != NULL` to
avoid converting the pointer from bsearch() to an int.

The syntax for topgen is a block `{...}` among the parameters in the
top table.  It looks like the syntax of LLgen, but topgen doesn't
allow nested blocks, so declarations like `struct whatever {...};`
don't work.  The token OPEN_BRACKET that begins a declaration_block
doesn't conflict with the LETTER that begins a parameter_line or the
'%' that begins a separator.

Because a block writes a #line command to gen.h, a parameter line now
also writes a #line command to gen.h, so it doesn't get a wrong line
number from a previous block.
2019-10-30 18:36:55 -04:00