flat assembler
Message board for the users of flat assembler.

Index > Main > Will an interupt affect this?

Author
Thread Post new topic Reply to topic
l4m2



Joined: 15 Jan 2015
Posts: 651
l4m2
cs:cs:cs:cs:nop
cs:ss:movsb
66 67 66 67 mov ax,[bx]
66 mov al,5
Post 04 Aug 2015, 12:12
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17629
Location: In your JS exploiting you and your system
revolution
IIRC last segment register wins. Question
Post 04 Aug 2015, 12:28
View user's profile Send private message Visit poster's website Reply with quote
l4m2



Joined: 15 Jan 2015
Posts: 651
l4m2
revolution wrote:
I don't think
Quote:
Which segment register is used?
has the meaning of "what will happen if an interrupt happens ~"and so on
Post 05 Aug 2015, 02:13
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17629
Location: In your JS exploiting you and your system
revolution
l4m2 wrote:
... what will happen if an interrupt happens ...
Nothing unusual. The interrupt is taken and then return to the code to execute the next instruction. You can put as many prefixes as you want with the only limitation being the entire instruction length must be 15 bytes or less.


Last edited by revolution on 05 Aug 2015, 11:59; edited 1 time in total
Post 05 Aug 2015, 02:49
View user's profile Send private message Visit poster's website Reply with quote
shutdownall



Joined: 02 Apr 2010
Posts: 518
Location: Munich
shutdownall
l4m2 wrote:
revolution wrote:
I don't think
Quote:
Which segment register is used?
has the meaning of "what will happen if an interrupt happens ~"and so on


Usually interrupts will be handled at the end of an instruction only - otherwise you will have unpredicted results. What should happen if an interrupt occurs when reading the first, second, third, fourth byte of an instruction ? The interrupt interrupts the program not the current instruction.
Post 05 Aug 2015, 11:03
View user's profile Send private message Send e-mail Reply with quote
l4m2



Joined: 15 Jan 2015
Posts: 651
l4m2
Let's say 66 cs:cs:cs:...cs:mov ax,bx. the 66thrown ?
Post 05 Aug 2015, 18:10
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17629
Location: In your JS exploiting you and your system
revolution
A single instruction consists of all prefixes and the final opcode and operands, Interrupts cannot occur within an instruction. It just won't happen. Interrupts only occur between instruction boundaries.

All of the code below is considered a single instruction and an interrupt cannot occur within those 15 bytes:
Code:
cs:ds:es:fs:gs:ss:cs:ds:es:fs:gs:ss:cs:ds:nop    
Post 06 Aug 2015, 01:23
View user's profile Send private message Visit poster's website Reply with quote
Feryno



Joined: 23 Mar 2005
Posts: 454
Location: Czech republic, Slovak republic
Feryno
If I remember correctly, no more than 4 prefixes allowed. Pls consult CPU manuals. Also instruction limit is 15 bytes I think (or maybe 16?). And yes, interrupt cannot be fired inside instruction.
Post 06 Aug 2015, 08:54
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17629
Location: In your JS exploiting you and your system
revolution
It is easy to test:
Code:
include 'win32ax.inc'

.code

start:
        times 14 ds
        nop
        invoke  MessageBox,HWND_DESKTOP,'14 prefixes','14 prefixes',MB_OK
        invoke  ExitProcess,0

.end start    
If you change the times parameter to 15 the program will fault.
Post 06 Aug 2015, 09:10
View user's profile Send private message Visit poster's website Reply with quote
shutdownall



Joined: 02 Apr 2010
Posts: 518
Location: Munich
shutdownall
By the way - block instructions can be interrupted as they are executed as single instructions in a loop which maybe interrupted. On the Z80 interrupts are accepted during all LDIR/LDDR, CPIR/CPDR, OTIR/OTDR instructions. Think this is quite similar to x86 instructions with REP prefix for example - would be interesting to see if all necessary flags are restored like direction flag - would be nice to test.
Post 06 Aug 2015, 10:20
View user's profile Send private message Send e-mail Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17629
Location: In your JS exploiting you and your system
revolution
Logically something like "rep lodsb" is still a single instruction. So it can't be interrupted in the middle of rep and lodsb but it can interrupt at any iteration count. The interrupt function will see the return address pointing to the beginning of rep. Register values for [R|E]SI, [R|E]DI and [R|E]CX are updated before entering the ISR. If the ISR alters DF then [R|E]SI and [R|E]DI will go in the opposite direction from before it was interrupted. If your ISR alters DF then expect bad things to happen. But remember that the ISR can alter all register values anyway so [R|E]SI, [R|E]DI and [R|E]CX could come back with different values also.
Post 06 Aug 2015, 10:41
View user's profile Send private message Visit poster's website Reply with quote
shutdownall



Joined: 02 Apr 2010
Posts: 518
Location: Munich
shutdownall
Yes you are right - it is the job of the ISR to save the flag register and all used registers ... Cool
Post 07 Aug 2015, 00:11
View user's profile Send private message Send e-mail 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-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.