Blend C4ASM

Go To Last Post
3 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

There is a nice tool with full java sources which enables C like flow constructs in your ASM sources. Unfortunately AVR is not yet supported, but according to what I saw adding new processors is just a matter of extending existing XML file 8). This is how high level C constructs can look in ASM source:

// C form
if( A==2 ) { ; Expression Code
  ; This is the PASS Code Block
} else {
  ; This is the ELSE Code Block
}

; Assembly form
START:
  ; Insert A==2 Expression Code Here
PASS:
  ; Insert PASS Code Block Here
  JMP OUT
FAIL:
  ; Insert ELSE Code Block Here
OUT:
// C form
do {
  ; This is the PASS Code Block
} while( A==2 ) ; Expression Code

; Assembly form
START:
PASS:
  ; Insert PASS Code Block Here
  ; Insert A==2 Expression Code Here
FAIL:
OUT:
// C form
while( A==2 ) {  ; Expression Code
  ; This is the PASS Code Block
}

; Assembly form
START:
  ; Insert A==2 Expression Code Here
PASS:
  ; Insert PASS Code Block Here
  JMP START
FAIL:
OUT:

http://computerarcheology.com/bl...
http://computerarcheology.com/bl...

Call it like this:
java -classpath . Blend GAP.ASM GAPLOLEV.ASM

Just imagine this as a preprocessor extension for AVR Studio...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

which enables C like flow constructs in your ASM sources.

That's called a C compiler isn't it? ;-)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

clawson wrote:
Quote:

which enables C like flow constructs in your ASM sources.
That's called a C compiler isn't it? ;-)

Not quite :wink:. Although expression like (A==2) && (Y!=4 || X<8 ) is allowed, you still deal directly with registers, without any of the simple types...

Look at how some comparison operators are defined in XML for 6502:

- 
-  
- 
   
   
   
-  
- 
  @COMPARE@;BEQ @PASS@;JMP @FAIL@ 
  @COMPARE@;BNE @FAIL@;JMP @PASS@ 
  
- 
  @COMPARE@;BNE @PASS@;JMP @FAIL@ 
  @COMPARE@;BEQ @FAIL@;JMP @PASS@ 
  
-  
-  
- 
  @COMPARE@;BCC @PASS@;JMP @FAIL@ 
  @COMPARE@;BCS @FAIL@;JMP @PASS@ 
  
- 
  @COMPARE@;BCS @PASS@;JMP @FAIL@ 
  @COMPARE@;BCC @FAIL@;JMP @PASS@