Task: | Sanalista |
Sender: | hltk |
Submission time: | 2020-09-30 08:43:31 +0300 |
Language: | Assembly |
Status: | READY |
Result: | 100 |
group | verdict | score |
---|---|---|
#1 | ACCEPTED | 100 |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.00 s | details |
#2 | ACCEPTED | 0.00 s | details |
#3 | ACCEPTED | 0.00 s | details |
Code
%macro r1_push 0 ; push registers except raxpush rbxpush rcxpush rdxpush r8push r9push r10push r11%endmacro%macro r1_pop 0 ; pop registers except raxpop r11pop r10pop r9pop r8pop rdxpop rcxpop rbx%endmacro%macro r_push 0 ; push registers including raxpush raxr1_push%endmacro%macro r_pop 0 ; pop registers including raxr1_poppop rax%endmacro%define N 32100section .bssibuf resb Nobuf resb Ntaulu resq 256section .textglobal _start_start:; read ibufxor rax, raxxor rdi, rdimov rsi, ibufmov rdx, Nsyscallmov rsi, ibufmov rdi, obuf ; älä sotke rdi:tä..call stoimov rcx, raxxor r9, r9.s:push rcxmov rcx, tauluadd rcx, 122*8mov rax, tauluadd rax, 97*8.ss:mov qword [rax], 0lea rax, [rax + 8]cmp rax, rcxjle .ssjmp .nxtchr_b.nxtchr_a:inc rsi.nxtchr_b:xor rax, raxlodsbcmp al, 97jl .nxtchr_acmp al, 122jg .nxtchr_a.chkchr_a:inc qword [taulu + rax * 8]xor rax, raxlodsbcmp al, 97jl .chkchr_bcmp al, 122jg .chkchr_bjmp .chkchr_a.chkchr_b:mov rcx, tauluadd rcx, 122*8mov rax, tauluadd rax, 97*8mov r8, 1.chkres_a:mov rbx, [rax]and rbx, 1cmp rbx, 0je .chkres_bmov r8, 0.chkres_b:lea rax, [rax + 8]cmp rax, rcxjle .chkres_aadd r9, r8pop rcxdec rcxcmp rcx, 0jg .smov rax, r9call printimov rax, 0xastosb; output obufsub rdi, obufmov rdx, rdimov rdi, 1mov rax, 1mov rsi, obufsyscall; exit syscallmov rax, 0x3cxor rdi, rdisyscallstoi: ; reads in integer from rsi s buffer and outputs it to raxr1_pushxor r8,r8mov r9, 1.a_stoi:xor rax, raxlodsbcmp al, 45jne .b_stoimov r9, -1jmp .a_stoi.b_stoi:cmp al, 32je .c_stoicmp al, 10je .c_stoicmp al, 0je .c_stoisub al, 48mov rdx, 10imul r8, rdxadd r8, raxjmp .a_stoi.c_stoi:mov rax, r8imul rax, r9r1_popretprinti: ; outputs an integer rdi s bufferpush raxr1_pushxor rbx, rbxcmp rax, 0jnl .a_printiimul rax, -1push raxmov rax, 45stosbpop rax.a_printi:xor rdx, rdxmov rcx, 10idiv rcxadd rdx, 48push rdxinc rbxcmp rax, 0jne .a_printimov rcx, rbx.b_printi:pop raxstosbloop .b_printimov rax, rdir1_popmov rdi, raxpop raxret
Test details
Test 1
Verdict: ACCEPTED
input |
---|
1000 korvata sopimusaika nuhatartunta korttiautomaatti ... |
correct output |
---|
15 |
user output |
---|
15 |
Test 2
Verdict: ACCEPTED
input |
---|
1000 pub hansikaslokero erikoisvalmisteinen unijukka ... |
correct output |
---|
42 |
user output |
---|
42 |
Test 3
Verdict: ACCEPTED
input |
---|
1000 haapalastu toipumisaika mustalaiskieli taidelainaamo ... |
correct output |
---|
70 |
user output |
---|
70 |