nasm

Near and Far JMPs

故事扮演 提交于 2019-12-12 08:01:51
问题 I am doing Linux assembly and I understand that is has a flat memory model. What I am confused about is NEAR and FAR JMPs. NEAR is in the same segment while FAR is another segment. From what I understand there are no segments in linux virtual memory? Also how do we know if my program's code is laid out in multiple segments? 回答1: It hasn't been segments for a long time now. The correct term in protected mode x86 is selector. Having said that, the difference between a near jump and a far one is

gas vs. nasm: which assembler produces the best code?

萝らか妹 提交于 2019-12-12 07:53:58
问题 Both tools translate assembly instructions directly into machine code, but is it possible to determine which one produces the fastest and cleanest code? 回答1: When you're writing in assembler, you are precisely describing the instructions to generate so it doesn't depend on the assembler. It depends on you. There's a one-to-one correspondence between the mnemonics you write and actual instructions in machine code. 回答2: I don't know about these two specific tools, but there are some

Does gcc really know how to output NASM Assembly

痞子三分冷 提交于 2019-12-12 07:20:09
问题 So I have a simple C program that loops through the args passed to main then returns: #include <stdio.h> int main(int argc, char *argv[]) { int i; for(i = 0; i < argc; ++i) { fprintf(stdout, "%s\n", argv[i]); } return 0; } I wanted to see how gcc wrote out the assembly in NASM format. I was looking over the output in the .asm file and noticed that the syntax was TASM. Below is the make file and the output from gcc. Am I doing something wrong or is it that gcc does not output true NASM syntax?

NASM: why must __float32__(1.5) be used for floating point literals instead of just 1.5?

做~自己de王妃 提交于 2019-12-12 06:37:19
问题 What is the rationale for: mov eax, 1.5 not working with: expression syntax error and requiring you to do: mov eax, __float32__(1.5) instead? The fact that it works for the dd family: dd 1.5 makes me even more curious. Would there be a syntax ambiguity with some other language feature in that case? Couldn't the size just be inferred from the register size as when we do: mov eax, 1 I have also posted on their bugtracker, but no reply so far: http://bugzilla.nasm.us/show_bug.cgi?id=3392309 回答1:

Explanation of a few lines in Assembly

旧城冷巷雨未停 提交于 2019-12-12 05:49:44
问题 bits 16 org 0x7c00 start: jmp loader ;******; ; OEM Parameter block ;********; TIMES 0Bh-$+start DB 0; THIS LINE bpbBytesPerSector: DW 512 bpbSectorsPerCluster: DB 1 bpbReservedSectors: DW 1 bpbNumberOfFATs: DB 2 bpbRootEntries: DW 224 bpbTotalSectors: DW 2880 bpbMedia: DB 0xF0 bpbSectorsPerFAT: DW 9 bpbSectorsPerTrack: DW 18 bpbHeadsPerCylinder: DW 2 bpbHiddenSectors: DD 0 bpbTotalSectorsBig: DD 0 bsDriveNumber: DB 0 bsUnused: DB 0 bsExtBootSignature: DB 0x29 bsSerialNumber: DD 0xa0a1a2a3

DOS INT 21H Function 0AH in nasm style

混江龙づ霸主 提交于 2019-12-12 05:24:52
问题 I am trying to use nasm to rewrite assembly programs in "IBM PC ASSEMBLY LANGUAGE AND PROGRAMMING" (15th edition) by Peter Abel. And here is the demo on buffering input, given on the page of 144, Chapter 8. The program is equivalent to the C programming char name[20]; scanf("Name?%s", &name); /*print the input name in the middle of the screen 25 * 80*/ .... My rewrite program is: ;file: A08CTRNM.asm segment data paralist: maxlen: db 20 ;The maximum length of the string will be 20 actulen:

C Calling Conventions 32bit to NASM with float (movups/movupd difference)

放肆的年华 提交于 2019-12-12 04:59:29
问题 I have this func in C. When I use istructions like: movss, movaps, movups all work propely, instead when I use istructions like: movupd, movapd, ecc.. it not work.. and return strange values CODE THAT WORK PROPELY WITH movaps, movups,ecc.. C: extern float test(float* a,float* b, int num, int spuri, float* res); int main(int argc, char** argv) { float a[] = { 1.0, 2.0, 3.0, 4.0, 6.0, 9.0 }; float b[] = { 3.0, 4.0, 4.0, 5.0, 5.0, 8.0 }; int d=6; int num=d/4; int spuri=d-(num*4); float res=-1.0;

NASM Subroutine Call Segmentation Fault

扶醉桌前 提交于 2019-12-12 04:23:14
问题 I'm working on a school project involving NASM, and while the language makes some kind of sense to me I always end up having a problem that makes no sense. The program I'm writing involves 1 command line argument, which must be a string of 0s, 1s, and/or 2s. If it is not, an error message is displayed and the program ends. If there are no errors, the "suffixes" of the string are displayed in order. Example: "./sufsort 00100102" should produce sorted suffixes: 00100102 00102 0100102 0102 02

Assembly (Intel syntax + NASM) Error: attempt to define a local label before any non-local labels

戏子无情 提交于 2019-12-12 04:13:39
问题 I am quite new regarding the assembly and I am trying to work with a program. So whenever I try to compile it, I get the error for the line, as listed under the comments in the code. I am wondering if anyone has any ideas why NASM detects this errors when I am defining some things for the rest of the assembly code? Maybe it has to do something with how the main is defined? P.S. I listed just the first part of the code, since the program is quite long. Thank you for the help .xlist ;attempt to

NASM far jump / far call in real mode and ASM code conventions

隐身守侯 提交于 2019-12-12 03:35:31
问题 I tried to make a bootloader the last few days and this is the result: BITS 16 ;CONSTANTS BOOTSEG equ 07C0h STACKSEG equ 1BC0h ; BOOTSEG + 512 Byte (bootloader) + 512 Byte (second stage) + 4096 Byte (buffer) = 1BC0h STACKSIZE equ 0400h ; 1KB stack ; INIT mov AX, BOOTSEG mov DS, AX ; set data segment to adress where bootloader will be loaded to mov AX, STACKSEG cli ; disable interrupts while set up stack mov SS, AX mov SP, STACKSIZE ; set up stack sti ; restore interrupts mov [bootdev], DL ;