nasm 입문자입니다

overover2000의 이미지

안녕하세요. 아래처럼 include "asm_io.inc"
c언어로 치면 라이브러리를 선언하였는데(nasm에서는 어떻게 부르는지 모르겠습니다)

오브젝트파일하고 실행파일 명령어를 치면 오류가 납니다.
c언어처럼 특정폴더에 라이브러리가 있을것 같은데...
당최 어떻게 해야하는지 모르겠네요
인터넷에 정보도 많이 없고, 책들도 하나같이 이상하고..
c언어처럼 제대로된 정보가 없어 답답합니다.
더불어 nasm에 관한 책이나 자료, 블로그 등등이 있으면 추천해 주십시오.

%include "asm_io.inc"
segment .data
prompt db "Enter a number: ", 0
square_msg db "Square of input is ",0
cube_msg db "Cube of input is ",0
cube25_msg db "Cube of input times 25 is ", 0
quot_msg db "Quotient of cube/100 is", 0
rem_msg db "Remainder of cube/100 is", 0
neg_msg db "The negation of the remainder is ", 0

segment .bss
input resd 1

segment .text
global _asm_main
_asm_main:
enter 0,0
pusha

mov eax,prompt
call print_string

call read_int
mov [input], eax

imul eax
mov ebx, eax
mov eax, squarg_msg
call print_string
mov eax, ebx
call print_int
call print_nl

mov ebx, eax
imul ebx, [input]
mov eax, cube_msg
call print_string
mov eax, ebx
call print_int
call print_nl

imul ecx, ebx, 25 ;ecx = ebx*25
mov eax, cube25_msg
call print_string
mov eax, ecx
call print_int
call print_nl

mov eax, ebx
sdq ;부호 확장을 위해 edx 초기화
mov ecx, 100
idiv ecx
mov ecx, eax
mov eax, quot_msg
call print_string
mov eax, ecx
call print_int
call print_nl
mov eax, rem_msg
call print_string
mov eax, edx
call print_int
call print_nl

neg edx ;나머지에 음을 취함
mov eax, neg_msg
call pirnt_string
mov eax, edx
call print_int
call print_nl

popa
mov eax, 0
leave
ret

cleansugar의 이미지

어셈러브요

재벌 2세가 재벌이 될 확률과
금메달리스트 2세가 금메달을 딸 확률이 비슷해지도록
자유오픈소스 대안화폐를 씁시다.

아이디의 아이디어 무한도전
http://blog.aaidee.com

귀태닷컴
http://www.gwitae.com

익명 사용자의 이미지

inc 파일을 포함한 것은 헤더를 포함했다는 표현이 더 올바른 것 같은데요.
그리고 C언어 라이브러리를 호출 규약만 지켜주면 어셈에서도 쓸 수 있습니다.

익명 사용자의 이미지

gcc 같은 경우는 표준 라이브러리를 자동으로 링크해 주지만 어셈블리는 그런 게 없으니
수동으로 직접 해 주시면 됩니다.
정확히 말하자면 gcc는 전처리 -> 컴파일(c -> asm -> o) -> 링킹을 수행해 주지만 nasm과 같은 어셈블러는 저 과정들 중 asm -> o 만 하신다고 보시면 됩니다.
따라서 링킹을 수행해서 executable으로 만든 다음에 실행해 주셔야 합니다. 링커는 ld 명령으로 호출할 수 있습니다.

댓글 달기

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