flat assembler
Message board for the users of flat assembler.

flat assembler > OS Construction > [solved] Loop instruction getting "stuck"

Author
Thread Post new topic Reply to topic
nkeck72



Joined: 28 May 2015
Posts: 83
Location: 0000:7C00
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 ah, byte ptr es:bx
        cmp ah, 80h
        jne not_right_file
        ; Back to 0x80. Go to byte after 0xff
go_to_end:
        mov cx, 14d
        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
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: 16050
Location: 112 Ocean Avenue, Amityville
nkeck72 wrote:
Code:
go_to_end:
        mov cx, 14d
        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


Copyright © 1999-2018, Tomasz Grysztar.

Powered by rwasa.