coreBugZJ

此 blog 已弃。

SPOJ 1. Life, the Universe, and Everything

1. Life, the Universe, and Everything

Your program is to use the brute-force approach in order to find the Answer to Life, the Universe, and Everything. More precisely... rewrite small numbers from input to output. Stop processing input after reading in the number 42. All numbers at input are integers of one or two digits.

Example

Input:
1
2
88
42
99
Output:
1
2
88
我的代码:
section .bss
        buf : resb 0x4
        len : resd 0x1
section .text
        global  _start
_start : 
        xor eax, eax
        mov [len], eax
        mov [buf], al
        mov [buf+1], al
LOOP_INPUT :
        call INPUT
        cmp al, 0xa
        jne LOOP_INPUT
        mov al, [buf]
        cmp al, '4'
        jne LOOP_JUDGE_E
        mov al, [buf+1]
        cmp al, '2'
        jne LOOP_JUDGE_E
        jmp EXIT
LOOP_JUDGE_E :
        call OUTPUT
        jmp _start
INPUT :
        mov eax, 0x3
        mov ebx, 0x0
        mov ecx, buf
        add ecx, [len]
        mov edx, 0x1
        int 0x80
        mov eax, [len]
        inc eax
        mov [len], eax
        mov al, [ecx]
        ret
OUTPUT :
        mov eax, 0x4
        mov ebx, 0x1
        mov ecx, buf
        mov edx, [len]
        int 0x80
        ret
EXIT :
        mov eax, 1
        xor ebx, ebx
        int 0x80
 
 

posted on 2011-03-16 13:24 coreBugZJ 阅读(1006) 评论(0)  编辑 收藏 引用 所属分类: Assemble


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理