자료형
db 8bit 8bit
dw 8bit,8bit 16bit
dd 8bit,8bit 8bit,bit 32bit
dd 8bit,8bit,8bit,8bit 8bit,8bit,8bit,8bit 64bit
example asm2.asm
SECTION .data
msg: db "Hello world, this is assembly",10,0
msgLen: equ $-msg
fmt: db "Msg length = %d",10,0
i: dd 120
fmt2: db "Value of myInteger is %d",10,0
SECTION .text
extern printf
global main
main:
push ebp
mov ebp, esp
push msg
call printf
;printf(format,msgLen)
push DWORD msgLen
push fmt
call printf
;printf(format,balue)
push DWORD i
push fmt2
call printf
mov esp, ebp
pop ebp
ret
compile :
compile.sh
#!/bin/bash
numArg=$#
clear
if [ $numArg != 2 ] ; then
echo "You enter too many or too little arguments to script when expected 2, asm file"
echo "you supplied only $numArg"
echo "Usage: compile <input.asm> <program_name>"
exit
else
echo "Compiling asm using NASM"
input=$1
output=$2
inter=asm000.o
nasm -f elf32 -o $inter $input
ret=$?
if [ $ret != 0 ] ; then
echo "Nasm compilation failed"
exit
else
echo "compilation using GCC for final output"
gcc -m32 -o $output $inter
ret=$?
if [ $ret != 0 ] ; then
echo "There was a problem with gcc compilation"
exit
else
rm $inter
echo "Compilation successfull"
fi
fi
fi
./compile.sh asm2.asm asm2
댓글 없음:
댓글 쓰기