Could anyone help me to convert this code to 8086 assembly language.

Aku wt pki MASM32 (www.masm32.com)
; Build this with the "Project" menu using
; "Console Assemble & Link"

.486 ; create 32 bit code
.model flat, stdcall ; 32 bit memory model
option casemap :none ; case sensitive

include D:\masm32\include\windows.inc ; always first
include D:\masm32\macros\macros.asm ; MASM support macros

include D:\masm32\include\masm32.inc
include D:\masm32\include\kernel32.inc
include D:\masm32\include\msvcrt.inc

includelib D:\masm32\lib\masm32.lib
includelib D:\masm32\lib\kernel32.lib
includelib D:\masm32\lib\msvcrt.lib ; import CRT (C run-time) library


ConstantCalculation proto : DWORD
UserInputCalculation proto : BYTE

.data
double REAL8 ?
two REAL4 2.0
_0point1 REAL4 0.1
_1point0 REAL4 1.0
_10point0 REAL4 10.0
_100point5 REAL4 100.5
_1000point0 REAL4 1000.0
format1 db "2.0 x log10 (%f) = %f", 10, 0
format2 db "%s", 0

.code ; Tell MASM where the code starts


start: ; The CODE entry point to the program

Invoke ConstantCalculation, 1
Invoke ConstantCalculation, 2
Invoke ConstantCalculation, 3
Invoke ConstantCalculation, 4
Invoke ConstantCalculation, 5
Invoke UserInputCalculation, 0
print chr$ (10, 174, 174, 174, 174, 32, 99, 111, 100, 101, 100, 32, 98, 121, 32, 83, 116, 114, 97, 110, 103, 101, 114, 32, 175, 175, 175, 175, 10)
exit


ConstantCalculation proc SelectCase : DWORD
LOCAL Log10What : REAL8

finit ; Initialize the FPU

cmp SelectCase, 1
jne Case2
fld _0point1 ; st(0) = _0point1
fst Log10What ; Store real number
jz ExecuteNextStatement

Case2:
cmp SelectCase, 2
jne Case3
fld _1point0 ; st(0) = _1point0
fst Log10What ; Store real number
jz ExecuteNextStatement

Case3:
cmp SelectCase, 3
jne Case4
fld _10point0 ; st(0) = _10point0
fst Log10What ; Store real number
jz ExecuteNextStatement

Case4:
cmp SelectCase, 4
jne Case5
fld _100point5 ; st(0) = _100point5
fst Log10What ; Store real number
jz ExecuteNextStatement

Case5:
fld _1000point0 ; st(0) = _1000point0
fst Log10What ; Store real number


ExecuteNextStatement:
; "log10()" & "printf()" expects a REAL8 datatype, so convert
fstp double ; Store real number(double) and pop "st(0)"
push dword ptr [double + 4]
push dword ptr [double ]
call crt_log10

fld st(0)
fmul two
ffree st(1)
fstp double

; print result
INVOKE crt_printf, SADD("2.0 x log10 (%6.1f) = %1.5f", 10), Log10What, double

ret
ConstantCalculation endp


UserInputCalculation proc void : BYTE
LOCAL i : DWORD ; Loop
LOCAL String : DWORD
LOCAL d : REAL8

mov i, 0 ; Initialize i to 0
print chr$(10, 10)

gelung: ; Loop
finit

mov String, input("Input real number : ")

push String
call crt_atof
fst d ; Store real number (d)

push dword ptr [d + 4]
push dword ptr [d ]
call crt_log10
fmul two
fst double ; Store real number (double)

; print result
INVOKE crt_printf, ADDR format1, d, double
print chr$(10)

add i, 1
cmp i, 5
jne gelung ; Byk sgt reserved word, pki BM lg sng:)

ret
UserInputCalculation endp

end start ; Tell MASM where the program ends

Like assembling the code and disassembling it with something like hiew?
I'd like to know more about your project, it sounds interesting.

- Gordon

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.