UNPKG

coc-nasm

Version:

This is the snippets and autocompletions for Netwide Assembler language in coc.nvim

208 lines (207 loc) 5.1 kB
{ "mov": { "prefix": "mov", "body": [ "mov ${1:target}, " ], "description": "NASM mov instruction:\nmov [target], [source]" }, "sum": { "prefix": "sum", "body": [ "section .text", "\tglobal sum", "sum:", "\tmov rax, rdi ; rax = Return value, rdi = a = argv[1]", "\tadd rax, rsi ; rsi = b = argv[2]", "\tret ; Returns rax = a + b = rdi + rsi" ], "description": [ "This is an example of a function in NASM", "Note: rax = RETURN, rdi = argv[1], rsi = argv[2], rdx = argv[3], rcx = argv[4],", "r8 = argv[5], r9 = argv[6]" ] }, "equal to a len of a string": { "prefix": "const", "body": [ "equ $-${stringlabelname}" ], "description": "Calculate a length of a string. Place this thing right after you have defined byte a string value" }, "basic pi (64-bit)": { "prefix": "pi64", "body": [ "pi dq 3.14${0}" ], "description": "Basic pi constant (64-bit)." }, "basic pi (32-bit)": { "prefix": "pi32", "body": [ "pi dd 3.14${0}" ], "description": "Basic pi constant (32-bit)." }, "function": { "prefix": "function", "body": [ "${1:functionname}:", "\tret" ], "description": "This is the syntax to establish (set up) a function in nasm." }, "newline": { "prefix": "newline", "body": [ "mov rax, 1", "mov rdi, 1", "mov rsi, 10", "mov rdx, 1", "syscall" ], "description": "This is a snippet for printing a newline in nasm" }, "printHello": { "prefix": "printHello", "body": [ "section .data", "\tmsg db \"Hello world\", 10, 0", "\tlen equ $-msg\n", "section .text", "\tglobal _start\n", "_start:", "\tmov rax, 1", "\tmov rdi, 1", "\tmov rsi, msg", "\tmov rdx, len", "\tsyscall\n", "\t;exit(0)", "\tmov rax, 60", "\txor rdi, rdi", "\tsyscall" ], "description": "An exaple program of Netwide Assembler language." }, "section": { "prefix": "sectionname", "body": [ "section ${1:section}" ], "description": "Make a section in nasm\nmov section <section>" }, "cmp": { "prefix": "cmp", "body": [ "cmp ${1:value1}, " ], "description": "Compare 2 values:\nmov [target], [source]" }, "The start of an assembly program": { "prefix": "program", "body": [ "section .data", "\t${definedata}", "${0}", "section .text", "\tglobal _start", "_start:", "\t${0}" ], "description": "Automatically build the basical start of nasm language" }, "exit": { "prefix": "exit", "body": [ "mov rax, 60", "mov rdi, ${1:exitcode}", "syscall" ], "description": "The code to exit the program with your custom exit code" }, "include directive": { "prefix": "include", "body": [ "include \"${1:file}\"" ], "description": "Include a nasm file" }, "jge": { "prefix": "jge", "body": [ "jge ${1:label}" ], "description": "Jump to a label if in cmp, the previous label is greater than or equal to the target value" }, "jmp": { "prefix": "jmp", "body": [ "jmp ${1:label}" ], "description": "Jump to a label without any conditions" }, "jne": { "prefix": "jne", "body": [ "jne ${1:label}" ], "description": "Jump to a label if in cmp, the previous label is not equal to the target value" }, "je": { "prefix": "je", "body": [ "je ${1:label}" ], "description": "Jump to a label if in cmp, the previous label is equal to the target value" }, "jle": { "prefix": "jle", "body": [ "jle ${1:label}" ], "description": "Jump to a label if in cmp, the previous label is lower than or equal to the target value" }, "jg": { "prefix": "jg", "body": [ "jg ${1:label}" ], "description": "Jump to a label if in cmp, the previous label is greater than the target value" }, "jl": { "prefix": "jl", "body": [ "jl ${1:label}" ], "description": "Jump to a label if in cmp, the previous label is lower than the target value" }, "call": { "prefix": "call", "body": [ "call ${functionname}" ], "description": "call a function" }, "Basic script for outputing a variable/label": { "prefix": "basicoutput", "body": [ "mov rax, 1", "mov rdi, 1", "mov rsi, ${messagevalue}", "mov rdx, ${len}", "syscall" ], "description": "This script shows how to print a label basically" }, "Basic script for inputing a variable/label": { "prefix": "basicinput", "body": [ "mov rax, 0", "mov rdi, 0", "mov rsi, ${buffervariable} ; ", "mov rdx, 30", "syscall" ], "description": "This script shows how to make a user input by reading the sidin.\nYou must make an uninitialized memory using section .bss and resb first" } }