-----------------------------
asm5900 - development history
-----------------------------


21.01.2001
project started... (i should had give some comments, but i was too lazy)

10.03.2001
should support MIPS-I instruction sets (except OFF(BASE) parameters), now
things not done yet:
- need to include types for a param (of an instruction) to support things like OFF(BASE) "lb zero, 123h(zero)"
- expand the get_param instr. to detect so much params as possible and return just a pointer (dealloc it then by a call to free(ptr))
- take a look at the directives.cpp, not much done yet, ehh? ;) (not the macros)
- the label-resolve-kit should be done now
- implement COP-I+II, R59 MIPS, ... (thats a peace of work!!!)
- do implement a nice "1-4-all" return-value (compatible to error-function)
- and btw: make the error-comments fit (not just syntax-err when all other things look fine)
- make the assembler be able 2 generate info-files (for debugging-info) like label/off/line-tables
- macros!!!

12.03.2001
done the first 2 things, nxt step are the directives, need a own param-scan-routine (to report strings and split "data in marks" for DX`s)
(18:26) directives ORG and INCLUDE added. (INCLUDE BINARY not supported yet)

14.03.2001 (04:27)
directives Dx added, fixed a tons of bugs, the label: in the instr-line points now to the real ofs of the produced opcode (lbl_address,lbl_type)
nxt i should do the error-return stuff, thats real strange 'til now, and with every more line code, the return codes get more'n'more mixed'up

19.03.2001 (14:39)
was away for a while! now i completed the file opcodes.txt. just include this file in the assembler nxt time...
need 2 include define-"labels" 4 the COP0 opcode register

20.03.2001 (17:19)
start 2 change the entire error-routine (need a global one)...
(23:52) work completed!
just implement the resolving unit now...

21.03.2001 (02:21)
finished the first beta version of asm5900 :) feel so happy about this!

here comes lots of debugging...

[BUG] lw reg1,-offset(reg2)
lw t0,-16(a0), doesnt accept negative numbers, not so important as
FFFFFFFFFFFFFFF0h seems to do the job ;)
[COMMENT] fixed this bug! the do_math routine changed the string passed to it, but was used later again with same string
now int_math does the same job without changing the string

[BUG] lh reg1,(reg2)
lh s2,(t0) -This one loads s2, with the contents of the adress t0 is pointing to.. very important that it works.
[COMMENT] done! def. ofs = 0

[BUG] LI reg,value missing...
eventough its an pseudo up its very useful.. much easier doing li v0,value ,
than doing lui v0,value<<16 : ori v0,v0,value. The same goes for LA reg,ADR (load effective address)
[COMMENT] i will implement this later with the macros!

[BUG] lw reg,adr and sw reg,adr doesnt work
lw a0,1000A000h (load a0 with contents of adr. 1000A000h)
sw a0,1000A000h
[COMMENT] done! def. base is gp!

[BUG] regarding load instructions: LB,LBU,LW etc...
[COMMENT] works now:
org xxxxxxxxh
lw t0,variable
variable: DW 12345678h
would be translated like:
xxxxxxxxh lw t0,(variable - xxxxxxxxh)(gp)

21.03.2001
After lotsa tests, seems like the assembler works ;)
Version v1.0 beta uploaded to http://napalm.intelinet.com

[BUG] addi a0,a0,ffffh makes overflow..
it seems it doesnt accept full 16bit (think also this is wrong in the offsets)
[COMMENT] fixed!

24.03.2001
done:
- inserted a case-sensitive-switch (NOTE: in non-case-sensitive-mode the default register "bfh" overwrites another reg)
- done parameter-scan (asm5900 main.asm -omain.elf -c)
- converted all cpp-files into classes (looks better with vc++ :)
- updated the stream-class to support different file-types (FTYPE_xxx)
what 2 do:
- implement macro-directive and if-directive
- extend 64bit signed to 128bit signed/unsigned

18.04.2001
macros works now and data-duplication ..Dx num DUP(value).. added
REMARK: $ returns actual ofs (program counter) now, and $$ the actual file offset. the hole label-addressing changed. (@code.proc.label)
macro syntax:
my_macro MACRO a,b,c
....code....
my_macro ENDM

2do: IF..ELSE..ENDIF

20.04.2001
include preprocessing:
give the intmath routine a flag, whether to allow labels or not... done!
include a preprocess-counter in assemble class... works partial!
do support, that the stream is switched back to start... works!

22.04.2001
resolve remove...ok!
segment-class reset...ok!
macro-overwrite error...ok! (i think its!)
preprocessing works now! i included a switch to set preprocessing-number! (default is 2)

23.04.2001
changing the label adressing method (hope the last time :)

fixed a DUP-bug, this code works now:
dup DB 16 DUP(_a),0
DEFINE _a 'a'

24.04.2001
added ability 2 output debug info (when finished, see the doc for file description)

  head(22): "[asm5900|dbg|v1.00]", 0D, 0A, 1B

  file_block_id(6): "[file]"
  no_file_items(DWORD): holds the number of items following this DWORD

	typedef struct
	{
	  BYTE type; //0=def,1=binout,2=include,3=macro, bit64?buffer:file, bit128?done:broken
	  DWORD	return_to_file_no;
	  DWORD	line_cntr; //lines done
	  DWORD	size;			//number of lines (for buffers)
	  DWORD	error_cntr; //number of errors only in this file
	  DWORD	warning_cntr;
	  void *dmy00, *dmy01, *dmy02;
	  void *dmy03, *dmy04, *dmy05;
	} FILE_ITEM;

	enum
	{
	  FTYPE_DEFAULT,	//the item points 2 a default file (like src-file)
	  FTYPE_BINOUT,		//points to a binary output file
	  FTYPE_INCLUDE,	//file points 2 an include file
	  FTYPE_MACRO,		//this entry points to a macro
	  FTYPE_IFELSE,		//an if/else - statement

	  FTYPE_BUF_FLAG = 64,
	  FTYPE_DONE_FLAG = 128,
	};

	NOTE: c++ aligns every table entry to 32bit!
	after the items a chain of null-terminated strings is written (for every item one name).
	file_block ends.


  class_block_id(7): "[class]"
  no_class_items(DWORD): holds the number of items following this DWORD

	typedef struct
	{
	  BYTE type;
	  DWORD	last; //no of previous class instance (or -1 if highest one)
	  __int64 start;
	  __int64 fstart;
	  __int64 end;
	  __int64 fend;
	  DWORD	file_no;
	  DWORD	line_cntr;
	  void *dmy00;
	  int   dmy01;
      DWORD	dmy02;
	  DWORD dmy03;
	} CLASS_ITEM;

	enum
	{
	  CLASS_TYPE_SEG,
	  CLASS_TYPE_PROC,
	  CLASS_TYPE_TBL,

	  CLASS_CLOSED_FLAG = 128
	};

	NOTE: c++ aligns every table entry to 32bit!
	after the items a chain of null-terminated strings is written (for every item one name).
	class_block ends.


  label_block_id(6): "[label]"
  no_label_items(DWORD): holds the number of items following this DWORD

	typedef struct
	{
	  BYTE type; //0=def,1=binout,2=include,3=macro, bit64?buffer:file, bit128?done:broken
	  DWORD	sel_class;	//the linked class_no
	  void *dmy00;
	  int dmy01;
	  __int64 dmy02;
	  __int64 value; //the value of the label
	  DWORD	file_no; //the file_no
	  DWORD	line_cntr; //and the line where the lbl is defined
	  void *dmy03;
	} LABEL_ITEM;

	enum
	{
	  LBL_TYPE_UNDEF, //default
      LBL_TYPE_CODE,
	  LBL_TYPE_DB, LBL_TYPE_DH, LBL_TYPE_DW, LBL_TYPE_DD, LBL_TYPE_DQ,
	  LBL_TYPE_PC, LBL_TYPE_PC_FOFS,
	  LBL_TYPE_REG, LBL_TYPE_DEFINE,
	  LBL_TYPE_PREDEFINE
	};

	NOTE: c++ aligns every table entry to 32bit!
	after the items a chain of null-terminated strings is written (for every item one name).
	label_block ends.


  eof_id(5): "[end]"



new label addressing method works! its syntax goes like:
without the switch nl set:

	code SEGMENT 400000h

	  tbl TABLE

	    nop

	    a DB 0
		.
		.

		nop

	  tbl ENDT


	  main PROC

	    la a0,tbl	;or: la a0,code.tbl
					;or: la a0,@code.tbl
					;not: la a0,@tbl

		lb a1,tbl.~a(a0)
		.
		.
		.

	  main ENDP

	code ENDS

26.04.2001
added 6+2 logical operators inmath library, now it should support boolean syntax:
&&, ||, !=, ==, <=, >=, <, > (remember: TRUE=1, FALSE=0)

added a COMMENT directive to set complete parts to rem!

better error support for MACROs now!


BUG in internal release v1.4 reported by duke:
> -->
> dmalib.asm(20) : error C2040: wrong parameter type in param 3
> dmalib.asm(35) : error C2040: wrong parameter type in param 3
> dmalib.asm(55) : error C2040: wrong parameter type in param 3
> dmalib.asm(63) : error C2040: wrong parameter type in param 3
>
> It seems like it has a major problem with immidiates !?
>
> 20 andi v1,v1,100h
> 35 ori v1,v1,105h
> 55 andi v1,v1,FF1Fh
> 63 ori v1,v1,1

and another one!
> -->
> I do this :
>
> MAINFILE -->
>
> start...
> j @main
> nop
> include "xx"
> main: bla. bla
> end..
>
> XX FILE ->
>
> start...
> nop
> include "binaryfile of ie. 300h bytes".
> nop
> end...
>
> then the jump in the main code is miscalculated with the size of the binary
> file (this case 300h bytes)..

--> works in version 1.6b


03.05.2001
added r3000 instruction set (of the first PSX)

fixed a bug in instruction-class:  get_nobase(..)
now it takes labels without base, too

fixed a bug in macro-definition (macros,streams(line),directives(do_if)):
now it does not terminate a macro on an empty line

08.05.2001
created a dbgdump tool
fixed a bug in the assemble.cpp -> write_dbg_info: use now size1e instead of sizeof(...)
added %HI, %LO math operators and changed search_op(..) in intmath-class again
added ALIGN$ (same as ALIGN) and ALIGN$$ (aligns to file-offset)

09.05.2001
add EQU-directive

14.05.2001
changed math-routine::extract-value: only support values starting with a number (0..9) or $ or 0x
implemented RADIX,R3000 and R5900 directives

16.05.2001
fixed a bug in jump2target-instructions (jal). now its possible to jump in regions loaded to addr greater than 256MB

31.05.2001
another bug inside of intmath.cpp (eg.: it thought the syntax "IF (_DEBUG)" was not correct):

			if((imr->imrc = extract(sr.rest, &imr->value))!=RETC_OK)
			{	//otherwise check for label
				if(!label.validate(sr.rest)) return(false);
				imr->imrc = RETC_OK; 7//<<<<<<<<<<< we need this line to fx it

04.06.2001
added the param_type - check

17.07.2001
i wrote no comments the last time ;)


possible upgrades:
- do LOCAL-directive: searchs the parameter in the lable-table and gives him a local flag if label has the current file_no, locals are only visible when their file_no==current_no
- check if MACRO-arguments are equal and give an error in this case
- different SEGMENT types: TEXT,DATA,STEXT,SDATA
- PUBLIC directive
- MACRO inside MACRO (same for IF)
