-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
adds basic legv8 snippets #8
Open
JoaoLira-br
wants to merge
5
commits into
patrickdemers6:main
Choose a base branch
from
JoaoLira-br:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
f2ac751
adds basic legv8 snippets
JoaoLira-br 6a4fcfb
improves formatting, adds new snippets and adjusts the previous snippets
JoaoLira-br f7ac2f6
Adds and Refactors more snippets
JoaoLira-br 48bf018
Reformats loop snippets
JoaoLira-br 13a395b
Reformats add, addi, sub, subi, for_incremental and for_decremental s…
JoaoLira-br File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,224 @@ | ||
{ | ||
"set register": { | ||
"prefix": "sreg", | ||
"body": ["ADD ${1:Rd}, XZR, ${2:Rm}", "$3"], | ||
"description": "R[d] = R[m]. Set one register (Rd) to the value of another (Rm)." | ||
}, | ||
"increment register (immediate)": { | ||
"prefix": "addi", | ||
"body": ["ADDI ${1:Rd}, ${1:Rd}, #${2:Imm}", "$3"], | ||
"description": "R[Rd] = R[Rd] + Imm. Increment the Rd register by the value of Imm" | ||
}, | ||
"decrement register (immediate)": { | ||
"prefix": "subi", | ||
"body": ["SUBI ${1:Rd}, ${1:Rd}, #${2:Imm}", "$3"], | ||
"description": "R[Rd] = R[Rd] + Imm. Decrement the Rd register by the value of Imm." | ||
}, | ||
"increment register": { | ||
"prefix": "add", | ||
"body": ["ADD ${1:Rd}, ${1:Rd}, ${2:Rm}", "$3"], | ||
"description": "R[Rd] = R[Rd] + R[Rm]. Increment one register (Rd) with the value of another register (Rm)." | ||
}, | ||
"decrement register": { | ||
"prefix": "sub", | ||
"body": ["SUB ${1:Rd}, ${1:Rd}, ${2:Rm}", "$3"], | ||
"description": "R[Rd] = R[Rd] - R[Rm]. Decrement one register (Rd) with the value of another register (Rm). " | ||
}, | ||
|
||
"stack manipulation with 1 register": { | ||
"prefix": "stk1", | ||
"body": [ | ||
"// storing registers in stack before changing them", | ||
"SUBI SP, SP, #16 // make room on stack (SP) for 2 registers", | ||
"STUR LR, [SP, #8] // store return adress (LR) of procedure", | ||
"STUR $reg1, [SP, #0] // store $reg1", | ||
"// body of the procedure", | ||
"$body", | ||
"// restoring saved registers from stack", | ||
"LDUR $reg1, [SP, #0] // restore $reg1", | ||
"LDUR LR, [SP, #8] // restore LR", | ||
"ADDI SP, SP, #16 // restore previous space on stack" | ||
], | ||
"description": "Use this to save 2 registers in the Stack, including the return address of the procedure (where the procedure was called)" | ||
}, | ||
"stack manipulation with 2 registers": { | ||
"prefix": "stk2", | ||
"body": [ | ||
"// storing registers in stack before changing them", | ||
"SUBI SP, SP, #24 // make room on stack (SP) for 2 registers", | ||
"STUR LR, [SP, #16] // store return adress (LR) of procedure", | ||
"STUR $reg1, [SP, #8] // store $reg1", | ||
"STUR $reg2, [SP, #0] // store $reg2", | ||
"// body of the procedure", | ||
"$body", | ||
"// restoring saved registers from stack", | ||
"LDUR $reg2, [SP, #0] // restore $reg2", | ||
"LDUR $reg1, [SP, #8] // restore $reg1", | ||
"LDUR LR, [SP, #16] // restore LR", | ||
"ADDI SP, SP, #24 // restore previous space on stack" | ||
], | ||
"description": "Use this to save 3 registers in the Stack, including the return address of the procedure (where the procedure was called)" | ||
}, | ||
"stack manipulation with 3 registers": { | ||
"prefix": "stk3", | ||
"body": [ | ||
"// storing registers in stack before changing them", | ||
"SUBI SP, SP, #32 // make room on stack (SP) for 2 registers", | ||
"STUR LR, [SP, #24] // store return adress (LR) of procedure", | ||
"STUR $reg1, [SP, #16] // store $reg1", | ||
"STUR $reg2, [SP, #8] // store $reg2", | ||
"STUR $reg3, [SP, #0] // store $reg3", | ||
"// body of the procedure", | ||
"$body", | ||
"// restoring saved registers from stack", | ||
"LDUR $reg3, [SP, #0] // restore $reg3", | ||
"LDUR $reg2, [SP, #8] // restore $reg2", | ||
"LDUR $reg1, [SP, #16] // restore $reg1", | ||
"LDUR LR, [SP, #24] // restore LR", | ||
"ADDI SP, SP, #32 // restore previous space on stack" | ||
], | ||
"description": "Use this to save 4 registers in the Stack, including the return address of the procedure (where the procedure was called)" | ||
}, | ||
"stack manipulation with 4 registers": { | ||
"prefix": "stk4", | ||
"body": [ | ||
"// storing registers in stack before changing them", | ||
"SUBI SP, SP, #40 // make room on stack (SP) for 2 registers", | ||
"STUR LR, [SP, #32] // store return adress (LR) of procedure", | ||
"STUR $reg1, [SP, #24] // store $reg1", | ||
"STUR $reg2, [SP, #16] // store $reg2", | ||
"STUR $reg3, [SP, #8] // store $reg3", | ||
"STUR $reg4, [SP, #0] // store $reg4", | ||
"// body of the procedure", | ||
"$body", | ||
"// restoring saved registers from stack", | ||
"LDUR $reg4, [SP, #0] // restore $reg4", | ||
"LDUR $reg3, [SP, #8] // restore $reg3", | ||
"LDUR $reg2, [SP, #16] // restore $reg2", | ||
"LDUR $reg1, [SP, #24] // restore $reg1", | ||
"LDUR LR, [SP, #32] // restore LR", | ||
"ADDI SP, SP, #40 // restore previous space on stack" | ||
], | ||
"description": "Use this to save 5 registers in the Stack, including the return address of the procedure (where the procedure was called)" | ||
}, | ||
"stack manipulation with 5 registers": { | ||
"prefix": "stk5", | ||
"body": [ | ||
"// storing registers in stack before changing them", | ||
"SUBI SP, SP, #48 // make room on stack (SP) for 2 registers", | ||
"STUR LR, [SP, #40] // store return adress (LR) of procedure", | ||
"STUR $reg1, [SP, #32] // store $reg1", | ||
"STUR $reg2, [SP, #24] // store $reg2", | ||
"STUR $reg3, [SP, #16] // store $reg3", | ||
"STUR $reg4, [SP, #8] // store $reg4", | ||
"STUR $reg5, [SP, #0] // store $reg5", | ||
"// body of the procedure", | ||
"$body", | ||
"// restoring saved registers from stack", | ||
"LDUR $reg5, [SP, #0] // restore $reg5", | ||
"LDUR $reg4, [SP, #8] // restore $reg4", | ||
"LDUR $reg3, [SP, #16] // restore $reg3", | ||
"LDUR $reg2, [SP, #24] // restore $reg2", | ||
"LDUR $reg1, [SP, #32] // restore $reg1", | ||
"LDUR LR, [SP, #40] // restore LR", | ||
"ADDI SP, SP, #48 // restore previous space on stack" | ||
], | ||
"description": "Use this to save 6 registers in the Stack, including the return address of the procedure (where the procedure was called)" | ||
}, | ||
"stack manipulation with 6 registers": { | ||
"prefix": "stk6", | ||
"body": [ | ||
"// storing registers in stack before changing them", | ||
"SUBI SP, SP, #56 // make room on stack (SP) for 2 registers", | ||
"STUR LR, [SP, #48] // store return adress (LR) of procedure", | ||
"STUR $reg1, [SP, #40] // store $reg1", | ||
"STUR $reg2, [SP, #32] // store $reg2", | ||
"STUR $reg3, [SP, #24] // store $reg3", | ||
"STUR $reg4, [SP, #16] // store $reg4", | ||
"STUR $reg5, [SP, #8] // store $reg5", | ||
"STUR $reg6, [SP, #0] // store $reg6", | ||
"// body of the procedure", | ||
"$body", | ||
"// restoring saved registers from stack", | ||
"LDUR $reg6, [SP, #0] // restore $reg6", | ||
"LDUR $reg5, [SP, #8] // restore $reg5", | ||
"LDUR $reg4, [SP, #16] // restore $reg4", | ||
"LDUR $reg3, [SP, #24] // restore $reg3", | ||
"LDUR $reg2, [SP, #32] // restore $reg2", | ||
"LDUR $reg1, [SP, #40] // restore $reg1", | ||
"LDUR LR, [SP, #48] // restore LR", | ||
"ADDI SP, SP, #56 // restore previous space on stack" | ||
], | ||
"description": "Use this to save 7 registers in the Stack, including the return address of the procedure (where the procedure was called)" | ||
}, | ||
"stack manipulation with 7 registers": { | ||
"prefix": "stk7", | ||
"body": [ | ||
"// storing registers in stack before changing them", | ||
"SUBI SP, SP, #64 // make room on stack (SP) for 2 registers", | ||
"STUR LR, [SP, #56] // store return adress (LR) of procedure", | ||
"STUR $reg1, [SP, #48] // store $reg1", | ||
"STUR $reg2, [SP, #40] // store $reg2", | ||
"STUR $reg3, [SP, #32] // store $reg3", | ||
"STUR $reg4, [SP, #24] // store $reg4", | ||
"STUR $reg5, [SP, #16] // store $reg5", | ||
"STUR $reg6, [SP, #8] // store $reg6", | ||
"STUR $reg7, [SP, #0] // store $reg7", | ||
"// body of the procedure", | ||
"$body", | ||
"// restoring saved registers from stack", | ||
"LDUR $reg7, [SP, #0] // restore $reg7", | ||
"LDUR $reg6, [SP, #8] // restore $reg6", | ||
"LDUR $reg5, [SP, #16] // restore $reg5", | ||
"LDUR $reg4, [SP, #24] // restore $reg4", | ||
"LDUR $reg3, [SP, #32] // restore $reg3", | ||
"LDUR $reg2, [SP, #40] // restore $reg2", | ||
"LDUR $reg1, [SP, #48] // restore $reg1", | ||
"LDUR LR, [SP, #56] // restore LR", | ||
"ADDI SP, SP, #64 // restore previous space on stack" | ||
], | ||
"description": "Use this to save 8 registers in the Stack, including the return address of the procedure (where the procedure was called)" | ||
}, | ||
"incremental for loop": { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A few suggestions for the loop.
"increasing for loop": {
"prefix": "for_increasing",
"body": [
"${1:loop name}_loop:",
"// if counter ($2) greater than or equal to limit ($3), then exit",
"SUBS XZR, ${2:counter}, ${3:upper_limit}",
"B.GE ${1}_loop_done",
"// loop body",
"",
"// increment counter ($2) by $4",
"ADDI $2, $2, #${4:increment_amount}",
"B $1_loop",
"$1_loop_done:"
],
"description": "Creates a for loop from counter to upper_limit. for (; counter < upper_limit; counter += increment_amount); Note: the counter and array size must be initialized before the loop."
}, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree, It`s Implemented |
||
"prefix": "for_incremental", | ||
"body": [ | ||
"${1:loop name}_loop:", | ||
"//comparing pointer to array length; if equal then exit", | ||
"SUBS XZR, ${2:counter}, ${3:upper_limit}", | ||
"B.GE ${1}_loop_exit", | ||
"//loop body", | ||
" ", | ||
"// increment counter ($2) by $4", | ||
"ADDI $2, $2, #${4:increment_amount}", | ||
"B $1_loop", | ||
"${1}_loop_exit:" | ||
], | ||
"description": "Creates a for loop that increments from counter to upper_limit. Equivalent In C: for (counter = <value>; counter < upper_limit; counter += increment_amount){ //loop body }. Note: the counter and upper limit must be initialized before the loop" | ||
}, | ||
"decremental for loop": { | ||
"prefix": "for_decremental", | ||
"body": [ | ||
"${1:loop name}_loop:", | ||
"//comparing pointer to 0; if equal then exit", | ||
"CBZ ${2:counter}, ${1}_loop_exit", | ||
"//loop body", | ||
" ", | ||
"// decrement pointer", | ||
"SUBI $2, $2, #${3:decrement_amount}", | ||
"B ${1}_loop", | ||
"${1}_loop_exit:" | ||
], | ||
"description": "Creates a for loop that decrements from counter to 0. Equivalent in C: for (counter = <value>; counter > 0; counter --){ //loop body }. Note: the counter must be initialized before the loop" | ||
}, | ||
|
||
"return statement": { | ||
"prefix": "br", | ||
"body": ["BR LR"], | ||
"description": "returns to the caller (LR)" | ||
}, | ||
"call procedure": { | ||
"prefix": "bl", | ||
"body": ["BL ${1:procedure name}"], | ||
"description": "calls a procedure with the given name" | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add description for all of them. Also try to make it easy to realize what the command does.
So if the code inserted is something to the effect of
ADDI reg, reg, #1
, show how to think of it in basic math terms, likereg = reg + 1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good comment! It`s implemented
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome! In addition to the math part, could you add a small text description? Also, having the description and placeholder text be the same may be useful. Such as:
Thoughts?