어셈블리언어 조건코드에 대하여...

superdma의 이미지

IA-32의 조건코드가 잘 이해가 안되 질문 드립니다.
니모닉 Greater(G) Not Less 또는 Equal (NLE)
플래그 ZF=0 AND ((OF=0 AND SF=0) OR (OF=1 AND SF=1))
만족시키는 조건 X>Y
설명 인자가 동일한지 확인하려고 ZF플래그를 사용한다. 또한 첫 번쨰 인자가 두번째 인자보다 큰지 판단하기 위해서 SF플래그를 사용해서 결과 값이 오버플로우 없는 양수이거나 오버플로우가 발생한 음수인지 확인한다.
두번쨰 인자가 너무 작은 음수이면 오버플로우가 발생한다.

라는 mnemonic 에 대한 설명이 있습니다.

조건코드는 조건명령에 대한 접미사롤 사용된다고 했는데, 저는 점프코드나 je 이나 jne 같은 조건명령에서 위와 같은 조건코드가 붙는걸 한번도 못봤거든요...

위에 있는 조건코드가 어떤의미이고 어디에 쓰이는지 궁금합니다 ^^...

SoulreaveR의 이미지

prefix 말씀하시는 건가요? prefix는 일반적으로 objdump 등의 disassemble 툴에서는 보여주지 않습니다. prefix 유무에 따라서 명령 자체를 다르게 해석합니다. Flag는 test나 sub 등의 명령어를 통해 설정되고 해당 연산의 결과로 설정된 zf, of 등등을 이용해서 jcc가 동작합니다.

Necromancer의 이미지

cmp나 test 같은 비교명령 실행시키면 그 결과에 따라 플래그 레지스터의 비트들이 변합니다.
플래그 레지스터의 모든 비트가 다 변하는건 아니고 OF나 ZF, CF 등등 연산결과를 알려주는 플래그 6개 정도가 바뀝니다. 명령어에 따라서는 일부만 바꾸는 경우도 있고요.

뒤따라오는 jne나 jz 같은 것들은 그걸 보고 넘어갈지 안넘어갈지 결정합니다.

덤으로 cmp가 하는것은 sub나 add도 똑같이 합니다. 그래서 숫자 덧뺄셈 겸 비교까지 한다면 sub나 add 한개만 써도 됩니다.

Written By the Black Knight of Destruction

Written By the Black Knight of Destruction

댓글 달기

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