結果
問題 | No.353 ヘイトプラス |
ユーザー | alpha_virginis |
提出日時 | 2016-04-01 22:22:54 |
言語 | Assembler (nasm 2.16.01) |
結果 |
WA
|
実行時間 | - |
コード長 | 3,833 bytes |
コンパイル時間 | 140 ms |
コンパイル使用メモリ | 5,120 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-02 09:10:40 |
合計ジャッジ時間 | 880 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 0 ms
5,248 KB |
testcase_01 | AC | 1 ms
5,248 KB |
testcase_02 | AC | 0 ms
5,248 KB |
testcase_03 | WA | - |
testcase_04 | AC | 0 ms
5,248 KB |
testcase_05 | AC | 0 ms
5,248 KB |
testcase_06 | AC | 0 ms
5,248 KB |
testcase_07 | AC | 0 ms
5,248 KB |
testcase_08 | AC | 0 ms
5,248 KB |
ソースコード
section .data ;;; static hellow: db "Hello World!" hellow_len: equ $ - hellow section .bss common stdinbuf 1048576:16 common stdinbuf_size 8:8 common stdinbuf_seek 8:8 common stdoutbuf 1048576:16 common stdoutbuf_size 8:8 section .text global _start _start: call readstdin call setupstdout call nextInt mov r10, rax call nextInt add r10, rax mov rdi, r10 call putInt call newLine call writestdout mov rax, 60 mov rdi, 0 syscall ret readstdin: mov rax, 0 mov rdi, 0 mov rsi, stdinbuf mov rdx, 1048576 syscall mov [stdinbuf_size], rax mov rax, 0 mov [stdinbuf_seek], rax ret setupstdout: mov rax, 0 mov [stdoutbuf_size], rax ret writestdout: mov rax, 1 mov rdi, 1 mov rsi, stdoutbuf mov rdx, [stdoutbuf_size] syscall ret ;;; ; rdi : dest ;;; ; rsi : src ;;; ; rdx : size strncpy: cmp rdx, 0 jne strncpy_L1 ret strncpy_L1: mov al, [rsi] mov [rdi], al add rsi, 1 add rdi, 1 sub rdx, 1 jne strncpy_L1 ret ;;; ; dil char putChar: mov rax, stdoutbuf add rax, [stdoutbuf_size] mov [rax], dil mov rax, [stdoutbuf_size] add rax, 1 mov [stdoutbuf_size], rax ret ;;; ; rdi str ;;; ; rsi size putStr: cmp rsi, 0 jne putStr_L1 ret putStr_L1: mov rax, stdoutbuf add rax, [stdoutbuf_size] mov rdx, [stdoutbuf_size] add rdx, rsi mov [stdoutbuf_size], rdx putStr_L2: mov dl, [rdi] mov [rax], dl add rax, 1 add rdi, 1 sub rsi, 1 jne putStr_L2 ret ;;; ; rdi str ;;; ; rsi size putStrLn: push rdi push rsi call putStr pop rsi pop rdi mov dil, 10 call putChar ret ;;; ; return 8bit char nextChar: mov rdi, stdinbuf add rdi, [stdinbuf_seek] mov al, [rdi] mov rdi, [stdinbuf_seek] add rdi, 1 mov [stdinbuf_seek], rdi ret ;;; ; return (64bit unsigned int) nextInt: mov rax, 0 nextInt_L1: push rax call nextChar mov dil, al pop rax cmp dil, 48 jb nextInt_L2 cmp dil, 57 ja nextInt_L2 mov rsi, 10 mul rsi movzx rcx, dil sub rcx, 48 add rax, rcx jmp nextInt_L1 nextInt_L2: ret ;;; ; rdi 64bit int putInt: mov rcx, 0 mov rax, rdi putInt_L1: cmp rax, 0 je putInt_L2 mov rdx, 0 mov rsi, 10 div rsi push rdx add rcx, 1 jmp putInt_L1 putInt_L2: cmp rcx, 0 je putInt_L3 sub rcx, 1 pop rdi add rdi, 48 push rcx call putChar pop rcx jmp putInt_L2 putInt_L3: ret newLine: mov dil, 10 call putChar ret