flat assembler
Message board for the users of flat assembler.
Index
> DOS > simple logical if |
Author |
|
Matrix 06 Aug 2005, 21:54
Hi Hicel,
well it is basically right, but jmp is an unconditional jump, you must use conditional jumps je jb jo ... and you can not compare direcly 2 memory address's contents with cmp, put one in register, then compare register with memory, or in case strings use cmpsb (compare string byte) uhm, and dont forget to exit in a way... Code: format MZ use16 push cs pop ds mov [num1],0 mov [num2],1 mov al,[num1] cmp al,[num2] jb is_then ; if below jae is_else ; if above or equal is_then: mov ah,9 mov dx,msg_then int 21h jmp endif is_else: mov ah,9 mov dx,msg_else int 21h endif: xor ax,ax ; wait for keypress int 16h ; bios function int 20h ; exit program num1 db ? num2 db ? msg_then db 'Then!',24h msg_else db 'Else!',24h |
|||
06 Aug 2005, 21:54 |
|
Hicel 07 Aug 2005, 11:26
Many thanks Matrix I just learned from you that there are different jumps.. from step to step I'm getting more into it For those having the same problem: (never understood the description but now )
Code: EB cb JMP rel8 Jump short, relative, 77 cb JA rel8 Jump short if above 73 cb JAE rel8 Jump short if above or equal 76 cb JBE rel8 Jump short if below or equal 72 cb JC rel8 Jump short if carry E3 cb JECXZ rel8 Jump short if ECX register is 0 74 cb JE rel8 Jump short if equal 7F cb JG rel8 Jump short if greater 7D cb JGE rel8 Jump short if greater or equal 7C cb JL rel8 Jump short if less 7E cb JLE rel8 Jump short if less or equal 75 cb JNE rel8 Jump short if not equal 71 cb JNO rel8 Jump short if not overflow 79 cb JNS rel8 Jump short if not sign 70 cb JO rel8 Jump short if overflow 7A cb JPE rel8 Jump short if parity even 7B cb JPO rel8 Jump short if parity odd 78 cb JS rel8 Jump short if sign |
|||
07 Aug 2005, 11:26 |
|
Bitdog 07 Aug 2005, 21:30
There are conditional signed jumps & unsigned jumps.
Your CHAR or INT = BYTE & WORD are usually unsigned values and require unsigned jumps such as JA JB JZ etc. Well, it's something to look into anyway. INT 20h ; is an exit for a .COM file & you have an MZ format .EXE so MOV AX,4C00h INT 21h might be best as an exit code. But I haven't checked it all out to be sure of anything above. I hope this helps somehow. Sincerely Bitdog |
|||
07 Aug 2005, 21:30 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.