日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

汇编解析(3)-nasm基础、物理地址

發布時間:2025/3/12 编程问答 16 豆豆
生活随笔 收集整理的這篇文章主要介紹了 汇编解析(3)-nasm基础、物理地址 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

1、8086生成物理地址:
段寄存器左移4位形成20位段地址,十六進制左移1位,然后加上16位偏移地址,合成物理地址
物理地址可在8086的20位地址總線上傳遞并尋址。
2、進制表示
0x開頭或H結尾:16進制,如:0x3f、3fH
B結尾:2進制,如:01010000B
3、nasm:
nasm:需要一系列參數才能正常工作。
-f 參數的作用是指定輸出文件的格式
-f bin 要求nasm生成的文件只包含純二進制的mkwpw,無損作系統所需要的加載和重定位信息
-o 指定編譯后輸出的文件名
更多說明如下:

To assemble a file, you issue a command of the form nasm -f <format> <filename> [-o <output>] For example, nasm -f elf myfile.asm will assemble myfile.asm into an ELF object file myfile.o. And nasm -f bin myfile.asm -o myfile.com will assemble myfile.asm into a raw binary file myfile.com. To produce a listing file, with the hex codes output from NASM displayed on the left of the original sources, use the -l option to give a listing file name, for example: nasm -f coff myfile.asm -l myfile.lst To get further usage instructions from NASM, try typing nasm -h The option --help is an alias for the -h option. If you use Linux but aren’t sure whether your system is a.out or ELF, type file nasm (in the directory in which you put the NASM binary when you installed it). If it says something like nasm: ELF 32-bit LSB executable i386 (386 and up) Version 1 then your system is ELF, and you should use the option -f elf when you want NASM to produce Linux object files. If it says nasm: Linux/i386 demand-paged executable (QMAGIC) or something similar, your system is a.out, and you should use -f aout instead (Linux a.out systems have long been obsolete, and are rare these days.) Like Unix compilers and assemblers, NASM is silent unless it goes wrong: you won’t see any output at all, unless it gives error messages.-f format select output file formatbin Flat raw binary (MS-DOS, embedded, ...) [default]ith Intel Hex encoded flat binarysrec Motorola S-records encoded flat binaryaout Linux a.outaoutb NetBSD/FreeBSD a.outcoff COFF (i386) (DJGPP, some Unix variants)elf32 ELF32 (i386) (Linux, most Unix variants)elf64 ELF64 (x86-64) (Linux, most Unix variants)elfx32 ELFx32 (ELF32 for x86-64) (Linux)as86 as86 (bin86/dev86 toolchain)obj Intel/Microsoft OMF (MS-DOS, OS/2, Win16)win32 Microsoft extended COFF for Win32 (i386)win64 Microsoft extended COFF for Win64 (x86-64)rdf Relocatable Dynamic Object File Format v2.0ieee IEEE-695 (LADsoft variant) object file formatmacho32 Mach-O i386 (Mach, including MacOS X and variants)macho64 Mach-O x86-64 (Mach, including MacOS X and variants)dbg Trace of all info passed to output stageelf Legacy alias for "elf32"macho Legacy alias for "macho32"win Legacy alias for "win32"

hello,world例子

(base) [myhaspl@localhost nasm]$ cat test.asm section .data ;section declaration msg db "Hello, world!",0xA ;our dear string len equ $ - msg ;length of our dear string section .text ;section declaration;we must export the entry point to the ELF linker orglobal _start ;loader. They conventionally recognize _start as their;entry point. Use ld -e foo to override the default. _start: ;write our string to stdoutmov eax,4 ;system call number (sys_write)mov ebx,1 ;first argument: file handle (stdout)mov ecx,msg ;second argument: pointer to message to writemov edx,len ;third argument: message lengthint 0x80 ;call kernel ;and exitmov eax,1 ;system call number (sys_exit)xor ebx,ebx ;first syscall argument: exit codeint 0x80 ;call kernel (base) [myhaspl@localhost nasm]$ (base) [myhaspl@localhost nasm]$ nasm -f elf64 test.asm (base) [myhaspl@localhost nasm]$ ls test.asm test.o (base) [myhaspl@localhost nasm]$ ld -s -o test test.o (base) [myhaspl@localhost nasm]$ ls test test.asm test.o (base) [myhaspl@localhost nasm]$ ./test Hello, world!

4、基本輸入輸出系統(BIOS)

總結

以上是生活随笔為你收集整理的汇编解析(3)-nasm基础、物理地址的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。