Nasm syntax problem

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Prochamber
Member
Member
Posts: 100
Joined: Wed Mar 13, 2013 2:27 am

Re: Nasm syntax problem

Post by Prochamber »

gerryg400 wrote:
You should clear interrupt before changing the stack pointer and segment then restore them afterwards.
It's not necessary to disable interrupts if the SS is loaded first. The processor does it for you automatically.
Not on really old processors. This won't be relevant for the OP anyway because the OP loaded the stack pointer two instructions before the stack segment.
TachyonOS - Violates causality on 95% of attempts. Runs at approximately 1.5c.
gerryg400
Member
Member
Posts: 1801
Joined: Thu Mar 25, 2010 11:26 pm
Location: Melbourne, Australia

Re: Nasm syntax problem

Post by gerryg400 »

You're correct of course. Some 8088 processors have this bug.

However, it doesn't change the fact that the correct way to modify the SS, (E)SP pair is to modify the SS first and then the (E)SP. That's the way Intel recommends it, presumably because CLI by itself doesn't prevent an NMI or a debug trap.
If a trainstation is where trains stop, what is a workstation ?
User avatar
qw
Member
Member
Posts: 792
Joined: Mon Jan 26, 2009 2:48 am

Re: Nasm syntax problem

Post by qw »

If possible, LSS is even more recommended:
The [url=http://pdos.csail.mit.edu/6.828/2010/readings/i386.pdf]Intel 80386 Programmer's Reference Manual[/url] wrote:To prevent this situation, the 80386, after both a MOV to SS and a POP to SS instruction, inhibits NMI, INTR, debug exceptions, and single-step traps at the instruction boundary following the instruction that changes SS. Some exceptions may still occur; namely, page fault and general protection fault. Always use the 80386 LSS instruction, and the problem will not occur.
User avatar
Griwes
Member
Member
Posts: 374
Joined: Sat Jul 30, 2011 10:07 am
Libera.chat IRC: Griwes
Location: Wrocław/Racibórz, Poland
Contact:

Re: Nasm syntax problem

Post by Griwes »

That's the exact same quote as in post #15...
Reaver Project :: Repository :: Ohloh project page
<klange> This is a horror story about what happens when you need a hammer and all you have is the skulls of the damned.
<drake1> as long as the lock is read and modified by atomic operations
Antti
Member
Member
Posts: 923
Joined: Thu Jul 05, 2012 5:12 am
Location: Finland

Re: Nasm syntax problem

Post by Antti »

Is this a true uninterruptible loop? Except an SMM...

Code: Select all

; Uninterruptible Busy Loop Program (loop.asm)
; Written by Antti

; Compile: nasm -f bin -o loop.img loop.asm

[BITS 16]

start:
	cli
	xor ax, ax
	mov ss, ax
	mov sp, ax
	mov ax, 0x1000
	mov es, ax

	cld
	mov ax, 0xD08E         ; Opcodes:  "mov ss, ax"
	mov cx, 0x8000
	xor di, di
	rep stosw              ; Fill 0x10000-0x1FFFF with "mov ss, ax"

	xor ax, ax
	jmp 0x1000:0x0000

times 510 - ($ - $$) db 0
dw 0xAA55

times 1474560 - ($ - $$) db 0  ; "Standard floppy size"
EDIT: It seems that IP does not wrap around...
Post Reply