[Article] Cross-dev under Linux
France krusty - 20 January 2012 - 13:25:41 195 posts
Read the article

I am in a transition period where I am moving from sjasmplus to another assembler.
Some of my projects use several instructions per lines, which is not recognized by all the assembler.

You'll find in this message a function, allowing to change a line formatted like that:

inst 1 : inst 2 : inst 3

into something like that:

inst 1
inst 2
inst 3


If you want to change one line, type (of course autocompletion allow you to type just the first characters of the function):

:call CPCSplitInstructionsInSeveralLines()


If you want to change all the similar occurence in the file, type:

:%call CPCSplitInstructionsInSeveralLines()



Here is the function to add in the file ~/.vim/ftplugin/z80.vim


" Split a line with several commands in several independant lines
" (allow to easily convert files from one assembly language to another one)
function! CPCSplitInstructionsInSeveralLines() range

let lnum = a:firstline
let s:linecounter = 0

while lnum <= a:lastline
let s:line = getline(lnum + s:linecounter)

" Works only on right lines
if -1 == match(s:line, '.*:.*')
let lnum = lnum + 1
continue
endif


let s:instructions = split(s:line, ':')
let s:empty = matchstr(s:line, '^\s*')
let s:code = substitute(s:line, '^\s*\(.*$\)', '\1', '')
let s:i=1


call append(lnum + s:linecounter, s:empty.'; '.s:code.' {{{ Automatic expanding')
" Copy each instruction
for instruction in s:instructions
if s:i == 1
call append(lnum+s:i+s:linecounter, instruction)
else
call append(lnum+s:i+s:linecounter, s:empty.instruction)
endif
let s:i=s:i +1
endfor
call append(lnum+s:i+s:linecounter, s:empty.'; }}}')

" Delete line
exec (lnum+s:linecounter)."d"

let s:linecounter = s:linecounter + s:i
let lnum = lnum + 1
endwhile
endfunction
France krusty - 23 January 2012 - 22:41:41 195 posts
I will not more pollute the forum with this subject which interest nobody except me ;)

I have published a repository with my CPC editor configuration which will evolve with my needs.
If one day, someone is interested, it is here:
https://github.com/rgiot/vim-z80-democoding
France CloudStrife - 24 January 2012 - 00:14:29 128 posts
You're not the only one interested :) Just I don't have the time :(
France PulkoMandy - 24 January 2012 - 19:57:34 452 posts
Why another repository ? Why not use cpcsdk one ?

And yes, we are reading :)
France krusty - 24 January 2012 - 20:40:39 195 posts
@pulko:
- I am in a period were I prefer small repositories for one task, than big repositories with tons of things.
- I want to address this work to any people coding in z80, not only CPC demosceners
- git is marvelous
- do not hesitate to fork it if you want
- I fell ridiculous with my small number of commits on cpcsdk ;)

@cloud:
- yes, we are three to be interested ;) Maybe 3 is a bigger figure than half of the number of real active cpc sceners ;)
France krusty - 08 February 2012 - 13:34:39 195 posts
Useful tip from Pulko, hidden in the intraweb.
I'll probably use it

http://pulkomandy.lexinfo.fr/_/_Development/_Smarter%20vim%20filetype%20detection
France PulkoMandy - 08 February 2012 - 18:38:27 452 posts
I didn't expect anyone else to do more than z80 :)
France krusty - 20 February 2012 - 12:25:14 195 posts
VIM is now able to detect minor z80 syntax error using the syntastic plugin (repository version):
https://github.com/scrooloose/syntastic

The z80 parser must be installed before
https://github.com/rgiot/pycpcdemotools/blob/master/cpcdemotools/source_checker/z80_syntax_checker.py

Fell free to improve the process
Online: OffseT
Kill All Humans!