shurikan |
19-11-2004 19:54 274198 |
warezhka84
Ссылка на E-mail недоступна, кладу здесь.
Код:
.286
.model large
.code
inbuffer db 10,0
db 10 dup(?)
outbuffer db ' ' ;;; <- здесь не видно, но пробелов 9 штук
outtail db '$'
signed dw 0
ten dw 10
;;;
;;; Получить в AX число.
;;;
public get_in_AX
get_in_AX proc
push ax
push bp
mov bp,sp
push si
push bx
push cx
push ds
push cs
pop ds
lea dx,inbuffer
mov ah,0Ah
int 21h
xor cx,cx
mov cl,inbuffer+1
jcxz gAXerr
lea si,inbuffer+2
xor bx,bx
mov signed,bx
gAXloop:
lodsb
cmp al,'+'
je @1
cmp al,'-'
jne @2
mov signed,1
@1:
cmp si,offset inbuffer+3
jne gAXerr
@2:
cmp al,'0'
jb gAXerr
cmp al,'9'
ja gAXerr
xor ah,ah
sub ax,'0'
xchg ax,bx
mul ten
add ax,bx
js gAXerr
xchg ax,bx
loop gAXloop
jmp short gAXok
gAXerr:
stc
jmp short gAXdone
gAXok:
mov ax,signed
test ax,ax
je @3
neg bx
@3:
mov [bp+2],bx
clc
gAXdone:
pop cx
pop bx
pop si
pop ds
pop bp
pop ax
ret
get_in_AX endp
;;;
;;; Вывести число из AX на экран*.
;;;
public print_AX
print_AX proc
std
mov signed,0
test ax,8000h
je @4
mov signed,1
neg ax
@4:
push di
lea di,outtail-1
push cs
pop es
@7:
test ax,ax
je @5
xor dx,dx
div ten
xchg ax,dx
add al,'0'
stosb
xchg ax,dx
jmp short @7
@5:
cmp di,offset outtail-1
jne @6
add al,'0'
stosb
@6:
mov ax,signed
test ax,ax
jne @8
mov al,'-'
stosb
@8:
push ds
push cs
pop ds
mov dx,di
mov ah,09h
int 21h
pop ds
pop di
cld
ret
print_AX endp
end
:)
|