LoginSignup
1
0

More than 1 year has passed since last update.

paiza.ioでelixir その129

Last updated at Posted at 2022-12-08

概要

paiza.ioでelixirやってみた。
練習問題やってみた。

練習問題

アセンブラでcpuidを求めよ。

サンプルコード

File.write "hello.s", """


.code64
.text
.globl main
main:
	lea	 	msg(%rip), %rdi
	xorl	%eax, %eax
	cpuid
	movl	%ebx, (%rdi)
	movl	%edx, 4(%rdi)
	movl	%ecx, 8(%rdi)
	mov   	$1, %rax;
	mov   	$1, %rdi;
	mov   	$msg, %rsi;
	mov   	$12, %rdx;
	syscall;
	mov   	$0, %rax;
	syscall;
.data
msg:
	.asciz "Hello world!"
"""

{result, 0} = System.shell("gcc -no-pie hello.s")
IO.puts result

{result, 0} = System.shell("./a.out")
IO.puts result




実行結果


GenuineIntel

成果物

以上。

1
0
0

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
1
0