Hi,
I often work with assembly and one strong reason that prevents me from
changing existing assembly code is the difficulty and inconvenience to
track stack state when moving around statements. In that respect, it
would be really great to have a vim plugin that would show the stack
state at each assembler instruction.
Here's an algorithm that would work:
1.) First mark the first assembler statement that the stack recording
starts (e.g. the entry point to a function)
2.) When cursor is moved over to another statement after that, the vim
plugin would automatically parse the statements from the first mark
and display the data pushed to stack.
3.) Furthermore, the distance to various locations on the stack are
displayed, so that the correct offset can be added/subtracted from the
current stack pointer to reach those locations, without the need to
calculate from head.
4.) This would greatly simplify the life of low-level C/assembler/
embedded programmers. I believe assembly programming would become a
lot simpler.
As an example I have an irq exception entry (ARM assembler):
747 @ Stack state: |LR_IRQ<-|{original SP_SVC}|
748 ldr r14, [r0, #IRQ_SPSR] @ Load irq spsr.
749 is_psr_usr r14 @ Check previous mode
750 str r14, [sp, #-64]!
751 bne save_svc
752 save_user:
753 stmfd sp, {r1-r14}^
754 @ Stack state: |r1|...|r12|SP_USR|LR_USR|LR_IRQ{PC
return address}<-|{original SP_SVC}|
755 @ Stack state: |spsr<-|<emtpy>|r1|...|r12|SP_USR|LR_USR|
LR_IRQ{PC return address}<-|{original SP_SVC}|
756 save_svc:
757 @ Stack state: |LR_IRQ<-|{original SP_SVC}|
758 add sp, sp, #4
759 @ Stack state: |LR_IRQ|{original SP_SVC}<-|
760 str sp, [sp, #-????
761 stmfd sp, {r1-r12}
762 @ Stack state: |r1|...|r12|SP_USR|LR_USR|LR_IRQ{PC
return address}<-|{original SP_SVC}|
See each stack state: comment that I wrote myself by calculating stack
positioning on every statement. Also see the ???? on line 760. I want
to store a value in a location relative to current SP. But every time
I change this code, I have to re-calculate positions from my head. Its
highly error prone.
I can probably write some nice python script that can handle this, but
I never wrote a vim plugin. If vim has its own scripting language for
plugins it would be pretty difficult for me to use it to parse the
assembler like this, but probably I can create something useful with
python.
What do you think? If someone would like to join me in making this
plugin happen, we can work together and push the work to public with a
vim-friendly license so everyone can use it.
Thanks,
Bahadir
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php