Hello Gyes!
I am very new in Using emu8086 and i need a code about this Program Problem:

I have to convert a Hexa input to a Binary Output using emu8086.
1. Hexa number will be placed in AL
2.And output Binary will come in AX+ DX, Memory address will be 0507 to 0500

I tried to do but last of all i mixed up everything...


Plz Guys help me to do this problem. Thank you ..

Dani AI

Generated

A few focused notes on the attempts by and a clearer, reliable approach for 8086 emu8086.

The main problem in the posted attempts is mixing division semantics and reconstruction math. On 8086 the DIV instruction size matters: an 8-bit divisor divides AX (quotient → AL, remainder → AH); a 16-bit divisor divides DX:AX (quotient → AX, remainder → DX). If AX/AH or DX are not set exactly as required, remainders and quotients will be garbage — which explains the wrong bits seen. Clearing the high byte (AH) or using the correct divisor width is mandatory when trying repeated DIV-by-2 loops.

A simpler, safer method is bit extraction rather than arithmetic division. Treat the byte as eight independent bits and write each bit as a byte ('0' or '1') into a small output buffer. Two common, easy-to-reason-about ways work well on 8086: test with masks (80h, 40h, 20h, ... 01h) from MSB to LSB, or shift the working byte and read the carry/low bit each iteration. Both avoid multiword division, avoid rebuilding values with decimal/hex place multiplications, and produce predictable output order for display.

Practical cautions and test tips: choose whether the buffer holds ASCII '0'/'1' (0x30/0x31) or numeric 0/1; initialize segment registers or use labels so writes go to the expected memory; single-step in the emulator and watch AX/AH/DX when trialing DIV; inspect the buffer in memory view to confirm order. Using a small, clearly indexed loop for eight iterations will be far more robust than repeated DIV and multiply steps.

Please kindly help me.

MOV AL, 0AH
MOV BX, 2H

MOV DX, 0000H
DIV BX

MOV [0500], DL
MOV DX,0000H
DIV BX

MOV [0501], DL
MOV DX, 0000H

DIV BX
MOV [0502], DL

MOV DX, 0000H
DIV BX

MOV DX, 0000H
MOV [0503], DL
DIV BX

MOV AX, [0500]
MOV BX, 1H
MUL BX

ADD [0504], AX
MOV AX, [0501]
MOV BX, 10H
MUL BX

ADD [0504], AX
MOV AX, [0502]
MOV BX, 100H
MUL BX

ADD [0504], AX
MOV AX, [0503]
MOV BX, 1000H
MUL BX

ADD [0504], AX
MOV AX, [0504]

RET


This is the Code. Buit in Th AX Register i Found 0110 But it Should be 1010.
PLEASE BROTHER ANY ONE HELP ME

; to convert a hexa number to a binary number

mov al,0ch
mov bl,2h

mov dx, 0000h
div bx
mov [0500],dl


mov dx, 0000h
div bx
mov [0501],dl

mov dx, 0000h
div bx
mov [0502],dl


mov dx, 0000h
div bx
mov [0503],dl


mov al, [0503]
mov bx, 1000h
mul bx
add [0508],ax


mov al, [0502]
mov bx, 100h
mul bx
add [0508],ax


mov al, [0501]
mov bl, 10h
mul bl
add [0508],ax


mov al, [0500]
mov bl, 1h
mul bl
add [0508],ax


mov ax,[0508]

ret

this is the solution. u all are chitter and dont even try to help in this simple program.

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.