Submission #54766528
Source Code Expand
Copy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
bits 64
section .note.GNU-stack
section .text
; int read_char(void)
; 1文字(バイト)読み込み、文字コードを返す
read_char:
xor eax, eax
xor edi, edi
lea rsi, [rsp - 8]
mov edx, 1
syscall
cmp eax, 1
jne read_char_error
mov al, [rsp - 8]
ret
read_char_error:
mov eax, -1
ret
; void print_char(int c)
; 1文字(バイト)出力する
print_char:
mov [rsp - 8], edi
mov eax, 1
mov edi, eax
lea rsi, [rsp - 8]
mov edx, eax
syscall
ret
; int read_int(void)
; 十進数の非負整数を1個読み込む
read_int:
push rbp
mov rbp, rsp
sub rsp, 16
mov [rbp - 8], ebx
xor ebx, ebx
read_int_loop:
call read_char
cmp eax, '0'
jl read_int_end
cmp eax, '9'
jg read_int_end
imul ebx, ebx, 10
sub eax, '0'
add ebx, eax
jmp read_int_loop
read_int_end:
mov eax, ebx
mov ebx, [rbp - 8]
leave
ret
; void print_int(int value)
; 非負整数を十進数で出力する
print_int:
mov eax, edi
mov rsi, rsp
mov ecx, 10
print_int_convert_loop:
cdq
idiv ecx
add dl, '0'
dec rsi
mov [rsi], dl
test eax, eax
jnz print_int_convert_loop
mov eax, 1
mov edi, eax
mov rdx, rsp
sub rdx, rsi
syscall
ret
global main
main:
push rbp
mov rbp, rsp
sub rsp, 16
; 3個の数値の和を出力する
call read_int
mov [rbp - 8], eax
call read_int
add [rbp - 8], eax
call read_int
add eax, [rbp - 8]
mov edi, eax
call print_int
; 区切りとなる空白を出力する
mov edi, ' '
call print_char
; 文字列を1行出力する
main_loop:
call read_char
mov [rbp - 16], al
mov edi, eax
call print_char
cmp byte [rbp - 16], `\n`
jne main_loop
; 終了する
mov eax, 60
xor edi, edi
syscall
Submission Info
| Submission Time |
|
| Task |
PracticeA - Welcome to AtCoder |
| User |
mikecat |
| Language |
Assembly x64 (NASM 2.15.05) |
| Score |
100 |
| Code Size |
1758 Byte |
| Status |
AC |
| Exec Time |
1 ms |
| Memory |
1628 KB |
Judge Result
| Set Name |
All |
| Score / Max Score |
100 / 100 |
| Status |
|
| Set Name |
Test Cases |
| All |
00_rnd_01.txt, 00_rnd_02.txt, 00_rnd_03.txt, 00_rnd_04.txt, 00_rnd_05.txt, 00_sample_1.txt, 00_sample_2.txt |
| Case Name |
Status |
Exec Time |
Memory |
| 00_rnd_01.txt |
AC |
1 ms |
1504 KB |
| 00_rnd_02.txt |
AC |
0 ms |
1504 KB |
| 00_rnd_03.txt |
AC |
1 ms |
1508 KB |
| 00_rnd_04.txt |
AC |
0 ms |
1504 KB |
| 00_rnd_05.txt |
AC |
1 ms |
1616 KB |
| 00_sample_1.txt |
AC |
0 ms |
1628 KB |
| 00_sample_2.txt |
AC |
0 ms |
1448 KB |