NASM to GAS assembly help
-
- Member
- Posts: 83
- Joined: Thu Jan 07, 2021 2:01 pm
NASM to GAS assembly help
Hello, I hope I'm posting this in the right place. I was just wondering if there is a resource online that specializes in converting NASM syntax to GAS. I want to learn the GAS assembly because in OSDEV, inline assembly when using GCC as a compiler is very similar to it and I would prefer to keep things consistent in my code. I ask this rather than asking "how do I convert X to Y" for every component I don't understand.
Here is what I've tried thus far:
- Google search. I feel like google's search engine is getting dumber and dumber with time. I ask google for X, it gives me Z, W, and T.
- objdump -d test.asm. It dumps the contents in GAS syntax, butb when I put it in it loses some data.
Example:
-----------------------------------
test_func:
mov eax, ds:si
ret
I create the obj file with nasm -fefli386 test.asm -o test.o
It creates the object file. Then, I do objdump -d test.o
It outputs the following:
Disassembly of section .text:
00000000 <test_func>:
0: 3e 67 8b 04 mov %ds:(%si),%eax
4: c3 ret
So, I create test2.S. Do the same thing:
test_func:
mov %ds:(%si), %eax
ret
I basically put it as it appears in the terminal.
as --32 test2.S -o test2.o
objdump -d test2.o
This is what I get:
Disassembly of section .text:
00000000 <test_func>:
0: 67 8b 04 mov (%si),%eax
3: c3 ret
Notice anything? It loses opcode 3e which is %ds from what I can tell. Clearly, I am doing something wrong. I am more familiar with NASM syntax. But I need to be able to use GAS for consistency. Whoever is able to help me with this will be my hero, lol.
Additionally, would it be possible for somebody to tell me what the proper conversion is? Is that the proper conversion? Is it an assembler optimization? What is really going on here?
- Thanks
Here is what I've tried thus far:
- Google search. I feel like google's search engine is getting dumber and dumber with time. I ask google for X, it gives me Z, W, and T.
- objdump -d test.asm. It dumps the contents in GAS syntax, butb when I put it in it loses some data.
Example:
-----------------------------------
test_func:
mov eax, ds:si
ret
I create the obj file with nasm -fefli386 test.asm -o test.o
It creates the object file. Then, I do objdump -d test.o
It outputs the following:
Disassembly of section .text:
00000000 <test_func>:
0: 3e 67 8b 04 mov %ds:(%si),%eax
4: c3 ret
So, I create test2.S. Do the same thing:
test_func:
mov %ds:(%si), %eax
ret
I basically put it as it appears in the terminal.
as --32 test2.S -o test2.o
objdump -d test2.o
This is what I get:
Disassembly of section .text:
00000000 <test_func>:
0: 67 8b 04 mov (%si),%eax
3: c3 ret
Notice anything? It loses opcode 3e which is %ds from what I can tell. Clearly, I am doing something wrong. I am more familiar with NASM syntax. But I need to be able to use GAS for consistency. Whoever is able to help me with this will be my hero, lol.
Additionally, would it be possible for somebody to tell me what the proper conversion is? Is that the proper conversion? Is it an assembler optimization? What is really going on here?
- Thanks
Re: NASM to GAS assembly help
Losing the ds segment override prefix is fine in this case, because ds is already the segment register that's used for this instruction. It is an optimization, and I'm a bit surprised nasm doesn't do it.
Working on managarm.
-
- Member
- Posts: 83
- Joined: Thu Jan 07, 2021 2:01 pm
Re: NASM to GAS assembly help
I kind of figured, thanks! But I still would like any and all resources that might help with conversions. After all, I used objdump with my memcmp and got this:
Disassembly of section .text:
00000000 <memcmp>:
0: 53 push %ebx
1: 8b 4c 24 10 mov 0x10(%esp),%ecx
5: 85 c9 test %ecx,%ecx
7: 74 2f je 38 <memcmp+0x38>
9: 8b 44 24 08 mov 0x8(%esp),%eax
d: 8b 54 24 0c mov 0xc(%esp),%edx
11: 01 c1 add %eax,%ecx
13: eb 0f jmp 24 <memcmp+0x24>
15: 8d 76 00 lea 0x0(%esi),%esi
18: 77 26 ja 40 <memcmp+0x40>
1a: 83 c0 01 add $0x1,%eax
1d: 83 c2 01 add $0x1,%edx
20: 39 c8 cmp %ecx,%eax
22: 74 14 je 38 <memcmp+0x38>
24: 0f b6 1a movzbl (%edx),%ebx
27: 38 18 cmp %bl,(%eax)
29: 73 ed jae 18 <memcmp+0x18>
2b: b8 ff ff ff ff mov $0xffffffff,%eax
30: 5b pop %ebx
31: c3 ret
32: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
38: 31 c0 xor %eax,%eax
3a: 5b pop %ebx
3b: c3 ret
3c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
40: b8 01 00 00 00 mov $0x1,%eax
45: 5b pop %ebx
46: c3 ret
Sorry for formatting. I literally copied it from my Linux VBox using guest additions. See the part where it says:
" 7: 74 2f je 38 <memcmp+0x38>"
I'm no expert with GAS, but thst doesn't seem like proper syntax.
Also, that might just prove GAS assembly is slightly better than NASM, lol
Edit:
Okay, so I was just looking at it again and realized these are jumps, meaning they would correspond to a label or an address somewhere. Is that accurate?
Disassembly of section .text:
00000000 <memcmp>:
0: 53 push %ebx
1: 8b 4c 24 10 mov 0x10(%esp),%ecx
5: 85 c9 test %ecx,%ecx
7: 74 2f je 38 <memcmp+0x38>
9: 8b 44 24 08 mov 0x8(%esp),%eax
d: 8b 54 24 0c mov 0xc(%esp),%edx
11: 01 c1 add %eax,%ecx
13: eb 0f jmp 24 <memcmp+0x24>
15: 8d 76 00 lea 0x0(%esi),%esi
18: 77 26 ja 40 <memcmp+0x40>
1a: 83 c0 01 add $0x1,%eax
1d: 83 c2 01 add $0x1,%edx
20: 39 c8 cmp %ecx,%eax
22: 74 14 je 38 <memcmp+0x38>
24: 0f b6 1a movzbl (%edx),%ebx
27: 38 18 cmp %bl,(%eax)
29: 73 ed jae 18 <memcmp+0x18>
2b: b8 ff ff ff ff mov $0xffffffff,%eax
30: 5b pop %ebx
31: c3 ret
32: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
38: 31 c0 xor %eax,%eax
3a: 5b pop %ebx
3b: c3 ret
3c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
40: b8 01 00 00 00 mov $0x1,%eax
45: 5b pop %ebx
46: c3 ret
Sorry for formatting. I literally copied it from my Linux VBox using guest additions. See the part where it says:
" 7: 74 2f je 38 <memcmp+0x38>"
I'm no expert with GAS, but thst doesn't seem like proper syntax.
Also, that might just prove GAS assembly is slightly better than NASM, lol
Edit:
Okay, so I was just looking at it again and realized these are jumps, meaning they would correspond to a label or an address somewhere. Is that accurate?
Re: NASM to GAS assembly help
objdump adds extra annotations to addresses to make it clearer what's going on, because it doesn't know about any local labels that existed in the original source code. Here, "je 38" is the actual instruction, with just the jump target address, and the "<memcmp+0x38>" part is telling you what that address corresponds to (in this case, a place within memcmp).
Working on managarm.
Re: NASM to GAS assembly help
If you for some reason need the 3e prefix, you can encode it directly:
But there are only very few situations in which that should be necessary. For example when you are making a table and need your code to be a certain length. Although you can always pad it with nops at the end as well.
BTW, please consider using a [ code ] tag next time. Makes the stuff more readable.
Basically, you have the choice between macro labels and real labels. Macro labels consist only of a decimal number at the point of definition, and you can reuse them. At the point of usage, you have to additionally say if you want the label of that name that's defined earlier ("back", therefore b) or later ("forward", therefore f) in the file. All other labels work as you'd expect, with the important caveat that all labels that start with .L don't get put into the symbol table.
Code: Select all
.byte 0x3e
mov (%si), %eax
BTW, please consider using a [ code ] tag next time. Makes the stuff more readable.
Basically all disassemblers display branches this way. Correct gas syntax would be something likeTheGameMaker90 wrote: ↑Tue Jun 18, 2024 7:00 pmI'm no expert with GAS, but thst doesn't seem like proper syntax.
Code: Select all
je 1f
...
1:
Carpe diem!
-
- Member
- Posts: 83
- Joined: Thu Jan 07, 2021 2:01 pm
Re: NASM to GAS assembly help
Ah, I see. Nope, I just wanted to know why it was missing on one but not the other. If it's not needed at a binary level, I won't put it. And alright. I didn't even remember the code tag. Been a while since I was here.
I've seen that technique used before. It can be any number (chronologically of course), right? And thank you! I was not aware that the f meant forward. I wasw always wondering about that one so you killed two birds. Here's what I'll do. I'll replace my memcmp written in C with GAS assebly based on your help and objdump and let you guys know how it went. Is there much of a performace difference? I can't imagine it would be substantial.
I've seen that technique used before. It can be any number (chronologically of course), right? And thank you! I was not aware that the f meant forward. I wasw always wondering about that one so you killed two birds. Here's what I'll do. I'll replace my memcmp written in C with GAS assebly based on your help and objdump and let you guys know how it went. Is there much of a performace difference? I can't imagine it would be substantial.
-
- Member
- Posts: 83
- Joined: Thu Jan 07, 2021 2:01 pm
Re: NASM to GAS assembly help
Okay, so I tried it with the following code:
The problem is that when using it, the return value is always the same. str1 < str2. Obviously that is not ideal. I may have to look into the documentation of GAS assembly to fix this. I will keep trying. Unless any of you kind people have a fix. I woukd greatly appreciate a better exaample of using the labels and making this work. Thanks.
Edit: I wonder if this resource is going to be helpful...:
https://en.wikibooks.org/wiki/X86_Assem ... bly_syntax
Edit2:
Okay, upon reading up on that article I managed to get an output file that looks like this:
of which is similar to the objdump file with a few major differences. I'm not sure I need all that "junk" at the top and the "_GLOBAL_OFFSET_TABLE_" stuff or even the stuff here:
but I could be wrong. If somebody would point me in the right direction, it would be helpful.
Edit 3: Good news my fellow OSDevs and software engineers! I have managed to remove said junk and effectively rewritten the memcmp function in GAS assembly! Here is my result (I will be changing the label names):
If there's any changes or optimizations you see that I could/should make, let me know and I will add your name to the list of contributers on my GitHub repository: https://github.com/PsionixSoftworks/Adamantium.
- Thanks
Code: Select all
.globl memcmp
memcmp:
push %ebx
mov 0x10(%esp), %ecx
test %ecx, %ecx
je 1f
1:
mov 0x08(%esp), %eax
mov 0x0C(%esp), %edx
add %eax, %edx
jmp 2f
2:
lea 0x00(%esi), %esi
ja 3f
3:
add $0x01, %eax
add $0x01, %edx
cmp %ecx, %eax
je 4f
4:
movzbl (%edx), %ebx
cmp %bl, (%ebx)
jae 5f
5:
mov $0xFFFFFFFF, %eax
pop %ebx
ret
lea 0x0(%esi), %esi
xor %eax, %eax
pop %ebx
ret
Edit: I wonder if this resource is going to be helpful...:
https://en.wikibooks.org/wiki/X86_Assem ... bly_syntax
Edit2:
Okay, upon reading up on that article I managed to get an output file that looks like this:
Code: Select all
.file "memcmp.c"
.text
.globl memcmp
.type memcmp, @function
memcmp:
.LFB0:
.cfi_startproc
pushl %ebp
.cfi_def_cfa_offset 8
.cfi_offset 5, -8
movl %esp, %ebp
.cfi_def_cfa_register 5
subl $16, %esp
call __x86.get_pc_thunk.ax
addl $_GLOBAL_OFFSET_TABLE_, %eax
movl 8(%ebp), %eax
movl %eax, -8(%ebp)
movl 12(%ebp), %eax
movl %eax, -4(%ebp)
movl $0, -12(%ebp)
jmp .L2
.L6:
movl -8(%ebp), %edx
movl -12(%ebp), %eax
addl %edx, %eax
movzbl (%eax), %edx
movl -4(%ebp), %ecx
movl -12(%ebp), %eax
addl %ecx, %eax
movzbl (%eax), %eax
cmpb %al, %dl
jnb .L3
movl $-1, %eax
jmp .L4
.L3:
movl -4(%ebp), %edx
movl -12(%ebp), %eax
addl %edx, %eax
movzbl (%eax), %edx
movl -8(%ebp), %ecx
movl -12(%ebp), %eax
addl %ecx, %eax
movzbl (%eax), %eax
cmpb %al, %dl
jnb .L5
movl $1, %eax
jmp .L4
.L5:
addl $1, -12(%ebp)
.L2:
movl -12(%ebp), %eax
cmpl 16(%ebp), %eax
jb .L6
movl $0, %eax
.L4:
leave
.cfi_restore 5
.cfi_def_cfa 4, 4
ret
.cfi_endproc
.LFE0:
.size memcmp, .-memcmp
.section .text.__x86.get_pc_thunk.ax,"axG",@progbits,__x86.get_pc_thunk.ax,comdat
.globl __x86.get_pc_thunk.ax
.hidden __x86.get_pc_thunk.ax
.type __x86.get_pc_thunk.ax, @function
__x86.get_pc_thunk.ax:
.LFB1:
.cfi_startproc
movl (%esp), %eax
ret
.cfi_endproc
.LFE1:
.ident "GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
.section .note.GNU-stack,"",@progbits
Code: Select all
.LFE0:
.size memcmp, .-memcmp
.section .text.__x86.get_pc_thunk.ax,"axG",@progbits,__x86.get_pc_thunk.ax,comdat
.globl __x86.get_pc_thunk.ax
.hidden __x86.get_pc_thunk.ax
.type __x86.get_pc_thunk.ax, @function
Edit 3: Good news my fellow OSDevs and software engineers! I have managed to remove said junk and effectively rewritten the memcmp function in GAS assembly! Here is my result (I will be changing the label names):
Code: Select all
.code32
.text
.globl memcmp
memcmp:
push %ebp
movl %esp, %ebp
subl $16, %esp
movl 8(%ebp), %eax
movl %eax, -8(%ebp)
movl 12(%ebp), %eax
movl %eax, -4(%ebp)
movl $0, -12(%ebp)
jmp .L2
.L6:
movl -8(%ebp), %edx
movl -12(%ebp), %eax
addl %edx, %eax
movzbl (%eax), %edx
movl -4(%ebp), %ecx
movl -12(%ebp), %eax
addl %ecx, %eax
movzbl (%eax), %eax
cmpb %al, %dl
jnb .L3
movl $-1, %eax
jmp .L4
.L3:
movl -4(%ebp), %edx
movl -12(%ebp), %eax
addl %edx, %eax
movzbl (%eax), %edx
movl -8(%ebp), %ecx
movl -12(%ebp), %eax
addl %ecx, %eax
movzbl (%eax), %eax
cmpb %al, %dl
jnb .L5
movl $1, %eax
jmp .L4
.L5:
addl $1, -12(%ebp)
.L2:
movl -12(%ebp), %eax
cmpl 16(%ebp), %eax
jb .L6
movl $0, %eax
.L4:
leave
ret
- Thanks
Re: NASM to GAS assembly help
This and all of the other jumps in the code are effectively nops. They all jump to the next instruction if the condition passes, so they do the same thing in both cases.
I converted the code a bit more accurately into assembler source code:
Code: Select all
push %ebx
mov 0x10(%esp),%ecx
test %ecx,%ecx
je 3f
mov 0x8(%esp),%eax
mov 0xc(%esp),%edx
add %eax,%ecx
jmp 2f
lea 0x0(%esi),%esi
1:
ja 4f
add $0x1,%eax
add $0x1,%edx
cmp %ecx,%eax
je 3f
2:
movzbl (%edx),%ebx
cmp %bl,(%eax)
jae 1b
mov $0xffffffff,%eax
pop %ebx
ret
lea 0x0(%esi),%esi
3:
xor %eax,%eax
pop %ebx
ret
lea 0x0(%esi,%eiz,1),%esi
4:
mov $0x1,%eax
pop %ebx
ret
That looks suspiciously like GCC output. GCC is of course not going to write assembler in a style you would use. Unless you often call your labels ".LC0" and the like.TheGameMaker90 wrote: ↑Wed Jun 19, 2024 10:20 am Okay, upon reading up on that article I managed to get an output file that looks like this:
To answer your further questions: Everything starting with a . is a pseudo-instruction. It instructs the assembler to do something (other than to assemble an instruction). All the ones starting with ".cfi" are call frame information directives. They generate data for the .eh_frame section, so if your code gets interrupted asynchronously, the unwinder knows how to unwind through the function. For your purposes, you can entirely ignore those.
The _GLOBAL_OFFSET_TABLE_ exists for position independent code. But the code is really dumb, since after calculating the pointer in EAX (probably wrongly) it gets overwritten immediately. This makes me think you were not compiling on the highest optimization level. That also makes the entire "get_pc_thunk.ax" thing uninteresting to talk about. It is a thing that GCC puts into position-independent builds on i386: In order to get the address of the global offset table, you have to find your current runtime address. On architectures without PC-relative addressing, like i386, this is done with a self-call:
Code: Select all
call 1f
1: pop %eax # now EAX contains the runtime address of label 1
add $_GLOBAL_OFFSET_TABLE_-1b, %eax # now EAX contains the runtime address of the GOT
Code: Select all
func: mov (%esp), %eax
ret
...
call func
1:# now EAX contains the runtime address of label 1
But it is not sensible to establish a GOT pointer in a function that doesn't call any other functions or references any static memory. So this should probably have been removed, and the compiler would likely have done that at a higher optimization level.
BTW, here's how I would do it:
Code: Select all
memcmp:
pushl %esi
pushl %edi
movl 12(%esp), %esi
movl 16(%esp), %edi
movl 20(%esp), %ecx
testl %ecx, %ecx
jz .Lret0
1:
movzbl (%esi), %eax
movzbl (%edi), %edx
subl %edx, %eax
jnz .Lret
incl %esi
incl %edi
decl %ecx
jnz 1b
.Lret0:
xorl %eax, %eax
.Lret:
popl %edi
popl %esi
retl
Carpe diem!
-
- Member
- Posts: 83
- Joined: Thu Jan 07, 2021 2:01 pm
Re: NASM to GAS assembly help
Thank you for the detailed explanation! I would give you the rest of the .S files to convert, but if you really want to help, I've linked the GitHub repository in my last post. As mentioned, I will add your name to the list of contributers if you do so. But the commit has to be done by you. Also, I can't find it anywhere, but how do you pass parameters in GAS assembly? I found a resource a long time ago with help on it, but I can't seem to find it.
basically, I'm trying to do the equivalent of this:
in gas. I can't seem to figure it out. I've tried
and most other combinations you might think of. objdump doesn't give me the help I need and I am trying to get the GDT pointer passed in as a parameter to my gtd_install code.
basically, I'm trying to do the equivalent of this:
Code: Select all
mov eax, [esp+4]
Code: Select all
movl 4(%esp), %eax
movl -4(%esp), %eax
movl 8(%esp), %eax
-
- Member
- Posts: 5512
- Joined: Mon Mar 25, 2013 7:01 pm
Re: NASM to GAS assembly help
If you're replicating your compiler's output in assembly, you'll get the same binary, so there won't be any difference in performance. (And if you're just going to get the same binary anyway, why bother rewriting the code in assembly in the first place?)TheGameMaker90 wrote: ↑Wed Jun 19, 2024 9:54 amIs there much of a performace difference? I can't imagine it would be substantial.
Same way you do in NASM assembly. Parameter passing depends on the ABI, not the assembler syntax.TheGameMaker90 wrote: ↑Wed Jun 19, 2024 1:50 pmAlso, I can't find it anywhere, but how do you pass parameters in GAS assembly?
The first one you listed is equivalent to the NASM syntax. But it'll only work if this is the correct way to access the parameter you're passing, and you didn't say what kind of parameter it is.TheGameMaker90 wrote: ↑Wed Jun 19, 2024 1:50 pmbasically, I'm trying to do the equivalent of this:in gas. I can't seem to figure it out. I've triedCode: Select all
mov eax, [esp+4]
Code: Select all
movl 4(%esp), %eax
-
- Member
- Posts: 83
- Joined: Thu Jan 07, 2021 2:01 pm
Re: NASM to GAS assembly help
I know that, I just mean that if it was modified. So if I found a similar way to do it in GAS assembly, it probably wouldn't get much more efficient because it can only be optimized so much before you're just trying to perfect perfection.Octocontrabass wrote: ↑Wed Jun 19, 2024 2:27 pmIf you're replicating your compiler's output in assembly, you'll get the same binary, so there won't be any difference in performance. (And if you're just going to get the same binary anyway, why bother rewriting the code in assembly in the first place?)TheGameMaker90 wrote: ↑Wed Jun 19, 2024 9:54 amIs there much of a performace difference? I can't imagine it would be substantial.
Same way you do in NASM assembly. Parameter passing depends on the ABI, not the assembler syntax.TheGameMaker90 wrote: ↑Wed Jun 19, 2024 1:50 pmAlso, I can't find it anywhere, but how do you pass parameters in GAS assembly?
The first one you listed is equivalent to the NASM syntax. But it'll only work if this is the correct way to access the parameter you're passing, and you didn't say what kind of parameter it is.TheGameMaker90 wrote: ↑Wed Jun 19, 2024 1:50 pmbasically, I'm trying to do the equivalent of this:in gas. I can't seem to figure it out. I've triedCode: Select all
mov eax, [esp+4]
Code: Select all
movl 4(%esp), %eax
Yes, that's why I said "i'm trying to do the equivalent of this." in other words, I want to do that but in GAS. And the syntax is important. Am I right that a digit has to go before the '(' in the expression? If not, what should it look like I mean. I can't just write it as it appears in NASM assembly. That wouldm produce an error. So my question is how are parameters formatted in GAS assembly. I merely put that there so somebody could give me the translation. And the parameter is of type 32-bit integer. It's literally just loading the GDT pointer in GAS assembly. I have the segments setup and
Code: Select all
lgdt (%eax)
-
- Member
- Posts: 5512
- Joined: Mon Mar 25, 2013 7:01 pm
Re: NASM to GAS assembly help
You have to measure to know for sure, but I wouldn't be surprised if you could make it a bit faster by reducing it to fewer instructions. For example, nullplan combined the comparison and the return value calculation into a single SUB instruction.TheGameMaker90 wrote: ↑Wed Jun 19, 2024 3:31 pmI know that, I just mean that if it was modified. So if I found a similar way to do it in GAS assembly, it probably wouldn't get much more efficient because it can only be optimized so much before you're just trying to perfect perfection.
Yes, the displacement goes before the "(" in an address operand.TheGameMaker90 wrote: ↑Wed Jun 19, 2024 3:31 pmAm I right that a digit has to go before the '(' in the expression?
Memory operands in AT&T syntax are formatted as "displacement(%base,%index,scale)". You must specify them in that order, though you can leave out the parts you aren't using. The equivalent in NASM syntax would be something like "[base+index*scale+displacement]", although NASM will allow you to specify them in whatever order you like as long as it's algebraically equivalent. (NASM will even accept things like "[eax*3]" since it's equivalent to "[eax+eax*2]".)TheGameMaker90 wrote: ↑Wed Jun 19, 2024 3:31 pmSo my question is how are parameters formatted in GAS assembly.
Then yes, assuming you haven't done anything that would change ESP like pushing stuff onto the stack, that's the correct instruction.
It's usually helpful to run QEMU with "-d int" (and also "-no-reboot") when you're trying to figure out a triple fault.TheGameMaker90 wrote: ↑Wed Jun 19, 2024 3:31 pmJust started a few days ago and the system keeps restarting every time I hit enter on the GRUB boot menu.
-
- Member
- Posts: 83
- Joined: Thu Jan 07, 2021 2:01 pm
Re: NASM to GAS assembly help
Awesome, thanks for all of the tips! And thanks for showing me that trick with the debug flag. It actually shows me things like GDT = and the value stored at that memory location. At the bottom however, there is something I'm unfamiliar with:
check_exception old: 0x8 new 0xd
What does that mean? Should I be long jumping to 0x0D instead of 0x08 in my GDT? Or something else? Also, if I wanted to dothe whole GDT in GAS assembly, how would I get the GDT pointer? Here is my code:
To my understanding, it is the equivalent of:
yes? If so, how would I do the part under gdt_pointer? (Perhaps it will be easier than trying to load the GDT from C into an assembly function).
check_exception old: 0x8 new 0xd
What does that mean? Should I be long jumping to 0x0D instead of 0x08 in my GDT? Or something else? Also, if I wanted to dothe whole GDT in GAS assembly, how would I get the GDT pointer? Here is my code:
Code: Select all
.code16
.text
.globl gdt_pointer
gdt_start:
.long 0x0
gdt_code:
.word 0xFFFF
.word 0x0000
.byte 0x00
.byte 0x9A
.byte 0xCF
.byte 0x00
gdt_data:
.word 0xFFFF
.word 0x0000
.byte 0x00
.byte 0x92
.byte 0xCF
.byte 0x00
gdt_end:
gdt_pointer:
Code: Select all
gdt_start:
dq 0x0
gdt_code:
dw 0xFFFF
dw 0x0000
db 0x00
db 0x9A
db 0xCF
db 0x00
gdt_data:
dw 0xFFFF
dw 0x0000
db 0x00
db 0x92
db 0xCF
db 0x00
gdt_end:
gdt_pointer:
dw gdt_end - gdt_start
dd gdt_start
-
- Member
- Posts: 5512
- Joined: Mon Mar 25, 2013 7:01 pm
Re: NASM to GAS assembly help
It means the CPU tried to jump to the exception handler for a double fault (0x8) but there was a problem that caused a general protection fault (0xd). Since you don't have an IDT yet, that's not surprising. The previous entry in the log should be the double fault, and before that should be the exception you're trying to debug.TheGameMaker90 wrote: ↑Tue Jun 25, 2024 10:46 amcheck_exception old: 0x8 new 0xd
What does that mean?
No, it's not equivalent. You need to use ".quad" instead of ".long".
The same way you did it with NASM, just replace "dw" and "dd" with the GAS equivalents.
If you're having this much trouble passing a parameter from C to assembly, you might have a bug somewhere else in your code.TheGameMaker90 wrote: ↑Tue Jun 25, 2024 10:46 am(Perhaps it will be easier than trying to load the GDT from C into an assembly function).
-
- Member
- Posts: 83
- Joined: Thu Jan 07, 2021 2:01 pm
Re: NASM to GAS assembly help
Thanks, I will change it to .quad, and...
If I knew the gas equivalent, the topic wouldn't be called nasm to gas assembly help, lol.
Edit:
Okay, so with a bit of research, I managed to (hopefully) figure it out. However, with the debug output from qemu, the GDT is all 0's. Like here's what it says for GDT:
GDT= 00000000 00000000
I assume that means it's not installed. Here is my updated code:
The gdt_install label is then called externally and used in my main.c (actually init/kernel.c) file:
To no avail. It doesn't triple fault anymore, but I think that's just because it's not finding the GDT at all...
oddly enough, under IDT (which I haven't even begun working on) says:
IDT= 00000000 000003ff
and LDT (which I also haven't created [yet]):
LDT=0000 00000000 0000ffff 00008200
Edit2:
Okay, I just noticed the list of output symbols is longer than santa's christmas list. There is a repeating pattern of things. I'llpaste the full output of the debug $#!+. Brace yourselves:
EAX=00000001 EBX=00000000 ECX=02000000 EDX=02000628
ESI=0000000b EDI=02000000 EBP=00014900 ESP=00006c5c
EIP=000e9bb1 EFL=00000002 [-------] CPL=0 II=0 A20=1 SMM=0 HLT=0
ES =0010 00000000 ffffffff 00cf9300 DPL=0 DS [-WA]
CS =0008 00000000 ffffffff 00cf9b00 DPL=0 CS32 [-RA]
SS =0010 00000000 ffffffff 00cf9300 DPL=0 DS [-WA]
DS =0010 00000000 ffffffff 00cf9300 DPL=0 DS [-WA]
FS =0010 00000000 ffffffff 00cf9300 DPL=0 DS [-WA]
GS =0010 00000000 ffffffff 00cf9300 DPL=0 DS [-WA]
LDT=0000 00000000 0000ffff 00008200 DPL=0 LDT
TR =0000 00000000 0000ffff 00008b00 DPL=0 TSS32-busy
GDT= 000f6180 00000037
IDT= 000f61be 00000000
CR0=00000011 CR2=00000000 CR3=00000000 CR4=00000000
DR0=00000000 DR1=00000000 DR2=00000000 DR3=00000000
DR6=ffff0ff0 DR7=00000400
CCS=00000080 CCD=00000001 CCO=LOGICB
EFER=0000000000000000
SMM: after RSM
EAX=00000001 EBX=00000000 ECX=02000000 EDX=02000628
ESI=0000000b EDI=02000000 EBP=00014900 ESP=00006c5c
EIP=000e9bb1 EFL=00000002 [-------] CPL=0 II=0 A20=1 SMM=0 HLT=0
ES =0010 00000000 ffffffff 00c09300 DPL=0 DS [-WA]
CS =0008 00000000 ffffffff 00c09b00 DPL=0 CS32 [-RA]
SS =0010 00000000 ffffffff 00c09300 DPL=0 DS [-WA]
DS =0010 00000000 ffffffff 00c09300 DPL=0 DS [-WA]
FS =0010 00000000 ffffffff 00c09300 DPL=0 DS [-WA]
GS =0010 00000000 ffffffff 00c09300 DPL=0 DS [-WA]
LDT=0000 00000000 0000ffff 00008200 DPL=0 LDT
TR =0000 00000000 0000ffff 00008b00 DPL=0 TSS32-busy
GDT= 000f6180 00000037
IDT= 000f61be 00000000
CR0=00000011 CR2=00000000 CR3=00000000 CR4=00000000
DR0=00000000 DR1=00000000 DR2=00000000 DR3=00000000
DR6=ffff0ff0 DR7=00000400
CCS=00000000 CCD=00000000 CCO=EFLAGS
EFER=0000000000000000
SMM: enter
EAX=000000b5 EBX=000f7d2a ECX=00001234 EDX=00006cff
ESI=00006cb8 EDI=07fbec71 EBP=00006c78 ESP=00006c78
EIP=00007d29 EFL=00000006 [-----P-] CPL=0 II=0 A20=1 SMM=0 HLT=0
ES =d980 000d9800 ffffffff 008f9300
CS =f000 000f0000 ffffffff 008f9b00
SS =0000 00000000 ffffffff 008f9300
DS =0000 00000000 ffffffff 008f9300
FS =0000 00000000 ffffffff 008f9300
GS =0000 00000000 ffffffff 008f9300
LDT=0000 00000000 0000ffff 00008200
TR =0000 00000000 0000ffff 00008b00
GDT= 00000000 00000000
IDT= 00000000 000003ff
CR0=00000010 CR2=00000000 CR3=00000000 CR4=00000000
DR0=00000000 DR1=00000000 DR2=00000000 DR3=00000000
DR6=ffff0ff0 DR7=00000400
CCS=00000004 CCD=00006c78 CCO=EFLAGS
EFER=0000000000000000
SMM: after RSM
EAX=000000b5 EBX=000f7d2a ECX=00001234 EDX=00006cff
ESI=00006cb8 EDI=07fbec71 EBP=00006c78 ESP=00006c78
EIP=000f7d2a EFL=00000002 [-------] CPL=0 II=0 A20=1 SMM=0 HLT=0
ES =0010 00000000 ffffffff 00c09300 DPL=0 DS [-WA]
CS =0008 00000000 ffffffff 00c09b00 DPL=0 CS32 [-RA]
SS =0010 00000000 ffffffff 00c09300 DPL=0 DS [-WA]
DS =0010 00000000 ffffffff 00c09300 DPL=0 DS [-WA]
FS =0010 00000000 ffffffff 00c09300 DPL=0 DS [-WA]
GS =0010 00000000 ffffffff 00c09300 DPL=0 DS [-WA]
LDT=0000 00000000 0000ffff 00008200 DPL=0 LDT
TR =0000 00000000 0000ffff 00008b00 DPL=0 TSS32-busy
GDT= 000f6180 00000037
IDT= 000f61be 00000000
CR0=00000011 CR2=00000000 CR3=00000000 CR4=00000000
DR0=00000000 DR1=00000000 DR2=00000000 DR3=00000000
DR6=ffff0ff0 DR7=00000400
CCS=00000000 CCD=00000000 CCO=EFLAGS
EFER=0000000000000000
SMM: enter
EAX=000000b5 EBX=00007d44 ECX=00005678 EDX=07fa91c0
ESI=000e8d00 EDI=07fbec71 EBP=00006c78 ESP=00006c78
EIP=000f7d43 EFL=00000012 [----A--] CPL=0 II=0 A20=1 SMM=0 HLT=0
ES =0010 00000000 ffffffff 00c09300 DPL=0 DS [-WA]
CS =0008 00000000 ffffffff 00c09b00 DPL=0 CS32 [-RA]
SS =0010 00000000 ffffffff 00c09300 DPL=0 DS [-WA]
DS =0010 00000000 ffffffff 00c09300 DPL=0 DS [-WA]
FS =0010 00000000 ffffffff 00c09300 DPL=0 DS [-WA]
GS =0010 00000000 ffffffff 00c09300 DPL=0 DS [-WA]
LDT=0000 00000000 0000ffff 00008200 DPL=0 LDT
TR =0000 00000000 0000ffff 00008b00 DPL=0 TSS32-busy
GDT= 000f6180 00000037
IDT= 000f61be 00000000
CR0=00000011 CR2=00000000 CR3=00000000 CR4=00000000
DR0=00000000 DR1=00000000 DR2=00000000 DR3=00000000
DR6=ffff0ff0 DR7=00000400
CCS=00000010 CCD=00006c64 CCO=EFLAGS
EFER=0000000000000000
SMM: after RSM
EAX=000000b5 EBX=00007d44 ECX=00005678 EDX=07fa91c0
ESI=000e8d00 EDI=07fbec71 EBP=00006c78 ESP=00006c78
EIP=00007d44 EFL=00000006 [-----P-] CPL=0 II=0 A20=1 SMM=0 HLT=0
ES =d980 000d9800 ffffffff 00809300
CS =f000 000f0000 ffffffff 00809b00
SS =0000 00000000 ffffffff 00809300
DS =0000 00000000 ffffffff 00809300
FS =0000 00000000 ffffffff 00809300
GS =0000 00000000 ffffffff 00809300
LDT=0000 00000000 0000ffff 00008200
TR =0000 00000000 0000ffff 00008b00
GDT= 00000000 00000000
IDT= 00000000 000003ff
CR0=00000010 CR2=00000000 CR3=00000000 CR4=00000000
DR0=00000000 DR1=00000000 DR2=00000000 DR3=00000000
DR6=ffff0ff0 DR7=00000400
CCS=00000004 CCD=00000001 CCO=EFLAGS
EFER=0000000000000000
SMM: enter
EAX=000000b5 EBX=000f7d2a ECX=00001234 EDX=000069ff
ESI=0000699e EDI=07fbec71 EBP=0000695e ESP=0000695e
EIP=00007d29 EFL=00000002 [-------] CPL=0 II=0 A20=1 SMM=0 HLT=0
ES =d980 000d9800 ffffffff 008f9300
CS =f000 000f0000 ffffffff 008f9b00
SS =0000 00000000 ffffffff 008f9300
DS =0000 00000000 ffffffff 008f9300
FS =0000 00000000 ffffffff 008f9300
GS =ca00 000ca000 ffffffff 008f9300
LDT=0000 00000000 0000ffff 00008200
TR =0000 00000000 0000ffff 00008b00
GDT= 00000000 00000000
IDT= 00000000 000003ff
CR0=00000010 CR2=00000000 CR3=00000000 CR4=00000000
DR0=00000000 DR1=00000000 DR2=00000000 DR3=00000000
DR6=ffff0ff0 DR7=00000400
CCS=00000000 CCD=0000695e CCO=EFLAGS
EFER=0000000000000000
SMM: after RSM
EAX=000000b5 EBX=000f7d2a ECX=00001234 EDX=000069ff
ESI=0000699e EDI=07fbec71 EBP=0000695e ESP=0000695e
EIP=000f7d2a EFL=00000002 [-------] CPL=0 II=0 A20=1 SMM=0 HLT=0
ES =0010 00000000 ffffffff 00c09300 DPL=0 DS [-WA]
CS =0008 00000000 ffffffff 00c09b00 DPL=0 CS32 [-RA]
SS =0010 00000000 ffffffff 00c09300 DPL=0 DS [-WA]
DS =0010 00000000 ffffffff 00c09300 DPL=0 DS [-WA]
FS =0010 00000000 ffffffff 00c09300 DPL=0 DS [-WA]
GS =0010 00000000 ffffffff 00c09300 DPL=0 DS [-WA]
LDT=0000 00000000 0000ffff 00008200 DPL=0 LDT
TR =0000 00000000 0000ffff 00008b00 DPL=0 TSS32-busy
GDT= 000f6180 00000037
IDT= 000f61be 00000000
CR0=00000011 CR2=00000000 CR3=00000000 CR4=00000000
DR0=00000000 DR1=00000000 DR2=00000000 DR3=00000000
DR6=ffff0ff0 DR7=00000400
CCS=00000000 CCD=00000000 CCO=EFLAGS
EFER=0000000000000000
SMM: enter
EAX=000000b5 EBX=00007d44 ECX=00005678 EDX=00000005
ESI=00000000 EDI=07fbec71 EBP=0000695e ESP=0000695e
EIP=000f7d43 EFL=00000012 [----A--] CPL=0 II=0 A20=1 SMM=0 HLT=0
ES =0010 00000000 ffffffff 00c09300 DPL=0 DS [-WA]
CS =0008 00000000 ffffffff 00c09b00 DPL=0 CS32 [-RA]
SS =0010 00000000 ffffffff 00c09300 DPL=0 DS [-WA]
DS =0010 00000000 ffffffff 00c09300 DPL=0 DS [-WA]
FS =0010 00000000 ffffffff 00c09300 DPL=0 DS [-WA]
GS =0010 00000000 ffffffff 00c09300 DPL=0 DS [-WA]
LDT=0000 00000000 0000ffff 00008200 DPL=0 LDT
TR =0000 00000000 0000ffff 00008b00 DPL=0 TSS32-busy
GDT= 000f6180 00000037
IDT= 000f61be 00000000
CR0=00000011 CR2=00000000 CR3=00000000 CR4=00000000
DR0=00000000 DR1=00000000 DR2=00000000 DR3=00000000
DR6=ffff0ff0 DR7=00000400
CCS=00000010 CCD=0000694a CCO=EFLAGS
EFER=0000000000000000
SMM: after RSM
EAX=000000b5 EBX=00007d44 ECX=00005678 EDX=00000005
ESI=00000000 EDI=07fbec71 EBP=0000695e ESP=0000695e
EIP=00007d44 EFL=00000002 [-------] CPL=0 II=0 A20=1 SMM=0 HLT=0
ES =d980 000d9800 ffffffff 00809300
CS =f000 000f0000 ffffffff 00809b00
SS =0000 00000000 ffffffff 00809300
DS =0000 00000000 ffffffff 00809300
FS =0000 00000000 ffffffff 00809300
GS =ca00 000ca000 ffffffff 00809300
LDT=0000 00000000 0000ffff 00008200
TR =0000 00000000 0000ffff 00008b00
GDT= 00000000 00000000
IDT= 00000000 000003ff
CR0=00000010 CR2=00000000 CR3=00000000 CR4=00000000
DR0=00000000 DR1=00000000 DR2=00000000 DR3=00000000
DR6=ffff0ff0 DR7=00000400
CCS=00000000 CCD=00000001 CCO=EFLAGS
EFER=0000000000000000
SMM: enter
EAX=000000b5 EBX=000f7d2a ECX=00001234 EDX=000069ff
ESI=00006998 EDI=07fbec71 EBP=00006958 ESP=00006958
EIP=00007d29 EFL=00000002 [-------] CPL=0 II=0 A20=1 SMM=0 HLT=0
ES =d980 000d9800 ffffffff 00809300
CS =f000 000f0000 ffffffff 00809b00
SS =0000 00000000 ffffffff 00809300
DS =0000 00000000 ffffffff 00809300
FS =0000 00000000 ffffffff 00809300
GS =ca00 000ca000 ffffffff 00809300
LDT=0000 00000000 0000ffff 00008200
TR =0000 00000000 0000ffff 00008b00
GDT= 00000000 00000000
IDT= 00000000 000003ff
CR0=00000010 CR2=00000000 CR3=00000000 CR4=00000000
DR0=00000000 DR1=00000000 DR2=00000000 DR3=00000000
DR6=ffff0ff0 DR7=00000400
CCS=00000000 CCD=00006958 CCO=EFLAGS
EFER=0000000000000000
SMM: after RSM
EAX=000000b5 EBX=000f7d2a ECX=00001234 EDX=000069ff
ESI=00006998 EDI=07fbec71 EBP=00006958 ESP=00006958
EIP=000f7d2a EFL=00000002 [-------] CPL=0 II=0 A20=1 SMM=0 HLT=0
ES =0010 00000000 ffffffff 00c09300 DPL=0 DS [-WA]
CS =0008 00000000 ffffffff 00c09b00 DPL=0 CS32 [-RA]
SS =0010 00000000 ffffffff 00c09300 DPL=0 DS [-WA]
DS =0010 00000000 ffffffff 00c09300 DPL=0 DS [-WA]
FS =0010 00000000 ffffffff 00c09300 DPL=0 DS [-WA]
GS =0010 00000000 ffffffff 00c09300 DPL=0 DS [-WA]
LDT=0000 00000000 0000ffff 00008200 DPL=0 LDT
TR =0000 00000000 0000ffff 00008b00 DPL=0 TSS32-busy
GDT= 000f6180 00000037
IDT= 000f61be 00000000
CR0=00000011 CR2=00000000 CR3=00000000 CR4=00000000
DR0=00000000 DR1=00000000 DR2=00000000 DR3=00000000
DR6=ffff0ff0 DR7=00000400
CCS=00000000 CCD=00000000 CCO=EFLAGS
EFER=0000000000000000
SMM: enter
EAX=000000b5 EBX=00007d44 ECX=00005678 EDX=00000003
ESI=07f8b590 EDI=07fbec71 EBP=00006958 ESP=00006958
EIP=000f7d43 EFL=00000016 [----AP-] CPL=0 II=0 A20=1 SMM=0 HLT=0
ES =0010 00000000 ffffffff 00c09300 DPL=0 DS [-WA]
CS =0008 00000000 ffffffff 00c09b00 DPL=0 CS32 [-RA]
SS =0010 00000000 ffffffff 00c09300 DPL=0 DS [-WA]
DS =0010 00000000 ffffffff 00c09300 DPL=0 DS [-WA]
FS =0010 00000000 ffffffff 00c09300 DPL=0 DS [-WA]
GS =0010 00000000 ffffffff 00c09300 DPL=0 DS [-WA]
LDT=0000 00000000 0000ffff 00008200 DPL=0 LDT
TR =0000 00000000 0000ffff 00008b00 DPL=0 TSS32-busy
GDT= 000f6180 00000037
IDT= 000f61be 00000000
CR0=00000011 CR2=00000000 CR3=00000000 CR4=00000000
DR0=00000000 DR1=00000000 DR2=00000000 DR3=00000000
DR6=ffff0ff0 DR7=00000400
CCS=00000014 CCD=00006944 CCO=EFLAGS
EFER=0000000000000000
SMM: after RSM
EAX=000000b5 EBX=00007d44 ECX=00005678 EDX=00000003
ESI=07f8b590 EDI=07fbec71 EBP=00006958 ESP=00006958
EIP=00007d44 EFL=00000002 [-------] CPL=0 II=0 A20=1 SMM=0 HLT=0
ES =d980 000d9800 ffffffff 00809300
CS =f000 000f0000 ffffffff 00809b00
SS =0000 00000000 ffffffff 00809300
DS =0000 00000000 ffffffff 00809300
FS =0000 00000000 ffffffff 00809300
GS =ca00 000ca000 ffffffff 00809300
LDT=0000 00000000 0000ffff 00008200
TR =0000 00000000 0000ffff 00008b00
GDT= 00000000 00000000
IDT= 00000000 000003ff
CR0=00000010 CR2=00000000 CR3=00000000 CR4=00000000
DR0=00000000 DR1=00000000 DR2=00000000 DR3=00000000
DR6=ffff0ff0 DR7=00000400
CCS=00000000 CCD=00000001 CCO=EFLAGS
EFER=0000000000000000
SMM: enter
EAX=000000b5 EBX=000f7d2a ECX=00001234 EDX=000069ff
ESI=0000699e EDI=07fbec71 EBP=0000695e ESP=0000695e
EIP=00007d29 EFL=00000002 [-------] CPL=0 II=0 A20=1 SMM=0 HLT=0
ES =d980 000d9800 ffffffff 00809300
CS =f000 000f0000 ffffffff 00809b00
SS =0000 00000000 ffffffff 00809300
DS =0000 00000000 ffffffff 00809300
FS =0000 00000000 ffffffff 00809300
GS =ca00 000ca000 ffffffff 00809300
LDT=0000 00000000 0000ffff 00008200
TR =0000 00000000 0000ffff 00008b00
GDT= 00000000 00000000
IDT= 00000000 000003ff
CR0=00000010 CR2=00000000 CR3=00000000 CR4=00000000
DR0=00000000 DR1=00000000 DR2=00000000 DR3=00000000
DR6=ffff0ff0 DR7=00000400
CCS=00000000 CCD=0000695e CCO=EFLAGS
EFER=0000000000000000
SMM: after RSM
EAX=000000b5 EBX=000f7d2a ECX=00001234 EDX=000069ff
ESI=0000699e EDI=07fbec71 EBP=0000695e ESP=0000695e
EIP=000f7d2a EFL=00000002 [-------] CPL=0 II=0 A20=1 SMM=0 HLT=0
ES =0010 00000000 ffffffff 00c09300 DPL=0 DS [-WA]
CS =0008 00000000 ffffffff 00c09b00 DPL=0 CS32 [-RA]
SS =0010 00000000 ffffffff 00c09300 DPL=0 DS [-WA]
DS =0010 00000000 ffffffff 00c09300 DPL=0 DS [-WA]
FS =0010 00000000 ffffffff 00c09300 DPL=0 DS [-WA]
GS =0010 00000000 ffffffff 00c09300 DPL=0 DS [-WA]
LDT=0000 00000000 0000ffff 00008200 DPL=0 LDT
TR =0000 00000000 0000ffff 00008b00 DPL=0 TSS32-busy
GDT= 000f6180 00000037
IDT= 000f61be 00000000
CR0=00000011 CR2=00000000 CR3=00000000 CR4=00000000
DR0=00000000 DR1=00000000 DR2=00000000 DR3=00000000
DR6=ffff0ff0 DR7=00000400
CCS=00000000 CCD=00000000 CCO=EFLAGS
EFER=0000000000000000
SMM: enter
EAX=000000b5 EBX=00007d44 ECX=00005678 EDX=00000005
ESI=00000000 EDI=07fbec71 EBP=0000695e ESP=0000695e
EIP=000f7d43 EFL=00000012 [----A--] CPL=0 II=0 A20=1 SMM=0 HLT=0
ES =0010 00000000 ffffffff 00c09300 DPL=0 DS [-WA]
CS =0008 00000000 ffffffff 00c09b00 DPL=0 CS32 [-RA]
SS =0010 00000000 ffffffff 00c09300 DPL=0 DS [-WA]
DS =0010 00000000 ffffffff 00c09300 DPL=0 DS [-WA]
FS =0010 00000000 ffffffff 00c09300 DPL=0 DS [-WA]
GS =0010 00000000 ffffffff 00c09300 DPL=0 DS [-WA]
LDT=0000 00000000 0000ffff 00008200 DPL=0 LDT
TR =0000 00000000 0000ffff 00008b00 DPL=0 TSS32-busy
GDT= 000f6180 00000037
IDT= 000f61be 00000000
CR0=00000011 CR2=00000000 CR3=00000000 CR4=00000000
DR0=00000000 DR1=00000000 DR2=00000000 DR3=00000000
DR6=ffff0ff0 DR7=00000400
CCS=00000010 CCD=0000694a CCO=EFLAGS
EFER=0000000000000000
SMM: after RSM
EAX=000000b5 EBX=00007d44 ECX=00005678 EDX=00000005
ESI=00000000 EDI=07fbec71 EBP=0000695e ESP=0000695e
EIP=00007d44 EFL=00000002 [-------] CPL=0 II=0 A20=1 SMM=0 HLT=0
ES =d980 000d9800 ffffffff 00809300
CS =f000 000f0000 ffffffff 00809b00
SS =0000 00000000 ffffffff 00809300
DS =0000 00000000 ffffffff 00809300
FS =0000 00000000 ffffffff 00809300
GS =ca00 000ca000 ffffffff 00809300
LDT=0000 00000000 0000ffff 00008200
TR =0000 00000000 0000ffff 00008b00
GDT= 00000000 00000000
IDT= 00000000 000003ff
CR0=00000010 CR2=00000000 CR3=00000000 CR4=00000000
DR0=00000000 DR1=00000000 DR2=00000000 DR3=00000000
DR6=ffff0ff0 DR7=00000400
CCS=00000000 CCD=00000001 CCO=EFLAGS
EFER=0000000000000000
SMM: enter
EAX=000000b5 EBX=000f7d2a ECX=00001234 EDX=000069ff
ESI=00006998 EDI=07fbec71 EBP=00006958 ESP=00006958
EIP=00007d29 EFL=00000002 [-------] CPL=0 II=0 A20=1 SMM=0 HLT=0
ES =d980 000d9800 ffffffff 00809300
CS =f000 000f0000 ffffffff 00809b00
SS =0000 00000000 ffffffff 00809300
DS =0000 00000000 ffffffff 00809300
FS =0000 00000000 ffffffff 00809300
GS =ca00 000ca000 ffffffff 00809300
LDT=0000 00000000 0000ffff 00008200
TR =0000 00000000 0000ffff 00008b00
GDT= 00000000 00000000
IDT= 00000000 000003ff
CR0=00000010 CR2=00000000 CR3=00000000 CR4=00000000
DR0=00000000 DR1=00000000 DR2=00000000 DR3=00000000
DR6=ffff0ff0 DR7=00000400
CCS=00000000 CCD=00006958 CCO=EFLAGS
EFER=0000000000000000
SMM: after RSM
EAX=000000b5 EBX=000f7d2a ECX=00001234 EDX=000069ff
ESI=00006998 EDI=07fbec71 EBP=00006958 ESP=00006958
EIP=000f7d2a EFL=00000002 [-------] CPL=0 II=0 A20=1 SMM=0 HLT=0
ES =0010 00000000 ffffffff 00c09300 DPL=0 DS [-WA]
CS =0008 00000000 ffffffff 00c09b00 DPL=0 CS32 [-RA]
SS =0010 00000000 ffffffff 00c09300 DPL=0 DS [-WA]
DS =0010 00000000 ffffffff 00c09300 DPL=0 DS [-WA]
FS =0010 00000000 ffffffff 00c09300 DPL=0 DS [-WA]
GS =0010 00000000 ffffffff 00c09300 DPL=0 DS [-WA]
LDT=0000 00000000 0000ffff 00008200 DPL=0 LDT
TR =0000 00000000 0000ffff 00008b00 DPL=0 TSS32-busy
GDT= 000f6180 00000037
IDT= 000f61be 00000000
CR0=00000011 CR2=00000000 CR3=00000000 CR4=00000000
DR0=00000000 DR1=00000000 DR2=00000000 DR3=00000000
DR6=ffff0ff0 DR7=00000400
CCS=00000000 CCD=00000000 CCO=EFLAGS
EFER=0000000000000000
SMM: enter
EAX=000000b5 EBX=00007d44 ECX=00005678 EDX=00000003
ESI=07ecb590 EDI=07fbec71 EBP=00006958 ESP=00006958
EIP=000f7d43 EFL=00000016 [----AP-] CPL=0 II=0 A20=1 SMM=0 HLT=0
ES =0010 00000000 ffffffff 00c09300 DPL=0 DS [-WA]
CS =0008 00000000 ffffffff 00c09b00 DPL=0 CS32 [-RA]
SS =0010 00000000 ffffffff 00c09300 DPL=0 DS [-WA]
DS =0010 00000000 ffffffff 00c09300 DPL=0 DS [-WA]
FS =0010 00000000 ffffffff 00c09300 DPL=0 DS [-WA]
GS =0010 00000000 ffffffff 00c09300 DPL=0 DS [-WA]
LDT=0000 00000000 0000ffff 00008200 DPL=0 LDT
TR =0000 00000000 0000ffff 00008b00 DPL=0 TSS32-busy
GDT= 000f6180 00000037
IDT= 000f61be 00000000
CR0=00000011 CR2=00000000 CR3=00000000 CR4=00000000
DR0=00000000 DR1=00000000 DR2=00000000 DR3=00000000
DR6=ffff0ff0 DR7=00000400
CCS=00000014 CCD=00006944 CCO=EFLAGS
EFER=0000000000000000
SMM: after RSM
EAX=000000b5 EBX=00007d44 ECX=00005678 EDX=00000003
ESI=07ecb590 EDI=07fbec71 EBP=00006958 ESP=00006958
EIP=00007d44 EFL=00000002 [-------] CPL=0 II=0 A20=1 SMM=0 HLT=0
ES =d980 000d9800 ffffffff 00809300
CS =f000 000f0000 ffffffff 00809b00
SS =0000 00000000 ffffffff 00809300
DS =0000 00000000 ffffffff 00809300
FS =0000 00000000 ffffffff 00809300
GS =ca00 000ca000 ffffffff 00809300
LDT=0000 00000000 0000ffff 00008200
TR =0000 00000000 0000ffff 00008b00
GDT= 00000000 00000000
IDT= 00000000 000003ff
CR0=00000010 CR2=00000000 CR3=00000000 CR4=00000000
DR0=00000000 DR1=00000000 DR2=00000000 DR3=00000000
DR6=ffff0ff0 DR7=00000400
CCS=00000000 CCD=00000001 CCO=EFLAGS
EFER=0000000000000000
If I knew the gas equivalent, the topic wouldn't be called nasm to gas assembly help, lol.
Edit:
Okay, so with a bit of research, I managed to (hopefully) figure it out. However, with the debug output from qemu, the GDT is all 0's. Like here's what it says for GDT:
GDT= 00000000 00000000
I assume that means it's not installed. Here is my updated code:
Code: Select all
.code32
.text
.globl gdt_install
gdt_start:
.quad 0x0
gdt_code:
.word 0xFFFF
.word 0x0000
.byte 0x00
.byte 0x9A
.byte 0xCF
.byte 0x00
gdt_data:
.word 0xFFFF
.word 0x0000
.byte 0x00
.byte 0x92
.byte 0xCF
.byte 0x00
gdt_end:
gdt_pointer:
.word gdt_end - gdt_start
.long gdt_start
gdt_install:
movl $gdt_pointer, %eax
lgdt (%eax)
movw $0x10, %ax
movw %ax, %ds
movw %ax, %es
movw %ax, %fs
movw %ax, %gs
movw %ax, %ss
ljmp $0x08, $.finish
.finish:
ret
Code: Select all
...
extern void gdt_install(void);
...
int main(unsigned long magic, unsigned long addr)
{
...
gdt_install();
...
return EXIT_SUCCESS;
}
oddly enough, under IDT (which I haven't even begun working on) says:
IDT= 00000000 000003ff
and LDT (which I also haven't created [yet]):
LDT=0000 00000000 0000ffff 00008200
Edit2:
Okay, I just noticed the list of output symbols is longer than santa's christmas list. There is a repeating pattern of things. I'llpaste the full output of the debug $#!+. Brace yourselves:
EAX=00000001 EBX=00000000 ECX=02000000 EDX=02000628
ESI=0000000b EDI=02000000 EBP=00014900 ESP=00006c5c
EIP=000e9bb1 EFL=00000002 [-------] CPL=0 II=0 A20=1 SMM=0 HLT=0
ES =0010 00000000 ffffffff 00cf9300 DPL=0 DS [-WA]
CS =0008 00000000 ffffffff 00cf9b00 DPL=0 CS32 [-RA]
SS =0010 00000000 ffffffff 00cf9300 DPL=0 DS [-WA]
DS =0010 00000000 ffffffff 00cf9300 DPL=0 DS [-WA]
FS =0010 00000000 ffffffff 00cf9300 DPL=0 DS [-WA]
GS =0010 00000000 ffffffff 00cf9300 DPL=0 DS [-WA]
LDT=0000 00000000 0000ffff 00008200 DPL=0 LDT
TR =0000 00000000 0000ffff 00008b00 DPL=0 TSS32-busy
GDT= 000f6180 00000037
IDT= 000f61be 00000000
CR0=00000011 CR2=00000000 CR3=00000000 CR4=00000000
DR0=00000000 DR1=00000000 DR2=00000000 DR3=00000000
DR6=ffff0ff0 DR7=00000400
CCS=00000080 CCD=00000001 CCO=LOGICB
EFER=0000000000000000
SMM: after RSM
EAX=00000001 EBX=00000000 ECX=02000000 EDX=02000628
ESI=0000000b EDI=02000000 EBP=00014900 ESP=00006c5c
EIP=000e9bb1 EFL=00000002 [-------] CPL=0 II=0 A20=1 SMM=0 HLT=0
ES =0010 00000000 ffffffff 00c09300 DPL=0 DS [-WA]
CS =0008 00000000 ffffffff 00c09b00 DPL=0 CS32 [-RA]
SS =0010 00000000 ffffffff 00c09300 DPL=0 DS [-WA]
DS =0010 00000000 ffffffff 00c09300 DPL=0 DS [-WA]
FS =0010 00000000 ffffffff 00c09300 DPL=0 DS [-WA]
GS =0010 00000000 ffffffff 00c09300 DPL=0 DS [-WA]
LDT=0000 00000000 0000ffff 00008200 DPL=0 LDT
TR =0000 00000000 0000ffff 00008b00 DPL=0 TSS32-busy
GDT= 000f6180 00000037
IDT= 000f61be 00000000
CR0=00000011 CR2=00000000 CR3=00000000 CR4=00000000
DR0=00000000 DR1=00000000 DR2=00000000 DR3=00000000
DR6=ffff0ff0 DR7=00000400
CCS=00000000 CCD=00000000 CCO=EFLAGS
EFER=0000000000000000
SMM: enter
EAX=000000b5 EBX=000f7d2a ECX=00001234 EDX=00006cff
ESI=00006cb8 EDI=07fbec71 EBP=00006c78 ESP=00006c78
EIP=00007d29 EFL=00000006 [-----P-] CPL=0 II=0 A20=1 SMM=0 HLT=0
ES =d980 000d9800 ffffffff 008f9300
CS =f000 000f0000 ffffffff 008f9b00
SS =0000 00000000 ffffffff 008f9300
DS =0000 00000000 ffffffff 008f9300
FS =0000 00000000 ffffffff 008f9300
GS =0000 00000000 ffffffff 008f9300
LDT=0000 00000000 0000ffff 00008200
TR =0000 00000000 0000ffff 00008b00
GDT= 00000000 00000000
IDT= 00000000 000003ff
CR0=00000010 CR2=00000000 CR3=00000000 CR4=00000000
DR0=00000000 DR1=00000000 DR2=00000000 DR3=00000000
DR6=ffff0ff0 DR7=00000400
CCS=00000004 CCD=00006c78 CCO=EFLAGS
EFER=0000000000000000
SMM: after RSM
EAX=000000b5 EBX=000f7d2a ECX=00001234 EDX=00006cff
ESI=00006cb8 EDI=07fbec71 EBP=00006c78 ESP=00006c78
EIP=000f7d2a EFL=00000002 [-------] CPL=0 II=0 A20=1 SMM=0 HLT=0
ES =0010 00000000 ffffffff 00c09300 DPL=0 DS [-WA]
CS =0008 00000000 ffffffff 00c09b00 DPL=0 CS32 [-RA]
SS =0010 00000000 ffffffff 00c09300 DPL=0 DS [-WA]
DS =0010 00000000 ffffffff 00c09300 DPL=0 DS [-WA]
FS =0010 00000000 ffffffff 00c09300 DPL=0 DS [-WA]
GS =0010 00000000 ffffffff 00c09300 DPL=0 DS [-WA]
LDT=0000 00000000 0000ffff 00008200 DPL=0 LDT
TR =0000 00000000 0000ffff 00008b00 DPL=0 TSS32-busy
GDT= 000f6180 00000037
IDT= 000f61be 00000000
CR0=00000011 CR2=00000000 CR3=00000000 CR4=00000000
DR0=00000000 DR1=00000000 DR2=00000000 DR3=00000000
DR6=ffff0ff0 DR7=00000400
CCS=00000000 CCD=00000000 CCO=EFLAGS
EFER=0000000000000000
SMM: enter
EAX=000000b5 EBX=00007d44 ECX=00005678 EDX=07fa91c0
ESI=000e8d00 EDI=07fbec71 EBP=00006c78 ESP=00006c78
EIP=000f7d43 EFL=00000012 [----A--] CPL=0 II=0 A20=1 SMM=0 HLT=0
ES =0010 00000000 ffffffff 00c09300 DPL=0 DS [-WA]
CS =0008 00000000 ffffffff 00c09b00 DPL=0 CS32 [-RA]
SS =0010 00000000 ffffffff 00c09300 DPL=0 DS [-WA]
DS =0010 00000000 ffffffff 00c09300 DPL=0 DS [-WA]
FS =0010 00000000 ffffffff 00c09300 DPL=0 DS [-WA]
GS =0010 00000000 ffffffff 00c09300 DPL=0 DS [-WA]
LDT=0000 00000000 0000ffff 00008200 DPL=0 LDT
TR =0000 00000000 0000ffff 00008b00 DPL=0 TSS32-busy
GDT= 000f6180 00000037
IDT= 000f61be 00000000
CR0=00000011 CR2=00000000 CR3=00000000 CR4=00000000
DR0=00000000 DR1=00000000 DR2=00000000 DR3=00000000
DR6=ffff0ff0 DR7=00000400
CCS=00000010 CCD=00006c64 CCO=EFLAGS
EFER=0000000000000000
SMM: after RSM
EAX=000000b5 EBX=00007d44 ECX=00005678 EDX=07fa91c0
ESI=000e8d00 EDI=07fbec71 EBP=00006c78 ESP=00006c78
EIP=00007d44 EFL=00000006 [-----P-] CPL=0 II=0 A20=1 SMM=0 HLT=0
ES =d980 000d9800 ffffffff 00809300
CS =f000 000f0000 ffffffff 00809b00
SS =0000 00000000 ffffffff 00809300
DS =0000 00000000 ffffffff 00809300
FS =0000 00000000 ffffffff 00809300
GS =0000 00000000 ffffffff 00809300
LDT=0000 00000000 0000ffff 00008200
TR =0000 00000000 0000ffff 00008b00
GDT= 00000000 00000000
IDT= 00000000 000003ff
CR0=00000010 CR2=00000000 CR3=00000000 CR4=00000000
DR0=00000000 DR1=00000000 DR2=00000000 DR3=00000000
DR6=ffff0ff0 DR7=00000400
CCS=00000004 CCD=00000001 CCO=EFLAGS
EFER=0000000000000000
SMM: enter
EAX=000000b5 EBX=000f7d2a ECX=00001234 EDX=000069ff
ESI=0000699e EDI=07fbec71 EBP=0000695e ESP=0000695e
EIP=00007d29 EFL=00000002 [-------] CPL=0 II=0 A20=1 SMM=0 HLT=0
ES =d980 000d9800 ffffffff 008f9300
CS =f000 000f0000 ffffffff 008f9b00
SS =0000 00000000 ffffffff 008f9300
DS =0000 00000000 ffffffff 008f9300
FS =0000 00000000 ffffffff 008f9300
GS =ca00 000ca000 ffffffff 008f9300
LDT=0000 00000000 0000ffff 00008200
TR =0000 00000000 0000ffff 00008b00
GDT= 00000000 00000000
IDT= 00000000 000003ff
CR0=00000010 CR2=00000000 CR3=00000000 CR4=00000000
DR0=00000000 DR1=00000000 DR2=00000000 DR3=00000000
DR6=ffff0ff0 DR7=00000400
CCS=00000000 CCD=0000695e CCO=EFLAGS
EFER=0000000000000000
SMM: after RSM
EAX=000000b5 EBX=000f7d2a ECX=00001234 EDX=000069ff
ESI=0000699e EDI=07fbec71 EBP=0000695e ESP=0000695e
EIP=000f7d2a EFL=00000002 [-------] CPL=0 II=0 A20=1 SMM=0 HLT=0
ES =0010 00000000 ffffffff 00c09300 DPL=0 DS [-WA]
CS =0008 00000000 ffffffff 00c09b00 DPL=0 CS32 [-RA]
SS =0010 00000000 ffffffff 00c09300 DPL=0 DS [-WA]
DS =0010 00000000 ffffffff 00c09300 DPL=0 DS [-WA]
FS =0010 00000000 ffffffff 00c09300 DPL=0 DS [-WA]
GS =0010 00000000 ffffffff 00c09300 DPL=0 DS [-WA]
LDT=0000 00000000 0000ffff 00008200 DPL=0 LDT
TR =0000 00000000 0000ffff 00008b00 DPL=0 TSS32-busy
GDT= 000f6180 00000037
IDT= 000f61be 00000000
CR0=00000011 CR2=00000000 CR3=00000000 CR4=00000000
DR0=00000000 DR1=00000000 DR2=00000000 DR3=00000000
DR6=ffff0ff0 DR7=00000400
CCS=00000000 CCD=00000000 CCO=EFLAGS
EFER=0000000000000000
SMM: enter
EAX=000000b5 EBX=00007d44 ECX=00005678 EDX=00000005
ESI=00000000 EDI=07fbec71 EBP=0000695e ESP=0000695e
EIP=000f7d43 EFL=00000012 [----A--] CPL=0 II=0 A20=1 SMM=0 HLT=0
ES =0010 00000000 ffffffff 00c09300 DPL=0 DS [-WA]
CS =0008 00000000 ffffffff 00c09b00 DPL=0 CS32 [-RA]
SS =0010 00000000 ffffffff 00c09300 DPL=0 DS [-WA]
DS =0010 00000000 ffffffff 00c09300 DPL=0 DS [-WA]
FS =0010 00000000 ffffffff 00c09300 DPL=0 DS [-WA]
GS =0010 00000000 ffffffff 00c09300 DPL=0 DS [-WA]
LDT=0000 00000000 0000ffff 00008200 DPL=0 LDT
TR =0000 00000000 0000ffff 00008b00 DPL=0 TSS32-busy
GDT= 000f6180 00000037
IDT= 000f61be 00000000
CR0=00000011 CR2=00000000 CR3=00000000 CR4=00000000
DR0=00000000 DR1=00000000 DR2=00000000 DR3=00000000
DR6=ffff0ff0 DR7=00000400
CCS=00000010 CCD=0000694a CCO=EFLAGS
EFER=0000000000000000
SMM: after RSM
EAX=000000b5 EBX=00007d44 ECX=00005678 EDX=00000005
ESI=00000000 EDI=07fbec71 EBP=0000695e ESP=0000695e
EIP=00007d44 EFL=00000002 [-------] CPL=0 II=0 A20=1 SMM=0 HLT=0
ES =d980 000d9800 ffffffff 00809300
CS =f000 000f0000 ffffffff 00809b00
SS =0000 00000000 ffffffff 00809300
DS =0000 00000000 ffffffff 00809300
FS =0000 00000000 ffffffff 00809300
GS =ca00 000ca000 ffffffff 00809300
LDT=0000 00000000 0000ffff 00008200
TR =0000 00000000 0000ffff 00008b00
GDT= 00000000 00000000
IDT= 00000000 000003ff
CR0=00000010 CR2=00000000 CR3=00000000 CR4=00000000
DR0=00000000 DR1=00000000 DR2=00000000 DR3=00000000
DR6=ffff0ff0 DR7=00000400
CCS=00000000 CCD=00000001 CCO=EFLAGS
EFER=0000000000000000
SMM: enter
EAX=000000b5 EBX=000f7d2a ECX=00001234 EDX=000069ff
ESI=00006998 EDI=07fbec71 EBP=00006958 ESP=00006958
EIP=00007d29 EFL=00000002 [-------] CPL=0 II=0 A20=1 SMM=0 HLT=0
ES =d980 000d9800 ffffffff 00809300
CS =f000 000f0000 ffffffff 00809b00
SS =0000 00000000 ffffffff 00809300
DS =0000 00000000 ffffffff 00809300
FS =0000 00000000 ffffffff 00809300
GS =ca00 000ca000 ffffffff 00809300
LDT=0000 00000000 0000ffff 00008200
TR =0000 00000000 0000ffff 00008b00
GDT= 00000000 00000000
IDT= 00000000 000003ff
CR0=00000010 CR2=00000000 CR3=00000000 CR4=00000000
DR0=00000000 DR1=00000000 DR2=00000000 DR3=00000000
DR6=ffff0ff0 DR7=00000400
CCS=00000000 CCD=00006958 CCO=EFLAGS
EFER=0000000000000000
SMM: after RSM
EAX=000000b5 EBX=000f7d2a ECX=00001234 EDX=000069ff
ESI=00006998 EDI=07fbec71 EBP=00006958 ESP=00006958
EIP=000f7d2a EFL=00000002 [-------] CPL=0 II=0 A20=1 SMM=0 HLT=0
ES =0010 00000000 ffffffff 00c09300 DPL=0 DS [-WA]
CS =0008 00000000 ffffffff 00c09b00 DPL=0 CS32 [-RA]
SS =0010 00000000 ffffffff 00c09300 DPL=0 DS [-WA]
DS =0010 00000000 ffffffff 00c09300 DPL=0 DS [-WA]
FS =0010 00000000 ffffffff 00c09300 DPL=0 DS [-WA]
GS =0010 00000000 ffffffff 00c09300 DPL=0 DS [-WA]
LDT=0000 00000000 0000ffff 00008200 DPL=0 LDT
TR =0000 00000000 0000ffff 00008b00 DPL=0 TSS32-busy
GDT= 000f6180 00000037
IDT= 000f61be 00000000
CR0=00000011 CR2=00000000 CR3=00000000 CR4=00000000
DR0=00000000 DR1=00000000 DR2=00000000 DR3=00000000
DR6=ffff0ff0 DR7=00000400
CCS=00000000 CCD=00000000 CCO=EFLAGS
EFER=0000000000000000
SMM: enter
EAX=000000b5 EBX=00007d44 ECX=00005678 EDX=00000003
ESI=07f8b590 EDI=07fbec71 EBP=00006958 ESP=00006958
EIP=000f7d43 EFL=00000016 [----AP-] CPL=0 II=0 A20=1 SMM=0 HLT=0
ES =0010 00000000 ffffffff 00c09300 DPL=0 DS [-WA]
CS =0008 00000000 ffffffff 00c09b00 DPL=0 CS32 [-RA]
SS =0010 00000000 ffffffff 00c09300 DPL=0 DS [-WA]
DS =0010 00000000 ffffffff 00c09300 DPL=0 DS [-WA]
FS =0010 00000000 ffffffff 00c09300 DPL=0 DS [-WA]
GS =0010 00000000 ffffffff 00c09300 DPL=0 DS [-WA]
LDT=0000 00000000 0000ffff 00008200 DPL=0 LDT
TR =0000 00000000 0000ffff 00008b00 DPL=0 TSS32-busy
GDT= 000f6180 00000037
IDT= 000f61be 00000000
CR0=00000011 CR2=00000000 CR3=00000000 CR4=00000000
DR0=00000000 DR1=00000000 DR2=00000000 DR3=00000000
DR6=ffff0ff0 DR7=00000400
CCS=00000014 CCD=00006944 CCO=EFLAGS
EFER=0000000000000000
SMM: after RSM
EAX=000000b5 EBX=00007d44 ECX=00005678 EDX=00000003
ESI=07f8b590 EDI=07fbec71 EBP=00006958 ESP=00006958
EIP=00007d44 EFL=00000002 [-------] CPL=0 II=0 A20=1 SMM=0 HLT=0
ES =d980 000d9800 ffffffff 00809300
CS =f000 000f0000 ffffffff 00809b00
SS =0000 00000000 ffffffff 00809300
DS =0000 00000000 ffffffff 00809300
FS =0000 00000000 ffffffff 00809300
GS =ca00 000ca000 ffffffff 00809300
LDT=0000 00000000 0000ffff 00008200
TR =0000 00000000 0000ffff 00008b00
GDT= 00000000 00000000
IDT= 00000000 000003ff
CR0=00000010 CR2=00000000 CR3=00000000 CR4=00000000
DR0=00000000 DR1=00000000 DR2=00000000 DR3=00000000
DR6=ffff0ff0 DR7=00000400
CCS=00000000 CCD=00000001 CCO=EFLAGS
EFER=0000000000000000
SMM: enter
EAX=000000b5 EBX=000f7d2a ECX=00001234 EDX=000069ff
ESI=0000699e EDI=07fbec71 EBP=0000695e ESP=0000695e
EIP=00007d29 EFL=00000002 [-------] CPL=0 II=0 A20=1 SMM=0 HLT=0
ES =d980 000d9800 ffffffff 00809300
CS =f000 000f0000 ffffffff 00809b00
SS =0000 00000000 ffffffff 00809300
DS =0000 00000000 ffffffff 00809300
FS =0000 00000000 ffffffff 00809300
GS =ca00 000ca000 ffffffff 00809300
LDT=0000 00000000 0000ffff 00008200
TR =0000 00000000 0000ffff 00008b00
GDT= 00000000 00000000
IDT= 00000000 000003ff
CR0=00000010 CR2=00000000 CR3=00000000 CR4=00000000
DR0=00000000 DR1=00000000 DR2=00000000 DR3=00000000
DR6=ffff0ff0 DR7=00000400
CCS=00000000 CCD=0000695e CCO=EFLAGS
EFER=0000000000000000
SMM: after RSM
EAX=000000b5 EBX=000f7d2a ECX=00001234 EDX=000069ff
ESI=0000699e EDI=07fbec71 EBP=0000695e ESP=0000695e
EIP=000f7d2a EFL=00000002 [-------] CPL=0 II=0 A20=1 SMM=0 HLT=0
ES =0010 00000000 ffffffff 00c09300 DPL=0 DS [-WA]
CS =0008 00000000 ffffffff 00c09b00 DPL=0 CS32 [-RA]
SS =0010 00000000 ffffffff 00c09300 DPL=0 DS [-WA]
DS =0010 00000000 ffffffff 00c09300 DPL=0 DS [-WA]
FS =0010 00000000 ffffffff 00c09300 DPL=0 DS [-WA]
GS =0010 00000000 ffffffff 00c09300 DPL=0 DS [-WA]
LDT=0000 00000000 0000ffff 00008200 DPL=0 LDT
TR =0000 00000000 0000ffff 00008b00 DPL=0 TSS32-busy
GDT= 000f6180 00000037
IDT= 000f61be 00000000
CR0=00000011 CR2=00000000 CR3=00000000 CR4=00000000
DR0=00000000 DR1=00000000 DR2=00000000 DR3=00000000
DR6=ffff0ff0 DR7=00000400
CCS=00000000 CCD=00000000 CCO=EFLAGS
EFER=0000000000000000
SMM: enter
EAX=000000b5 EBX=00007d44 ECX=00005678 EDX=00000005
ESI=00000000 EDI=07fbec71 EBP=0000695e ESP=0000695e
EIP=000f7d43 EFL=00000012 [----A--] CPL=0 II=0 A20=1 SMM=0 HLT=0
ES =0010 00000000 ffffffff 00c09300 DPL=0 DS [-WA]
CS =0008 00000000 ffffffff 00c09b00 DPL=0 CS32 [-RA]
SS =0010 00000000 ffffffff 00c09300 DPL=0 DS [-WA]
DS =0010 00000000 ffffffff 00c09300 DPL=0 DS [-WA]
FS =0010 00000000 ffffffff 00c09300 DPL=0 DS [-WA]
GS =0010 00000000 ffffffff 00c09300 DPL=0 DS [-WA]
LDT=0000 00000000 0000ffff 00008200 DPL=0 LDT
TR =0000 00000000 0000ffff 00008b00 DPL=0 TSS32-busy
GDT= 000f6180 00000037
IDT= 000f61be 00000000
CR0=00000011 CR2=00000000 CR3=00000000 CR4=00000000
DR0=00000000 DR1=00000000 DR2=00000000 DR3=00000000
DR6=ffff0ff0 DR7=00000400
CCS=00000010 CCD=0000694a CCO=EFLAGS
EFER=0000000000000000
SMM: after RSM
EAX=000000b5 EBX=00007d44 ECX=00005678 EDX=00000005
ESI=00000000 EDI=07fbec71 EBP=0000695e ESP=0000695e
EIP=00007d44 EFL=00000002 [-------] CPL=0 II=0 A20=1 SMM=0 HLT=0
ES =d980 000d9800 ffffffff 00809300
CS =f000 000f0000 ffffffff 00809b00
SS =0000 00000000 ffffffff 00809300
DS =0000 00000000 ffffffff 00809300
FS =0000 00000000 ffffffff 00809300
GS =ca00 000ca000 ffffffff 00809300
LDT=0000 00000000 0000ffff 00008200
TR =0000 00000000 0000ffff 00008b00
GDT= 00000000 00000000
IDT= 00000000 000003ff
CR0=00000010 CR2=00000000 CR3=00000000 CR4=00000000
DR0=00000000 DR1=00000000 DR2=00000000 DR3=00000000
DR6=ffff0ff0 DR7=00000400
CCS=00000000 CCD=00000001 CCO=EFLAGS
EFER=0000000000000000
SMM: enter
EAX=000000b5 EBX=000f7d2a ECX=00001234 EDX=000069ff
ESI=00006998 EDI=07fbec71 EBP=00006958 ESP=00006958
EIP=00007d29 EFL=00000002 [-------] CPL=0 II=0 A20=1 SMM=0 HLT=0
ES =d980 000d9800 ffffffff 00809300
CS =f000 000f0000 ffffffff 00809b00
SS =0000 00000000 ffffffff 00809300
DS =0000 00000000 ffffffff 00809300
FS =0000 00000000 ffffffff 00809300
GS =ca00 000ca000 ffffffff 00809300
LDT=0000 00000000 0000ffff 00008200
TR =0000 00000000 0000ffff 00008b00
GDT= 00000000 00000000
IDT= 00000000 000003ff
CR0=00000010 CR2=00000000 CR3=00000000 CR4=00000000
DR0=00000000 DR1=00000000 DR2=00000000 DR3=00000000
DR6=ffff0ff0 DR7=00000400
CCS=00000000 CCD=00006958 CCO=EFLAGS
EFER=0000000000000000
SMM: after RSM
EAX=000000b5 EBX=000f7d2a ECX=00001234 EDX=000069ff
ESI=00006998 EDI=07fbec71 EBP=00006958 ESP=00006958
EIP=000f7d2a EFL=00000002 [-------] CPL=0 II=0 A20=1 SMM=0 HLT=0
ES =0010 00000000 ffffffff 00c09300 DPL=0 DS [-WA]
CS =0008 00000000 ffffffff 00c09b00 DPL=0 CS32 [-RA]
SS =0010 00000000 ffffffff 00c09300 DPL=0 DS [-WA]
DS =0010 00000000 ffffffff 00c09300 DPL=0 DS [-WA]
FS =0010 00000000 ffffffff 00c09300 DPL=0 DS [-WA]
GS =0010 00000000 ffffffff 00c09300 DPL=0 DS [-WA]
LDT=0000 00000000 0000ffff 00008200 DPL=0 LDT
TR =0000 00000000 0000ffff 00008b00 DPL=0 TSS32-busy
GDT= 000f6180 00000037
IDT= 000f61be 00000000
CR0=00000011 CR2=00000000 CR3=00000000 CR4=00000000
DR0=00000000 DR1=00000000 DR2=00000000 DR3=00000000
DR6=ffff0ff0 DR7=00000400
CCS=00000000 CCD=00000000 CCO=EFLAGS
EFER=0000000000000000
SMM: enter
EAX=000000b5 EBX=00007d44 ECX=00005678 EDX=00000003
ESI=07ecb590 EDI=07fbec71 EBP=00006958 ESP=00006958
EIP=000f7d43 EFL=00000016 [----AP-] CPL=0 II=0 A20=1 SMM=0 HLT=0
ES =0010 00000000 ffffffff 00c09300 DPL=0 DS [-WA]
CS =0008 00000000 ffffffff 00c09b00 DPL=0 CS32 [-RA]
SS =0010 00000000 ffffffff 00c09300 DPL=0 DS [-WA]
DS =0010 00000000 ffffffff 00c09300 DPL=0 DS [-WA]
FS =0010 00000000 ffffffff 00c09300 DPL=0 DS [-WA]
GS =0010 00000000 ffffffff 00c09300 DPL=0 DS [-WA]
LDT=0000 00000000 0000ffff 00008200 DPL=0 LDT
TR =0000 00000000 0000ffff 00008b00 DPL=0 TSS32-busy
GDT= 000f6180 00000037
IDT= 000f61be 00000000
CR0=00000011 CR2=00000000 CR3=00000000 CR4=00000000
DR0=00000000 DR1=00000000 DR2=00000000 DR3=00000000
DR6=ffff0ff0 DR7=00000400
CCS=00000014 CCD=00006944 CCO=EFLAGS
EFER=0000000000000000
SMM: after RSM
EAX=000000b5 EBX=00007d44 ECX=00005678 EDX=00000003
ESI=07ecb590 EDI=07fbec71 EBP=00006958 ESP=00006958
EIP=00007d44 EFL=00000002 [-------] CPL=0 II=0 A20=1 SMM=0 HLT=0
ES =d980 000d9800 ffffffff 00809300
CS =f000 000f0000 ffffffff 00809b00
SS =0000 00000000 ffffffff 00809300
DS =0000 00000000 ffffffff 00809300
FS =0000 00000000 ffffffff 00809300
GS =ca00 000ca000 ffffffff 00809300
LDT=0000 00000000 0000ffff 00008200
TR =0000 00000000 0000ffff 00008b00
GDT= 00000000 00000000
IDT= 00000000 000003ff
CR0=00000010 CR2=00000000 CR3=00000000 CR4=00000000
DR0=00000000 DR1=00000000 DR2=00000000 DR3=00000000
DR6=ffff0ff0 DR7=00000400
CCS=00000000 CCD=00000001 CCO=EFLAGS
EFER=0000000000000000