# Thread: Beginner ASM question: jump instructions

1. ## Beginner ASM question: jump instructions

Code:
```FILE_OK:
mov     dx,OFFSET FNAME
mov     ax,3D02H
int     21H
jc      FOK_NZEND  ;error opening file
......
mov     ax,WORD PTR [FSIZE] ;
add     ax,OFFSET ENDPROG - OFFSET PROG   ;
jc      FOK_NZEND           ;c set if ax overflows (size > 64k)
cmp     BYTE PTR [START_IMAGE],0E9H   ;
jnz     FOK_ZEND            ;exit with z
cmp     WORD PTR [START_IMAGE+3],4956H
jnz     FOK_ZEND            ;return with Z set
FOK_NZEND:
mov     al,1                ;
or      al,al               ;return with z reset
ret
FOK_ZEND:
xor     al,al               ; return with z set
ret```
Hi im unclear about the working of jump instructions above. What's the meaning of "c set if ax overflows" and "return with Z set"? whats the relationship with cmp and jnz here? how jc and jnz decide whether to jump to another function.

Dont know if my question is clear. anyway, thanks for any input.

2. What's the meaning of "c set if AX overflows"
This comment means "The carry flag is set if ax overflows". "jc" means "jump if carry (is set)".

...and "return with Z set"
On this one, I'm not exactly sure, but it looks like it has something to do with the "zero flag". In fact, it does look like Z means "zero flag" here

whats the relationship with cmp and jnz here?
Well, the cmp instruction sets the different flags accordingly to the result of the comparaison. The JNZ check if the zero flag is set and jump to the location if it is. JNZ is for "jump not zero" and "jc" is for "jump carry".

I would suggest you to go to this site
http://developer.intel.com/products/...uals/index.htm
and download the Volume 1, Volume 2A and 2B. You'll see, they are handy if you are doing x86 (or x86-64) assembly.

3. Here is the best manual that I know for x86 assembly if you have any questions about the op codes or standard syntax. Specifically in this case you're going to want to look at this section.