ok i have this problem in mind i wanted to try but i cant figure out whats wrong with my code..the program lets you input a string of integers then press another input as target..The target is then cmp to the string..the output should place lesser values on the string based on the specifed target ex.
string: 12456
target: 2
output: 1

.model small
.stack
.data
.code
start:
push 0ah ; push linefeed indication of stack
start1:
mov ah,1
int 21h
push ax      ; data place at stack
cmp al,0dh   
je out1       ; will jump if equal to cmp al,0dh
jne start1 ; will jump if not equal to cmp al,0dh
out1:
mov ah,2
mov dl,0ah ;linefeed
int 21h

target:
pop bx
mov ah,1
int 21h
tests:
cmp al,bl
jl out2
out2:
pop bx
mov ah,2
mov dl,al
int 21h
cmp al,0ah
jne tests
je fin
fin:
mov ah,4ch
int 21h
end start

need help...im just wondering how come it wont workout the way i wanted it to workout..

JL or JB / JC ; Jump less-than or jump below
JG or JA ; Jump greater-than or jump above

The CMP instruction subtracts the dest-src from each other,
and updates the FLAGS which can be tested by conditional jumps.
For instance JB is equivalent to JC (Jump if CF Set).

Example:
cmp a, b
jg label ; Jump if A > B

cmp a, b
jl label ; Jump if A < B

Not to cloud the issue, but first you need to deterimine if you are working with signed versus unsigned data? You need to use a different compare based upon the type of data you're using!

Above & Below --> Unsigned
Less & Greater --> Signed

Unsigned:
JA, JNBE Jump if above (>)
JAE JNB (>=)
JBE, JNA (<=)
JB, JNAE (<_

Signed:
JG, JNLE (>)
JGE, JNL (>=)
JLE, JNG (<=)
JL, JNGE (<)

Suprisingly I did not know that JA was for unsigned
and JG was for signed, etc...
Thanks for the post wildgoose!

Hi,

Is there away to have the logic condition of (jl AND jg)?

Thanks

Hi talma, you're new around here. What you've just done is reply to a 4-year-old thread which was solved, with a completely new question of your own. This is known amongst the internet community as hijacking and/or necromancy, and it's frowned upon because it makes things a bit convoluted and disorganised. Please start your own topic in the Assmbly Forum to get help in solving your assembly question.

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.