assembly - adding 16 bits registers -
i have code
addint: add cx, bx cmp cx, 0ffffh jbe convert
i'm trying add cx , bx registers, each have same value of ffff
, instead of getting 1fffe
, fffe
, , when try use jbe
jump convert loop, jbe istruction nothing because ecx
register contain fffe
, not 1fff
, how can fix code make ecx
contain 1fffe , how compare check if still 16 bits or not. cannot use 32 bits registers make thing more complicated
thank in advance
addint: clc ;clear carry flag add cx,bx jnc convert ;jump no carry cmp cx,fffeh ;this needs true, ffff+ffff succeed because generates carry , matches cmp jnz convert ;will let through
this work, it's limited , simplistic
to "count" carry use adc dx,0 inserted after jnc convert
the carry flag set if register goes round clock, acts single bit
add ffff+2 set off, giving +ve carry flag , 0001 in register
you can store flag count in separate register adc [other register],0
using carry flag allows slap registers count
1,208,741,363,432,547,555,475,424 4x16 bit registers
which quite lot , miles better 65,534
Comments
Post a Comment