PDA

View Full Version : دستورات برای مقادیر 32 بیتی



jamjid
چهارشنبه 17 بهمن 1386, 06:38 صبح
سلام
دستورات 32 بیتی را برای تبدیل عدد به رشته و همچنین تبدیل رشته به عدد می خواستم
من دستورات 16 بیتی این اعمال را دارم . ولی به 32 بیتی نیاز دارم .

jamjid
پنج شنبه 18 بهمن 1386, 07:14 صبح
sign db ?
string db 6 dup(' '),"$"

.code
main proc far
mov ax, @data
mov ds, ax
lea bx, string
add bx, 5
mov ax, -2456 ; change to string
mov sign, ' '
cmp ax, 0
jge setup ; skip if not negative
mov sign, '-'
neg ax ; now ax > 0
setup: mov cx, 10 ; divisor
divloop: mov dx, 0 ; extend number to double word
div cx ; divide by 10
add dl, 30h ; convert
mov [bx], dl
dec bx
cmp ax, 0
jne divloop
mov cl, sign ; insert sign to string
mov [bx], cl
این دستورات برای تبدیل رشته عددی موجود در AX به عدد است

;itoa ---- convert integer to ascii string (the string is zero ending)
;input:
; ax = the integer to be converted
; cl = max length of the integer
; es:di -> buffer
;output:
; none
;================================================= ============================
itoa:
pusha
xor ch, ch
add di, cx
mov byte [di], 0
mov bx, 10
.loop_itoa:
xor dx, dx
dec di
div bx
add dl, '0'
mov [di], dl
dec cx
or ax, ax
jz .end_itoa
or cx, cx
jnz .loop_itoa
.end_itoa:
or cx, cx
jz .end
.loop_fillspace:
dec di
mov byte [di], ' '
loop .loop_fillspace
.end:
popa
ret



من این کار را برای برنامه های 32 بیتی می خواهم