my question is if i want to add number by the number before it for example 4+3+2+1+0=10 how i can do it by using emu8086 i try by using there code but it had many error include 'emu8086.inc' org 100h mov ax,4 mov bx,0 add ax,bx jz a dec ax,1 add ax,bx jmp exit
Ken2017-11-07T17:54:43Z
You have 2 jumps but show no labels to jump to. Adding those would help :)
Looks like you're using 16-bit instructions. For that, you can
mov bx,4 ; first term mov ax,0 ; sum of terms starts at zero new_term: ; return here to add a new term add ax,bx ; add current term to sum dec bx ; next term is 1 less than previous jge new_term
; now ax = 4 + 3 + 2 + 1 + 0
Change the final "jge" to "jg" or "jnz" to skip adding the final 0.
If you know how, use a "trace" of that and watch what happens to the registers on each instruction. If not....learn how! Or you can single-step and watch; but some GUI type interfaces won't show you a history of what happened--just the current state. You miss out on some of the dynamics.