flat assembler
Message board for the users of flat assembler.
 Home   FAQ   Search   Register 
 Profile   Log in to check your private messages   Log in 
flat assembler > OS Construction > [solved] Loop instruction getting "stuck"

Author
Thread Post new topic Reply to topic
nkeck72



Joined: 28 May 2015
Posts: 78
Location: 0000:7C00
[solved] Loop instruction getting "stuck"
I have the following code snippet as a part of the NOS API. When I was debugging, I noticed that Bochs seemed to get stuck indefinitely on this loop instruction:


Code:

not_right_file:
        ; Somewhere in the filename. Go back to the beginning of the field
        dec bx
        mov ahbyte ptr es:bx
        cmp ah80h
        jne not_right_file
        ; Back to 0x80. Go to byte after 0xff
go_to_end:
        mov cx14d
        inc bx
        loop go_to_end




What this code does is effectively take the pointer from the middle of a file descriptor field in the FSB back to the beginning of the field, then make it point to the byte after the end of the field. As far as I know, this code was written correctly, but yet Bochs seems to sit indefinitely on the loop instruction. Can someone help shed some light on this situation?


EDIT: I NOW NOTICE MY PROBLEM. I AM SUCH AN IDIOT. Embarassed

_________________
It may look hard, but it won't take long if you take it one byte at a time.

NOS: www.github.com/nkeck720/nos


Code:

org 100h
mov ah09h
mov dxmessage
int 21h
int 20h

message db "Hello FASM world!"0Dh0Ah"$"


Post 15 Oct 2016, 01:38
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 14469
Location: ?                               Posts: 6699
Re: [solved] Loop instruction getting "stuck"

nkeck72 wrote:

Code:
go_to_end:
        mov cx14d
        inc bx
        loop go_to_end

As far as I know, this code was written correctly, but yet Bochs seems to sit indefinitely on the loop instruction.

More correctly Bochs will continue execute the three instructions in the loop, not just on the loop instruction.

nkeck72 wrote:
EDIT: I NOW NOTICE MY PROBLEM. I AM SUCH AN IDIOT. Embarassed

Happens to everyone. Usually because of tiredness or distraction. Take a break, talk to a friend about something unrelated, play a game, or anything to remove your thoughts from the actual problem.

BTW: Why not simply this?

Code:
add bx,14d

Post 15 Oct 2016, 01:49
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


Powered by phpBB © 2001-2005 phpBB Group.

Main index   Download   Documentation   Examples   Message board
Copyright © 2004-2016, Tomasz Grysztar.