카테고리

asm (27) bootloader_x86_grub (1) C (92) compile (11) config (76) CPP (13) CSS (1) debugging (7) gimp (1) Go (1) html (1) Java (1) JavaScript (1) kernel (19) LibreOffice (3) Linux system progamming (21) MFC (1) opencv (4) OpenGL (1) PHP (1) Python (4) qemu (29) shell (3) socket (7) troubleshooting (2) ubuntu18.04 (2) windows (1)

2018/12/06

asm integer 자료형

apt-get install gcc-multilib

자료형
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

댓글 없음:

댓글 쓰기