v420v / vas Goto Github PK
View Code? Open in Web Editor NEWx86-64 Assembler written in V
License: MIT License
x86-64 Assembler written in V
License: MIT License
# ./vas main.s
.global _start
.section .text, "ax"
_start:
pushq %rbp
movq %rsp, %rbp
subq $16, %rsp
movq $1, %rax
movq $1, %rdi
leaq msg(%rip), %rsi
movq $13, %rdx
syscall
movq $60, %rax
movq $0, %rdi
syscall
msg:
.string "Hello, world!"
In the current assembler being developed, unnecessary relocation occurs with the "msg(%rip)" operation, even though the "msg" label is defined in the same section as the instruction/operation.
└─$ readelf -r main.o
再配置セクション '.rela.text' at offset 0x110 contains 1 entry:
オフセット 情報 型 シンボル値 シンボル名 + 加数
000000000019 000100000002 R_X86_64_PC32 0000000000000000 .text + 32
The assembler should not perform unnecessary relocation for "msg(%rip)" when the "msg" label is defined in the same section as the instruction/operation. This is because the address of the "msg" label can be determined at assembly time and does not need to be resolved at runtime. Therefore, the assembled code should not contain any relocation entries for "msg(%rip)" in this case.
Report an error when a macro expansion enters an infinite loop.
.macro FOO
movq $60, %rax
FOO
.end
FOO
vas doesn't support SSE registers yet.
https://en.wikibooks.org/wiki/X86_Assembly/SSE
%xmm0, %xmm1, ... , %xmm15
The .align directive causes the next data generated to be aligned modulo integer bytes. Integer must be a positive integer expression and must be a power of 2.
.align 8
...
...
...
Declares the type of symbol
.type main, @function
.global main
main:
retq
...
...
...
Describe the bug
# Hello world!
.global _start
.section .data, "wa"
msg:
.string "Hello, world!\n"
.section .text, "ax"
_start:
pushq %rbp
movq %rsp, %rbp
subq $16, %rsp
callq test1 # something wrong with the relocation process here.
movq $1, %rax
movq $1, %rdi
leaq msg(%rip), %rsi
movq $14, %rdx
syscall
movq $60, %rax
movq $0, %rdi
syscall
.section something, "ax"
.global test1
test1:
retq
Expected behavior
┌──(ibuki🧀kali)-[~/test/vas]
└─$ readelf -r as.o
再配置セクション '.rela.text' at offset 0x120 contains 2 entries:
オフセット 情報 型 シンボル値 シンボル名 + 加数
000000000009 000400000004 R_X86_64_PLT32 0000000000000000 test1 - 4
00000000001e 000100000002 R_X86_64_PC32 0000000000000000 .data - 4
Current Behavior
┌──(ibuki🧀kali)-[~/test/vas]
└─$ readelf -r test.o
再配置セクション '.rela.text' at offset 0x163 contains 2 entries:
オフセット 情報 型 シンボル値 シンボル名 + 加数
000000000009 000300000004 R_X86_64_PLT32 0000000000000000 msg - 4
00000000001e 000200000002 R_X86_64_PC32 0000000000000000 .data - 4
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.