Chinaunix首页 | 论坛 | 博客
  • 博客访问: 77199
  • 博文数量: 22
  • 博客积分: 1250
  • 博客等级: 中尉
  • 技术积分: 305
  • 用 户 组: 普通用户
  • 注册时间: 2007-04-19 09:44
文章分类

全部博文(22)

文章存档

2009年(2)

2008年(20)

我的朋友

分类: BSD

2008-06-20 16:01:04

代码是这样的:
%include   'system.inc'

section .data
hex db  '0123456789ABCDEF'
buffer  db  0, 0, ' '

section .text
global  _start
_start:
    ; read a byte from stdin
    push    dword 1
    push    dword buffer
    push    dword stdin
    sys.read
    add esp, byte 12
    or  eax, eax
    je  .done

    ; convert it to hex
    movzx   eax, byte [buffer]
    mov edx, eax
    shr dl, 4
    mov dl, [hex+edx]
    mov [buffer], dl
    and al, 0Fh
    mov al, [hex+eax]
    mov [buffer+1], al

    ; print it
    push    dword 3
    push    dword buffer
    push    dword stdout
    sys.write
    add esp, byte 12
    jmp short _start

.done:
    push    dword 0
    sys.exit
阅读(1194) | 评论(0) | 转发(0) |
0

上一篇:FREEBSD 与 LINUX的比较

下一篇:JAVA HASHTABLE

给主人留下些什么吧!~~