Category:8086 Assembly: Difference between revisions

m
 
Line 121:
loop foobar</lang>
 
It may not be obvious at first but the above loop will never end. <code>CX</code> decrements to 0x09990x0FFF with the <code>LOOP</code> instruction but the <code>mov cx,1000h</code> was mistakenly placed ''inside'' the loop, resetting the loop counter back to 0x1000, which means no progress is really being made. The correct way to do this is to set the starting loop counter '''outside''' the loop, like so:
 
<lang asm>mov cx,1000h
1,489

edits