VOOZH about

URL: https://qiita.com/ohisama@github/items/4adf841cda18142c7c07

⇱ paizaでアセンブラ #paiza.IO - Qiita


👁 Image
2

Go to list of users who liked

0

Share on X(Twitter)

Share on Facebook

Add to Hatena Bookmark

More than 1 year has passed since last update.

@ohisama@github

paizaでアセンブラ

2
Last updated at Posted at 2018-12-03

概要

思えば、paizaでアセンブラがやりたいだけの一年だった。
paizaでアセンブラ、やってみた。
pythonとgcc使った。 

サンプルコード

import subprocess
import os

def gcc():
 c_file = 'hello.s'
 test_c = """
.code64
.text
.globl main

main:
 mov $1, %rax; 
	mov $1, %rdi; 
	mov $msg, %rsi; 
	mov $12, %rdx; 
	syscall;
	mov $0, %rax; 
	syscall;

.data
msg:
	.asciz "Hello world!"
"""
 with open(c_file, 'w') as f:
 f.write(test_c)
 os.system("gcc -no-pie %s" % c_file)
 result = subprocess.Popen('./a.out', stdout = subprocess.PIPE).communicate()[0]
 for i, v in enumerate(result[ : -1].split('\n')):
 print v

if __name__ == '__main__':
 gcc()
 

成果物

以上。

2

Go to list of users who liked

0
0

Go to list of comments

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2

Go to list of users who liked

0