Message board for the users of flat assembler.
> DOS > convert decimal into hexa
i am beginner with assembly language.
please help me out with small source code.
i want to convert decimal number into hexa.
i did like this:
TEN DB 10
VAR1 DB 0
INDEC DB 0,1
M1 DB 'Enter Decimal : ','$'
M2 DB 13,10,'Hex Value: ','$'
mov ah, 2
mov dl, 'h'
but this is not good idia
|13 Oct 2008, 18:24||
It's not working because it's not fasm code (tasm?).
remove .MODEL SMALL, .DATA, .STACK, .CODE, .STARTUP, END
move all your data to the end
use brackets for memory locations (e.g. 'mov [var1],al' instead of 'mov var1,al')
don't forget the 'org 100h'
add some exit code at the end
and why not use 'mov' instead of 'lea'?
N.B. This code converts only one digit.
|14 Oct 2008, 07:21||
ret ; COM only
mov ax,$4C00 int $21 ; COM , RM EXE , DPMI EXE
Not required but nice to have at beginning:
; Compile with FASM format binary as "COM"
About converting dec to hex, you need 2 things:
- Parse DEC input
- Output as HEX
Check some of my examples
Bug Nr.: 12345
Title: Hello World program compiles to 100 KB !!!
Status: Closed: NOT a Bug
|15 Oct 2008, 23:48||
< Last Thread | Next Thread >
Copyright © 1999-2020, Tomasz Grysztar.
Powered by rwasa.