flat assembler
Message board for the users of flat assembler.

Index > OS Construction > Turn off NMI ???

Goto page Previous  1, 2
Author
Thread Post new topic Reply to topic
mikegonta



Joined: 20 Nov 2005
Posts: 99
mikegonta
[ Post removed by author. ]


Last edited by mikegonta on 28 Jan 2009, 09:16; edited 1 time in total
Post 24 Jan 2009, 22:46
View user's profile Send private message Reply with quote
Coddy41



Joined: 18 Jan 2009
Posts: 384
Location: Ohio, USA
Coddy41
mikegonta wrote:

The jmp @B continues the wait.

Oh, ok I thought it looked funny, It would have been more like,
+============
|hi:
| db 'hi',10,5
|jmp hi
+============
If you wanted to make a loop, sorry for the off topic posts. :\
Post 24 Jan 2009, 22:59
View user's profile Send private message Visit poster's website Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
Quote:

+============
|hi:
| db 'hi',10,5
|jmp hi
+============

I have seen you wrote a similar code somewhere else. Do you know what's going to happen when that code is executed?
Post 24 Jan 2009, 23:01
View user's profile Send private message Reply with quote
Coddy41



Joined: 18 Jan 2009
Posts: 384
Location: Ohio, USA
Coddy41
since you put it that way, no
Post 24 Jan 2009, 23:23
View user's profile Send private message Visit poster's website Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
I suppose you are expecting that it will print "hi\n" infinite times, right? Well, it turns out to be that the "db 'hi',10,5" part will be interpreted as CPU instructions so it will end up doing unexpected things.

For example, this is the listing provided by the debug program of your code:
Code:
-e 100 'hi', 10, 5
-a 104
0D1C:0104 jmp 100
0D1C:0106
-u100
0D1C:0100 68            DB      68
0D1C:0101 69            DB      69
0D1C:0102 1005          ADC     [DI],AL
0D1C:0104 EBFA          JMP     0100
.
.
.
-r
AX=0000  BX=0000  CX=0000  DX=0000  SP=FFEE  BP=0000  SI=0000  DI=0000
DS=0D1C  ES=0D1C  SS=0D1C  CS=0D1C  IP=0100   NV UP EI PL NZ NA PO NC
0D1C:0100 68            DB      68
-t

AX=0000  BX=0000  CX=0000  DX=0000  SP=FFEC  BP=0000  SI=0000  DI=0000
DS=0D1C  ES=0D1C  SS=0D1C  CS=0D1C  IP=0103   NV UP EI PL NZ NA PO NC
0D1C:0103 05EBFA        ADD     AX,FAEB
-t

AX=FAEB  BX=0000  CX=0000  DX=0000  SP=FFEC  BP=0000  SI=0000  DI=0000
DS=0D1C  ES=0D1C  SS=0D1C  CS=0D1C  IP=0106   NV UP EI NG NZ NA PE NC
0D1C:0106 206163        AND     [BX+DI+63],AH                      DS:0063=20    

As you can see in the trace command, the address of "jmp 100" was already exceeded but it was never executed and now the program is out of control.

Also note that the disassembly has a "jmp 100" only because it was not able to interpret the code as my CPU does because it couldn't recognize them as valid (debug disassembles for 8086, but the push imm16 appeared later in 80188 or so).
Post 24 Jan 2009, 23:59
View user's profile Send private message Reply with quote
Coddy41



Joined: 18 Jan 2009
Posts: 384
Location: Ohio, USA
Coddy41
hm, so what do I use to loop infinite times?
Post 25 Jan 2009, 00:17
View user's profile Send private message Visit poster's website Reply with quote
DJ Mauretto



Joined: 14 Mar 2007
Posts: 464
Location: Rome,Italy
DJ Mauretto
Quote:
hm, so what do I use to loop infinite times?


Code:
Infinite_Loop:
                jmp Infinite_Loop
    

_________________
Nil Volentibus Arduum Razz
Post 25 Jan 2009, 09:12
View user's profile Send private message Reply with quote
Coddy41



Joined: 18 Jan 2009
Posts: 384
Location: Ohio, USA
Coddy41
o,k --Takes notes-- Smile
Post 25 Jan 2009, 13:32
View user's profile Send private message Visit poster's website Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4242
Location: 2018
edfed
hem...

you don't need to reenable interrupts each loop.
if your system is'nt able to save the execution context, it should be corrected in order to recover the state before task switch.
then,
Code:
sti
@@:
hlt
jmp @b
    

is correct.
Post 26 Jan 2009, 18:42
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: 17665
Location: In your JS exploiting you and your system
revolution
edfed wrote:
hem...

you don't need to reenable interrupts each loop.
if your system is'nt able to save the execution context, it should be corrected in order to recover the state before task switch.
then,
Code:
sti
@@:
hlt
jmp @b
    

is correct.
You assume a lot with code like that. In some circumstances you can have lock up problems. It depends upon how one codes the rest of their OS. I would say use with extreme caution.
Post 26 Jan 2009, 19:01
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:  
Goto page Previous  1, 2

< 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 GitHub, YouTube, Twitter.

Website powered by rwasa.