It is currently Tue Oct 24, 2017 2:45 am

All times are UTC - 7 hours





Post new topic Reply to topic  [ 7 posts ] 
Author Message
PostPosted: Mon May 01, 2017 8:38 pm 
Offline
User avatar

Joined: Fri Nov 19, 2004 7:35 pm
Posts: 3944
You know how C compilers usually have inline ASM support? I was thinking of the other way around: An assembler with Inline C.

_________________
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!


Top
 Profile  
 
PostPosted: Mon May 01, 2017 8:56 pm 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 5736
Location: Canada
Could you perhaps fulfill this desire by writing in a C context but just using mostly inline assembly?


Top
 Profile  
 
PostPosted: Tue May 02, 2017 3:59 am 
Offline
User avatar

Joined: Wed Oct 16, 2013 7:55 am
Posts: 130
I feel like you can mostly achieve this with separate compilation and linking. Like, whatever C you want to "inline" would just be in a function that your assembly could call. Unless you're just taking about using C for conditionals or something.


Top
 Profile  
 
PostPosted: Tue May 02, 2017 5:12 am 
Offline
User avatar

Joined: Fri Nov 12, 2004 2:49 pm
Posts: 7235
Location: Chexbres, VD, Switzerland
This is indeed a silly idea.


Top
 Profile  
 
PostPosted: Tue May 02, 2017 5:50 am 
Offline
User avatar

Joined: Fri May 08, 2015 7:17 pm
Posts: 1787
Location: DIGDUG
Have a separate cc65 file, with only one line inside main(). Compile that, cut/paste the asm output into your asm file.

I do that sometimes.

_________________
nesdoug.com -- blog/tutorial on programming for the NES


Top
 Profile  
 
PostPosted: Tue May 02, 2017 1:10 pm 
Offline
User avatar

Joined: Sat Jan 03, 2015 5:58 pm
Posts: 367
Location: ...
Code:
lda valueptr
.extern "C"
  a=(imm)a-(3|x>>4);
.endext

I know, that's not really how compilers handle registers but it would make me very happy if it was and things like this were possible.


Top
 Profile  
 
PostPosted: Thu May 04, 2017 4:42 am 
Offline

Joined: Tue Feb 07, 2017 2:03 am
Posts: 248
If you want C like structure there is the MACROSS assembler for those who don't like 6502 ASM ;)

I would love an assembler that did assignment optimisation for me.
LDA #0
STA Addr
LDA #80
STA OtherAddr
LDA #1
STA AnotherAddr

where it works out the optimal way to store and sort the data, so if you want to set 14 values in a row and 7 else where it makes a table, splits it up into a loop of 7 with 3 load/stores, and I just write
{ size
$d000 = Logo.x,Logo.y,Logo.X+24,Logo.Y,Logo.X+48,Logo.Y,Logo.x,Logo.y+21,Logo.X+24,Logo.Y+21,Logo.X+48,Logo.Y+21,Logo.X+72,Logo.Y+21
$d027 = Colours.(White,Red,White,Red,White,Red,White)
}
and it makes the code for me.
Number of times I have optimised a store of 0, like
LDA #0
STA PlaceOne
STA PlaceTwo

Accidentally modified the fist 0 and broken something. Or had an INX further down the code...

Doing the actual code generation is easy, limited number of patterns and a easy heuristic but gaming the assembler to get the info I need was the hard part..


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group