Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .model tiny
- .code
- .386
- org 100h
- entry: jmp start
- int9:
- in al, 60h
- mov di, tail
- mov buffer[di], al
- inc tail
- and tail, 0fh
- mov ax, tail
- cmp head, ax
- jne _1
- inc head
- and head, 0fh
- _1:
- in al, 61h
- or al, 80h
- out 61h, al
- and al, 07fh
- out 61h, al
- mov al, 20h
- out 20h, al
- iret
- buffer db 10h dup (?)
- head dw ?
- tail dw ?
- oldInt9 dd ?
- ENDL db 13, 10, '$'
- ESC_SC db 81h
- SPACE_SC db 039h
- spaceMessage db 'muhaha', '$'
- start:
- xor dx, dx
- mov ax, 3509h
- int 21h
- mov word ptr oldInt9, bx
- mov word ptr oldInt9+2, es
- cli
- mov ax, 2509h
- mov dx, offset int9
- int 21h
- sti
- _2:
- mov di, head
- cmp tail, di
- je _2
- mov dl, buffer[di]
- inc head
- and head, 0fh
- cmp dl, SPACE_SC
- jne _cont
- mov ax, 0900h
- lea dx, spaceMessage
- int 21h
- mov ax, 0900h
- lea dx, ENDL
- int 21h
- _cont:
- cmp dl, ESC_SC
- je exit
- xor bx, bx
- mov bl, dl
- call out_hex
- jne _2
- out_hex proc
- push bp
- mov bp, sp
- pusha
- mov cx, 4
- _3:
- rol bx, 4
- mov al, bl
- and al, 0fh
- cmp al, 10
- sbb al, 69h
- das
- mov dh, 02h
- xchg ax, dx
- int 21h
- loop _3
- mov ax, 0900h
- lea dx, ENDL
- int 21h
- popa
- mov sp, bp
- pop bp
- ret
- out_hex endp
- exit:
- cli
- mov ax, 2509h
- mov dx, word ptr cs:[oldInt9]
- mov ds, word ptr cs:[oldInt9+2]
- int 21h
- sti
- ret
- end entry
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement