Author Topic: CHAMP Assembler/Debugger ported to Amstrad CPC  (Read 25880 times)

0 Members and 1 Guest are viewing this topic.

Offline Bruce Abbott

  • CPC664
  • ***
  • Posts: 53
  • Country: nz
  • Liked: 84
  • Likes Given: 0
Re: CHAMP Assembler/Debugger ported to Amstrad CPC
« Reply #25 on: 21:09, 28 January 14 »
Marvellous.
In ASM mode. Pushing "D" jump quickly in Debug mode. (which is nice.)
In Debug mode. I have to push "A"+"enter" to jump in ASM mode. (which is less nice.) :)
I did have it as a 'hot' key in the debugger, but it was inconsistent with other keys that required pressing <return> to execute. I can make it 'hot' again if you like...


 
 

Offline Bruce Abbott

  • CPC664
  • ***
  • Posts: 53
  • Country: nz
  • Liked: 84
  • Likes Given: 0
Re: CHAMP Assembler/Debugger ported to Amstrad CPC
« Reply #26 on: 21:52, 28 January 14 »
Do LOAD and WRITE work like in Maxam?
WRI will work similar to MAXAM. It will store the all the code from below the line it is on to the end, but only after successful assembly.

In MAXAM 'Load' is an editor command, so I presume you mean READ? This is a tricky one. As I understand it, READ is like 'including' a file in other assemblers - it loads the source text and assembles it as if it were part of the main text. In CHAMP each source code file has its own symbol table attached, which would need to be merged with the main symbol table. The problem here is that symbols are referenced in the source by their index numbers, which will change if they are merged into the main table. One solution might be to maintain the tables separately and assemble the file 'standalone' with its symbols not visible unless 'exported'.         

Offline TFM

  • Visit the mysteries of the CPC at www.futureos.de
  • Supporter
  • 6128 Plus
  • *
  • Posts: 9.899
  • Country: aq
  • Space Chicken for FutureOS is free!
    • index.php?action=treasury
    • FutureOS - The revolution on CPC!
  • Liked: 1977
  • Likes Given: 4650
Re: CHAMP Assembler/Debugger ported to Amstrad CPC
« Reply #27 on: 21:56, 28 January 14 »
Well, if a key has no parameter it can be hot IMHO.

oh, the READ can be replaced by INCB

« Last Edit: 21:58, 28 January 14 by TFM »
TFM of FutureSoft
Also visit the CPC and Plus users favorite OS: FutureOS - The Revolution on CPC6128 and 6128Plus

Offline Bruce Abbott

  • CPC664
  • ***
  • Posts: 53
  • Country: nz
  • Liked: 84
  • Likes Given: 0
Re: CHAMP Assembler/Debugger ported to Amstrad CPC
« Reply #28 on: 22:03, 28 January 14 »
Well, if a key has no parameter it can be hot IMHO.
That's what I thought too, but in practice I found the inconsistency was disturbing. Just making 'A' a hot key might be OK (as it is the partner to D in the assembler) so I will put that back in.

 

Offline Bruce Abbott

  • CPC664
  • ***
  • Posts: 53
  • Country: nz
  • Liked: 84
  • Likes Given: 0
Re: CHAMP Assembler/Debugger ported to Amstrad CPC
« Reply #29 on: 22:16, 30 January 14 »
Et voila! CHAMP V300b

This version adds the following features:-

1. Directive  WRI "filename"  (write object code to file)

2. Math operators: "*" (multiply), "/" (divide), "%" (mod)

3. Debug command 'A' is a hotkey

Example Code:-

Code: [Select]
         ORG  &8000
         ENT  start
;
; reference only, not stored in file
uninit   DS   8
;
         WRI  "test.bin"
message  DB   "Hello World!"
;
start    CALL &BB6C
         LD   HL,&100C
         CALL &BB75
         LD   HL,message
         LD   B,start-message
loop     LD   A,(HL)
         INC  HL
         CALL &BB5A
         DJNZ loop
         CALL &BB06
         RET
;
; math test
;
three    EQU  6/2
         DW   three
fifteen  EQU  5*three
         DW   fifteen
seven    EQU  fifteen%8
         DW   seven


Offline Bruce Abbott

  • CPC664
  • ***
  • Posts: 53
  • Country: nz
  • Liked: 84
  • Likes Given: 0
Re: CHAMP Assembler/Debugger ported to Amstrad CPC
« Reply #30 on: 10:42, 01 February 14 »
Another update!

1. Improved register display - now shows memory in ASCII as well as Hex.

2. Added directive STR (string with bit 7 of last char set)

3. Added directives REPT (repeat) and REND (repeat end). 

4. Added directive '='  (assign temporary value to label).

Sample code:-
Code: [Select]
scraddr  =    &C000
pattern  =    1
         REPT 8
         LD   A,pattern
         LD   (scraddr),A
scraddr  =    scraddr+&800
pattern  =    pattern*2
         REND
         RET

WARNING!!! due to a typo, this version may throw up bogus 'duplicate label' errors!  :'( I have removed the attachment.
« Last Edit: 11:30, 02 February 14 by Bruce Abbott »

Offline Bruce Abbott

  • CPC664
  • ***
  • Posts: 53
  • Country: nz
  • Liked: 84
  • Likes Given: 0
Re: CHAMP Assembler/Debugger ported to Amstrad CPC
« Reply #31 on: 11:36, 02 February 14 »
Hopefully this one is more stable...

V3.01

1. Fixed 'duplicate label' bug introduced in V3.00e

2. Added CTRL-C (copy line), and CTRL-V (paste line) to the asm editor. CTRL-X now also copies the deleted line to the paste buffer.

3. Added CTRL-I (insert space).  Inserts a space at the cursor position, opening a gap in the line to accommodate it.

4. Changed editing to Overwrite mode in all fields except comments.

4. DEL and CLR now only affect the field (label, opcode, operand) that they are applied to. 

Next challenge,
IF
ELSE
ENDIF

Will they fit into the 540 bytes available in the ROM?





Offline Bruce Abbott

  • CPC664
  • ***
  • Posts: 53
  • Country: nz
  • Liked: 84
  • Likes Given: 0
Re: CHAMP Assembler/Debugger ported to Amstrad CPC
« Reply #32 on: 19:41, 02 February 14 »
Just a small bug-fix this time,

V3.01a - fixes stack corruption when using CTRL-X on a blank line in <insert> mode.

 

Offline Hicks

  • CPC664
  • ***
  • Posts: 74
  • Country: fr
    • Vanity
  • Liked: 125
  • Likes Given: 1
Re: CHAMP Assembler/Debugger ported to Amstrad CPC
« Reply #33 on: 11:41, 04 February 14 »
Fuck!! You're faster to release new versions than me to try them!
Feedback soon :)

Offline Bruce Abbott

  • CPC664
  • ***
  • Posts: 53
  • Country: nz
  • Liked: 84
  • Likes Given: 0
Re: CHAMP Assembler/Debugger ported to Amstrad CPC
« Reply #34 on: 11:36, 08 February 14 »
Here is V3.02, which adds:-

1. Conditional assembly
    IFD <label>; assembles following lines only if <label> is defined
    IF <expr>  ; assembles following lines only if <expr> is TRUE (not zero)
    ELSE         ; assembles following lines only if the preceding IFD or IF result was FALSE (zero)
    ENDF        ; end of IF(D)/ELSE block (note spelling!)

2. Logical math operators
       '='         ; result is TRUE (-1) if a equals b, else FALSE (0)
       '>'         ; result is TRUE if a is greater than b, else FALSE
       '<'         ; result is TRUE if a is less than b, else FALSE
 
IFD/ELSE/ENDF and IF/ELSE/ENDF blocks can be nested up to 8 levels deep.

No error will be reported if too many IF(D) or ELSE statements are used, or if there are too many or too few ENDF's!   

Logical operators can used in IF expressions, eg. 'IF label=1234' is equivalent to MAXAM's 'IFNOT label-1234'. 
 
Implementing conditional assembly was quite tricky because CHAMP creates symbols as lines are typed in, then deletes any symbols whose values are not defined during assembly. A symbol in an IF/ELSE/ENDF block may not become defined, but must not be deleted or it will disappear from the source code! To get this working properly I had to add a 'referenced' flag to each symbol, then check for symbol references in the 'dead' branches of IF/ELSE/ENDF blocks.

Test code:-
Code: [Select]
two      EQU  2
         IFD  two
         DB   "defined"
         IF   two=2
label1   DB   "2 = 2"
         ELSE
label2   DB   "2 <> 2"
         ENDF
         IF   two<3
         DB   "2 < 3"
         IF   0
         IF   1
label3   DB   "dead code"
         ENDF
         ELSE
         DB   "0 = false"
         ENDF
         DB   "2 < 3"
         ENDF
         ELSE
         DB   "undefined"
         ENDF
       
 
« Last Edit: 11:40, 08 February 14 by Bruce Abbott »

Offline Hicks

  • CPC664
  • ***
  • Posts: 74
  • Country: fr
    • Vanity
  • Liked: 125
  • Likes Given: 1
Re: CHAMP Assembler/Debugger ported to Amstrad CPC
« Reply #35 on: 15:23, 09 March 14 »
I took some times to look at your last version and make some tests. I must say that I was quite enthusiastic at the begining but was finally a little bit disappointed. I tried Champ in the optic of a "Champ vs. DAMS" battle. So there is first some advantages of using Champ compared to DAMS:

+ It's a real ROM (more free memory)
+ Moves in the source code is faster thanks to CRTL+up/down arrows
+ Better set of directives : INCB, WRI, REPT/REND/= especially.

But I was familiar with some features in DAMS who are missing in Champ:

- Only allow line cut/copy/paste and no bloc cut/copy/paste (very usefull)
- The right part of the screen is full of text, then comments at the end of a line is not avalaible (limit of 62 char by line)
- Not possible to merge 2 files by 2 successives LOAD commands (the first source is replaced by the second)
- Memory management: if I understand well, there is 4 static memory area reserved for the source (&800), symbols table (&5000), buffer (&7800), and variables (&a000). In DAMS there is a dynamic management of these areas, who are placed at the end of the assembler so it's very compact. Champ memory make me think of a "gruyere" memory :)
- Some little details... For example: more keys are needed to assemble+execute a source code.

I don't know if it's possible to improve all these points... I didn't take the time to compare the memory needed for a same Champ/DAMS source. If I understand well, the space limit for a Champ source code is &5000-&800=&4800 bytes ?
« Last Edit: 15:25, 09 March 14 by Hicks »

Offline Bruce Abbott

  • CPC664
  • ***
  • Posts: 53
  • Country: nz
  • Liked: 84
  • Likes Given: 0
Re: CHAMP Assembler/Debugger ported to Amstrad CPC
« Reply #36 on: 22:09, 20 March 14 »
some features in DAMS who are missing in Champ:

- Only allow line cut/copy/paste and no bloc cut/copy/paste (very usefull)
Due to the way that CHAMP stores source code, multi-line cut/copy/paste is complicated. I have few ideas on how to do it, but what interface (keys to press, visual effects etc.) should I use?
 
Quote
- The right part of the screen is full of text, then comments at the end of a line is not avalaible (limit of 62 char by line)
Comments waste memory, and good code doesn't need commenting ;) .

Quote
- Not possible to merge 2 files by 2 successives LOAD commands (the first source is replaced by the second)
Due to the way that CHAMP source code files are structured, they cannot be merged. However In V3.03 you can save and load code in ASCII (plain text) format, and you can insert an ASCII file into the source code with 'import file'. 

To save the source code in ASCII format, end the file name with '.a' or '.i'.  On loading, ASCII files are handled automatically - no matter what their extension. CHAMP will try to import source code from other assemblers, but you should review the imported code to make sure it was converted correctly. Any line that CHAMP doesn't understand will be converted to a comment.

Other changes in V3.03 include:-

- You can now type decimal numbers into the source code (they will be converted to their Hex equivalent when the line is entered). Hex numbers must now be preceded with "&" or "#".

-  Pressing the <COPY> key now switches between 'overwrite' and 'insert' editing (this replaces CTRL-I). The cursor flashes faster when 'insert' editing is selected.

Quote
- Memory management: if I understand well, there is 4 static memory area reserved for the source (&800), symbols table (&5000), buffer (&7800), and variables (&a000). In DAMS there is a dynamic management of these areas, who are placed at the end of the assembler so it's very compact.
I am considering combining the source code and symbol table into a single memory allocation, which would make more efficient use of memory. Variables could also be stored dynamically, but this will require converting all direct memory accesses to (IY+d) form, which is not trivial.

Quote
more keys are needed to assemble+execute a source code.
I could easily implement a 'one key' assemble+execute command, however this might be a bit dangerous. You hit the hot key to assemble and execute your code, and... it crashes, resetting the computer and erasing your work!   

Quote
If I understand well, the space limit for a Champ source code is &5000-&800=&4800 bytes?
Yes, it is limited. However the source code is very compact, so this is equivalent to a 3~4 times larger amount of plain text. Eventually I would like to use expanded memory for source code, but paging the RAM correctly may be quite tricky...
 
« Last Edit: 22:14, 20 March 14 by Bruce Abbott »

Offline mikezt

  • CPC464
  • **
  • Posts: 3
  • Country: sk
    • zeroteam.sk
  • Liked: 0
  • Likes Given: 0
Re: CHAMP Assembler/Debugger ported to Amstrad CPC
« Reply #37 on: 15:40, 12 April 14 »
Hi,
I'm new here and I just tested the Champ and it looks really good. But I find one limit that's really annoying. I can't write anything like "ld hl,25*256+8". Is it possible to extend Champ to handle this?

Offline Bruce Abbott

  • CPC664
  • ***
  • Posts: 53
  • Country: nz
  • Liked: 84
  • Likes Given: 0
Re: CHAMP Assembler/Debugger ported to Amstrad CPC
« Reply #38 on: 00:34, 15 April 14 »
Hi,
I'm new here and I just tested the Champ and it looks really good. But I find one limit that's really annoying. I can't write anything like "ld hl,25*256+8". Is it possible to extend Champ to handle this?
Anything's 'possible', but CHAMP has  a hard limit of only one math operation per instruction. You can get around this by assigning intermediate values to a variable, eg:-

block25 = 25*256
ld hl,block25+8