flat assembler
Message board for the users of flat assembler.

Index > Main > flags, cmp, and add...

Author
Thread Post new topic Reply to topic
hckr83



Joined: 12 Nov 2006
Posts: 86
Location: usa
hckr83
hi I'm really kindof a newbie to asm(just know the basics mov and concepts)
and well I'm creating an x86 emulator(don't say I should be fluent in asm first lol)
I really do not understand what the bits in the flag register do
I've tried reading the intel docs and just got done reading some tuts in your faq
I understand how cmp will set the flags but exactly what do the bits mean like cf
is cf like overflow where when you add 1 to 0xFFFF(unsigned)
and I do not understand at all what cf does in sub(tract) in my docs it uses wierd terms like "borrow into the high order bit" which I do not understand at all!

thanks..

_________________
x86 CPU Emulation library: http://sourceforge.net/projects/x86lib
Post 12 Nov 2006, 02:15
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger Reply with quote
coconut



Joined: 02 Apr 2004
Posts: 326
Location: usa
coconut
zero flag for example works like so

cmp eax,ecx ;zero flag will be set to 0 if equal
jnz some_label ;if not equal jump somewhere else
call some_thing ;code continues here if equal

ive never played with carry flag, here is some info on it: http://en.wikipedia.org/wiki/Carry_flag
Post 12 Nov 2006, 04:26
View user's profile Send private message Reply with quote
rugxulo



Joined: 09 Aug 2005
Posts: 2341
Location: Usono (aka, USA)
rugxulo
Here's how you add two 32-bit numbers (using 16-bit assembly). Double-check your result in CALC.EXE, if you want.

Code:
[ WinXP ] Sat 11/11/2006>type test.asm
org 100h

mov ax,5150h
mov bx,0FFEEh
mov cx,1000h
mov dx,2000h
add bx,dx
adc ax,cx
int3
int 20h

[ WinXP ] Sat 11/11/2006>fasm test.asm
flat assembler  version 1.67.14  (455416 kilobytes memory)
1 passes, 19 bytes.

[ WinXP ] Sat 11/11/2006>debug test.com
-g

AX=6151  BX=1FEE  CX=1000  DX=2000  SP=FFFE  BP=0000  SI=0000  DI=0000
DS=14F6  ES=14F6  SS=14F6  CS=14F6  IP=0110   NV UP EI PL NZ NA PO NC
14F6:0110 CC            INT     3
-q

[ WinXP ] Sat 11/11/2006>scrndump
    


EDIT: I know, I know, I should've just used ADD reg16, imm16.
Post 12 Nov 2006, 05:57
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on YouTube, Twitter.

Website powered by rwasa.