JMPL과 JMP의 차이는 무엇인가요?

불량도ㅐㅈㅣ의 이미지

JUMP 명령어는 Near jump인 jmp와 Far jump인 ljmp가 있는 것으로 알고 있습니다.

"만들면서 배우는 OS 커널의 구조와 원리"

1장에 있는 소스(NASM)를 GAS 형식으로 바꿨습니다.

그래서 리눅스 bootsect.S 파일을 많이 참조했죠.

제가 NASM파일 형식을 GAS형식으로 바꾼 것입니다.

Quote:

BOOTSEG = 0x07C0 # boot 시작번지
COLOR_VIDEO = 0xB800 # 컬러 비디오램 메모리

.code16
.text

.globl _start
_start:

jmpl $BOOTSEG, $start2 # 0x7C0번지로 점프
start2:

movw %cs, %ax
movw %ax, %ds

movw $COLOR_VIDEO, %ax
movw %ax, %es
movw $0, %di

movw msgBack, %ax # '.' <= 주황색 문자
movw 0x7FF, %cx # Counter

# cx 개수 만큼 주황색인 '.' 문자를 화면에 출력한다
paint:
movw %ax, %es:(%di)
addw $2, %di
decw %cx
jnz paint

# ABC123을 출력한다
print:
movw $0, %di
movw $0x0641, %es:(%di) # 'A'
addw $2, %di
movw $0x0642, %es:(%di) # 'B'
addw $2, %di
movw $0x0643, %es:(%di) # 'C'
addw $2, %di
movw $0x0631, %es:(%di) # '1'
addw $2, %di
movw $0x0632, %es:(%di) # '2'
addw $2, %di
movw $0x0633, %es:(%di) # '3'

loop:
jmp loop

msgBack:
.byte '.',0xE7

# MBR Magic code
.org 510
boot_flag:
.word 0xAA55

저기서 ljmp 대신 왜 jmpl을 썼는지 궁금하며 두 개 명령어의 차이점을 알고 싶습니다.

이건 바이너리파일을 objdump 한것입니다.

Quote:

boot.o: file format elf32-i386

Disassembly of section .text:

00000000 <_start>:
0: 66 ea 08 00 00 00 ljmpw $0x0,$0x8
6: c0 07 8c rolb $0x8c,(%edi)

00000008 <start2>: 8: 8c c8 mov %cs,%eax
a: 8e d8 mov %eax,%ds
c: b8 00 b8 8e c0 mov $0xc08eb800,%eax
11: bf 00 00 a1 56 mov $0x56a10000,%edi
16: 00 8b 0e ff 07 26 add %cl,0x2607ff0e(%ebx)

0000001b <paint>:
1b: 26 89 05 83 c7 02 49 mov %eax,%es:0x4902c783
22: 75 f7 jne 1b <paint>

00000024 <print>:
24: bf 00 00 26 c7 mov $0xc7260000,%edi
29: 05 41 06 83 c7 add $0xc7830641,%eax
2e: 02 26 add (%esi),%ah
30: c7 05 42 06 83 c7 02 movl $0x5c72602,0xc7830642
37: 26 c7 05
3a: 43 inc %ebx
3b: 06 push %es
3c: 83 c7 02 add $0x2,%edi
3f: 26 c7 05 31 06 83 c7 movl $0x5c72602,%es:0xc7830631
46: 02 26 c7 05
4a: 32 06 xor (%esi),%al
4c: 83 c7 02 add $0x2,%edi
4f: 26 c7 05 33 06 eb fe movl $0xe72e,%es:0xfeeb0633
56: 2e e7 00 00

00000054 <loop>:
54: eb fe jmp 54 <loop>

00000056 <msgBack>:
56: 2e cs
57: e7 00 out %eax,$0x0
...

000001fe <boot_flag>:
1fe: 55 push %ebp
1ff: aa stos %al,%es:(%edi)

File attachments: 
첨부파일 크기
Image icon boot.JPG79.62 KB
Fe.head의 이미지

저도 배우는 입장에서 저 코드를 보면..
저 코드는 32bit 코드 같습니다.

66 EA 08 00 00 00 c0 07
8c(32bit mov 명령어??)

66 이 16, 32전환 코드이고 EB 가 jmp 명령어

대충 해석해 보면

66EA 07c0:00000008

jmp(16비트) 07c0:00000008 같습니다.

원래 16비트 jmp는 07c0:0008이 되어야 할것 같습니다만.

그때문이 아닐까 .. 추측해봅니다.^^

고작 블로킹 하나, 고작 25점 중에 1점, 고작 부활동
"만약 그 순간이 온다면 그때가 네가 배구에 빠지는 순간이야"

댓글 달기

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
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.