Here is my assembly lang program.

mov	dh,0
  
     C: sub	bl,cl
        mov	al,bl
	mov	ah,0
	mov	bh,2
	div	bh
	
	cmp	ah,0
	je	A
	
	mov	al,cl
	mov	ah,0
	mov	bh,2
	div	bh
	
		

    A:	
	mov	al,cl
		
	add	dh,al
	add	bl,cl
	add	cl,1
	cmp	cl,bl
	jle	C

I am trying to convert it to x86 Hexadecimal.
I am using a Intel 86v simulator to run this.

8A 1E 0B 01

8A 0E 0C 01

EB 00 02 "Jumps the next 2 bytes which are the one that run the program"

14 0E "These are to two value that run the program CL=14 BL=OE"

C6 C6 00 "Sets Dh=0"

2A D9 "jump Location C: is at the start of this instruction"

8A C3

C6 C4 00

C6 C7 02

F6 F7

80 FC 00 "Compares Ah to 0

74 0A "This is the jump to label A if =0"

8A C1

C6 C4 00

C6 C7 02

F6 F7

8A C1 "Jump location A is here"

02 F0

02 D9

80 C1 01

3A CB

7E D6 "This is jump back up to C which is at the top almost like a loop.
I think this is where my problem is i think the value d6 is wrong
but it needs to be the number of bytes i need to jump to get back to the top.

This is the error message i get.
The NTVDM CPU has encountered an illegal instruction.
CS:1243 IP:0111 OP:d9 8a c3 c6 c4 Choose close to terminate the application.

I really need help fixing this is hope you understand my problem.

Change 7E D6 into 7E DC, see below

main PROC

		mov	dh,0      
00401010  mov         dh,0 
C1: 
		sub	bl,cl        
00401012  sub         bl,cl 
		mov	al,bl	
00401014  mov         al,bl 
		mov	ah,0	
00401016  mov         ah,0 
		mov	bh,2	
00401018  mov         bh,2 
		div	bh 	
0040101A  div         al,bh 
		cmp	ah,0	
0040101C  cmp         ah,0 
		je	A1 	
0040101F  je          A1 (401029h) 
		
		mov	al,cl	
00401021  mov         al,cl 
		mov	ah,0	
00401023  mov         ah,0 
		mov	bh,2	
00401025  mov         bh,2 
		div	bh       
00401027  div         al,bh 
A1:		
		mov	al,cl 	
00401029  mov         al,cl 
		add	dh,al	
0040102B  add         dh,al 
		add	bl,cl	
0040102D  add         bl,cl 
		add	cl,1	
0040102F  add         cl,1 
		cmp	cl,bl	
00401032  cmp         cl,bl 
		jle	C1
00401034  jle         .Base+7 (40100Ch) 
--- No source file -------------------------------------------------------------
00401036  int         3

IP is on 00401036 and has to go to 00401012 thus 24h back,
DC + 24h = 100h
With 7E D6 it jumps to 0040100Ch (line 41).

Hope this helps

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.