For Programmers: Free Programming Magazines  


Home > Archive > ASM370 > December 2004 > i wanna convert hex to decimal but i don't know what is problem in my source T T









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author i wanna convert hex to decimal but i don't know what is problem in my source T T
crazy for closegl

2004-12-20, 3:55 pm

this is my source. i'm beginner but i did my best to think about and
make it.
i can get the exe file but this exe file doesn't change hex to
decimal.
what i try was after get the input by the keyboard, assign through the
indirect address and multifly each digit with power of 16 and sum up.
but the result was nothing i mean even thogh i got the exe file, it
didn't work
please save from this chaos.........



hexdec1 segment
ASSUME CS : hexdec1,ds:data

loop1:
mov ah,02h
int 21h
call hex
mov cx,0
mov si,0
mov [bx+si],dl
INC SI
MOV NUM1,SI
CMP DL,0
JE GAP
LOOP LOOP1

GAP:
MOV pow,1
DEC SI

LOOP2:
MOV CX,SI
MOV AL,16
MUL POW

MOV [bx+si+1000],al
DEC SI
MOV NUM2,SI
LOOP LOOP2

LOOP3:
MOV CX,NUM1
MOV SI,NUM1
MOV AL,[BX+SI]

A:
MOV SI,NUM2
Mov dx,[bx+si+1000]
MUL dx
ADD TOT,Ax
DEC NUM1
INC NUM2
CMP NUM1,1
JE MULTI2
CMP NUM1,0
JE PRINT

LOOP LOOP3

MULTI2:
INC NUM2
JMP A

PRINT:
MOV AL,0AH
MOV AH,02H
INT 21H
mov dh,0
MOV Dx,TOT
MOV AH,02H
INT 21H
MOV AH,4CH
INT 21H

HEX PROC NEAR

CMP DL,'0'
JL HEX_1
CMP DL,'9'
JG HEX_1
SUB DL,'0'
ret


HEX_1:

CMP DL,'A'
JL HEX_2
CMP DL,'F'
JG HEX_2
SUB DL,55
ret

HEX_2:

CMP DL,'a'
JL HEX_3
CMP DL,'f'
JG HEX_3
SUB DL,87
ret

HEX_3:

MOV DL,0
RET
HEX ENDP

hexdec1 ENDS

DATA SEGMENT

NUM1 Dw ?
NUM2 Dw ?
POW DB ?
MULTI DB ?
TOT Dw ?
DATA ENDS
END
END
The Family

2004-12-20, 3:55 pm


Well, I've got good news, and I've got bad news:

The good news:

It's much easier than you've shown. All you need is a CVD instruction.
(Convert To Decimal).

The Bad News:

You'll need to change platforms, or find the correct/appropriate
group. <g>

Gary




"crazy for closegl" <johttt@hotmail.com> wrote in message
news:a81985a8.0412201020.53fd0441@posting.google.com...
> this is my source. i'm beginner but i did my best to think about and
> make it.
> i can get the exe file but this exe file doesn't change hex to
> decimal.
> what i try was after get the input by the keyboard, assign through the
> indirect address and multifly each digit with power of 16 and sum up.
> but the result was nothing i mean even thogh i got the exe file, it
> didn't work
> please save from this chaos.........
>
>
>
> hexdec1 segment
> ASSUME CS : hexdec1,ds:data
>
> loop1:
> mov ah,02h
> int 21h
> call hex
> mov cx,0
> mov si,0
> mov [bx+si],dl
> INC SI
> MOV NUM1,SI
> CMP DL,0
> JE GAP
> LOOP LOOP1
>
> GAP:
> MOV pow,1
> DEC SI
>
> LOOP2:
> MOV CX,SI
> MOV AL,16
> MUL POW
>
> MOV [bx+si+1000],al
> DEC SI
> MOV NUM2,SI
> LOOP LOOP2
>
> LOOP3:
> MOV CX,NUM1
> MOV SI,NUM1
> MOV AL,[BX+SI]
>
> A:
> MOV SI,NUM2
> Mov dx,[bx+si+1000]
> MUL dx
> ADD TOT,Ax
> DEC NUM1
> INC NUM2
> CMP NUM1,1
> JE MULTI2
> CMP NUM1,0
> JE PRINT
>
> LOOP LOOP3
>
> MULTI2:
> INC NUM2
> JMP A
>
> PRINT:
> MOV AL,0AH
> MOV AH,02H
> INT 21H
> mov dh,0
> MOV Dx,TOT
> MOV AH,02H
> INT 21H
> MOV AH,4CH
> INT 21H
>
> HEX PROC NEAR
>
> CMP DL,'0'
> JL HEX_1
> CMP DL,'9'
> JG HEX_1
> SUB DL,'0'
> ret
>
>
> HEX_1:
>
> CMP DL,'A'
> JL HEX_2
> CMP DL,'F'
> JG HEX_2
> SUB DL,55
> ret
>
> HEX_2:
>
> CMP DL,'a'
> JL HEX_3
> CMP DL,'f'
> JG HEX_3
> SUB DL,87
> ret
>
> HEX_3:
>
> MOV DL,0
> RET
> HEX ENDP
>
> hexdec1 ENDS
>
> DATA SEGMENT
>
> NUM1 Dw ?
> NUM2 Dw ?
> POW DB ?
> MULTI DB ?
> TOT Dw ?
> DATA ENDS
> END
> END



RFCOMMSYS

2004-12-23, 3:57 am

johttt@hotmail.com wrote:

>
>
>hexdec1 segment
> ASSUME CS : hexdec1,ds:data
>
>loop1:
> mov ah,02h
> int 21h
> call hex
> mov cx,0
> mov si,0
> mov [bx+si],dl
> INC SI
> MOV NUM1,SI
> CMP DL,0
> JE GAP
>LOOP LOOP1
>
>GAP:
> MOV pow,1
> DEC SI
>
>LOOP2:
> MOV CX,SI
> MOV AL,16
> MUL POW
>
> MOV [bx+si+1000],al
> DEC SI
> MOV NUM2,SI
> LOOP LOOP2
>
>LOOP3:
> MOV CX,NUM1
> MOV SI,NUM1
> MOV AL,[BX+SI]
>
>A:
> MOV SI,NUM2
> Mov dx,[bx+si+1000]
> MUL dx
> ADD TOT,Ax
> DEC NUM1
> INC NUM2
> CMP NUM1,1
> JE MULTI2
> CMP NUM1,0
> JE PRINT
>
>LOOP LOOP3
>
>MULTI2:
> INC NUM2
> JMP A
>
>PRINT:
> MOV AL,0AH
> MOV AH,02H
> INT 21H
> mov dh,0
> MOV Dx,TOT
> MOV AH,02H
> INT 21H
> MOV AH,4CH
> INT 21H
>
>HEX PROC NEAR
>
> CMP DL,'0'
> JL HEX_1
> CMP DL,'9'
> JG HEX_1
> SUB DL,'0'
> ret
>
>
>HEX_1:
>
> CMP DL,'A'
> JL HEX_2
> CMP DL,'F'
> JG HEX_2
> SUB DL,55
> ret
>
>HEX_2:
>
> CMP DL,'a'
> JL HEX_3
> CMP DL,'f'
> JG HEX_3
> SUB DL,87
> ret
>
>HEX_3:
>
> MOV DL,0
> RET
>HEX ENDP
>
>hexdec1 ENDS
>
>DATA SEGMENT
>
>NUM1 Dw ?
>NUM2 Dw ?
>POW DB ?
>MULTI DB ?
>TOT Dw ?
>DATA ENDS
> END
> END
>



Good gawd! All that to simulate CVD? No wonder Microsoft sucks!

heh heh


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com