masm의 lgdt 명령을 기계어로 변경햇다는 소스인데 어떻게해서 그렇게 되는건지좀 알려주세요

intmain1202의 이미지

LGDT16 MACRO addr ; load from ds segment area
db 3eh
db 67h
db 0fh
db 01h
db 15h
dd addr
ENDM

FJMP16 MACRO selector, offset
db 66h
db 0eah
dd offset
dw selector
ENDM

nasm에서는 lgdt[gdtr] 이런식으로 쓰는데
masm에서 lgdt라는 명령이 없다고 기계어로 해서 햇다는 소스인데요

어떻게해서 그렇게 된건지 궁금합니다...

인텔 아키텍쳐문서를 찾아보니 0f 01이 lgdt 명령의 오프셋인것같던데;;
다른건 전혀모르겟네요 ;;
3e는 ds인것같고.. 15h는 eax라고 나오는것같은데 확실하지않네요;;
아시는분 잇으면 좀알려주세요 ^^;; 디스크립터 테이블을 만드는 전체적인 소스입니다...

.386P
.MODEL FLAT

PUBLIC _EntryPoint16, _m_GdtTable, _m_GdtrDesc
EXTERN _chobits_init:near

;===============================================================================
; DECLARE MACROs
;===============================================================================
LGDT16 MACRO addr ; load from ds segment area
db 3eh ds
db 67h 아무것도 없음
db 0fh
db 01h
db 15h eAX
dd addr
ENDM

FJMP16 MACRO selector, offset
db 66h
db 0eah
dd offset
dw selector
ENDM

.CODE
;===============================================================================
; EntryPoint called by bootsect.
;===============================================================================
_EntryPoint16 PROC NEAR

LGDT16 _m_GdtrDesc-20000h

mov eax, cr0
or ax, 1
mov cr0, eax
jmp $+2

FJMP16 08h, EntryPoint32

_EntryPoint16 ENDP

;===============================================================================
; 32bit routine
;===============================================================================
EntryPoint32 PROC NEAR

mov ax, 10h
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
mov ss, ax
mov esp, 1ffffh ; top of stack

mov eax, 0B8000h
mov word ptr [eax], 0749h
jmp $

call _chobits_init

infinate:
hlt
jmp infinate

EntryPoint32 ENDP

.DATA
;===============================================================================
; GDT table descriptor
;===============================================================================
ALIGN 4

_m_GdtrDesc dw GDT_SIZE-1
dd _m_GdtTable

;===============================================================================
; GDT table
;===============================================================================
ALIGN 4

;----------------------------------
; GDT TABLE INDEX #0
; INDEX : NULL SELECTOR
;----------------------------------
_m_GdtTable dd 0
dd 0

;----------------------------------
; GDT TABLE INDEX #1
; INDEX : 0x0008h
; TYPE : CODE SEGMENT
; RING LEVEL : 0
; ATTRIBUTES : Excute/Read, Nonconforming, 4GB
;----------------------------------
dw 0ffffh ; segment limit 15:00
dw 0000h ; base address 15:00
db 00h ; base address 23:16
db 10011010b ; P | DPL | S | TYPE
db 11001111b ; G | D/B | 0 | AVL | segment limit 19:16
db 00h ; base address 31:24

;----------------------------------
; GDT TABLE INDEX #2
; INDEX : 0x0010h
; TYPE : DATA SEGMENT
; RING LEVEL : 0
; ATTRIBUTES : Read/Write, 4GB
;----------------------------------
dw 0ffffh
dw 0000h
db 00h
db 10010010b
db 11001111b
db 00h

;----------------------------------
; GDT TABLE INDEX #3
; INDEX : 0x001Bh
; TYPE : CODE SEGMENT
; RING LEVEL : 3
; ATTRIBUTES : Excute/Read, Nonconforming, second 1mega area
;----------------------------------
dw 000ffh ; segment limit 15:00
dw 0000h ; base address 15:00
db 10h ; base address 23:16
db 11111010b ; P | DPL | S | TYPE
db 11001111b ; G | D/B | 0 | AVL | segment limit 19:16
db 00h ; base address 31:24

;----------------------------------
; GDT TABLE INDEX #4
; INDEX : 0x0023h
; TYPE : DATA SEGMENT
; RING LEVEL : 3
; ATTRIBUTES : Read/Write, second 1mega area
;----------------------------------
dw 000ffh
dw 0000h
db 10h
db 11110010b
db 11001111b
db 00h

;----------------------------------
; GDT TABLE INDEX #5
; INDEX : 0x0028h
; TYPE : 32-Bit TSS
; RING LEVEL : 0
; DESC : used by tmr_task_gate
;----------------------------------
dw 0067h ; segment limit 15:00
dw 0000h ; base address 15:00
db 00h ; base address 23:16
db 10001001b ; P | DPL | 0 | TYPE
db 00000000b ; G | 0 | 0 | AVL | limit 19:16
db 00h ; base address 31:24

;----------------------------------
; GDT TABLE INDEX #6
; INDEX : 0x0030h
; TYPE : 32-Bit TSS
; RING LEVEL : 0
; DESC : used during system initialization
;----------------------------------
dw 0067h ; segment limit 15:00
dw 0000h ; base address 15:00
db 00h ; base address 23:16
db 10001001b ; P | DPL | 0 | TYPE
db 00000000b ; G | 0 | 0 | AVL | limit 19:16
db 00h ; base address 31:24

;----------------------------------
; GDT TABLE INDEX #7
; INDEX : 0x0038h
; TYPE : 32-Bit TSS
; RING LEVEL : 0
; DESC : called whenever the system timer generates an interrupt
;----------------------------------
dw 0067h ; segment limit 15:00
dw 0000h ; base address 15:00
db 00h ; base address 23:16
db 10001001b ; P | DPL | 0 | TYPE
db 00000000b ; G | 0 | 0 | AVL | limit 19:16
db 00h ; base address 31:24

;----------------------------------
; GDT TABLE INDEX #8
; INDEX : 0x0040h
; TYPE : 32-Bit TSS
; RING LEVEL : 0
; DESC : soft-task-switch. when any thread wants to task-swithing, call this.
;----------------------------------
dw 0067h ; segment limit 15:00
dw 0000h ; base address 15:00
db 00h ; base address 23:16
db 10001001b ; P | DPL | 0 | TYPE
db 00000000b ; G | 0 | 0 | AVL | limit 19:16
db 00h ; base address 31:24

;----------------------------------
; GDT TABLE INDEX #9
; INDEX : 0x0048h
; TYPE : 32-Bit TSS
; RING LEVEL : 0
; DESC : call-gate for syscall
;----------------------------------
dw 0000h ; offset 15:00
dw 0000h ; selector
db 01h ; dword count = 1 (4bytes)
db 11101100b ; P, DPL=3, S=0, TYPE=1100
dw 0000h ; offset 31:16


GDT_SIZE EQU $ - _m_GdtTable ; Size, in bytes

END

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.