nasm

What is the @n (“at sign”) after every function name?

时间秒杀一切 提交于 2019-12-24 03:19:35
问题 I'm trying to learn assembly language, using Netwide Assembler. In tutorials, I see that there's an @ n at the end of every function name, like: CALL _GetStdHandle@4 CALL _WriteFile@20 CALL _ExitProcess@4 What does this @ n mean? (It seems to be part of the function name, in that I get error LNK2001: unresolved external symbol errors if I modify or remove that part, but obviously it's not part of the name of the C or C++ function that it was generated from. Where does it come from?) 回答1:

macro to allocate space in memory

自闭症网瘾萝莉.ら 提交于 2019-12-24 01:55:13
问题 i need to make an assembly programmer to calculate pascal triangle . so that every line of pascal triangle stored in memory place separate from other line i want to make one but i have no idea how to do it in assembly using macro . macro take an number and allocate that number of dword in memory i did a try but i don't know if it is the correct way to do it %macro Malloc 2 %2 : resd %1 %endmacro i want to know 2 thing : first i want the second arg ( %2 ) to have a string name automatically

macro to allocate space in memory

时光怂恿深爱的人放手 提交于 2019-12-24 01:54:59
问题 i need to make an assembly programmer to calculate pascal triangle . so that every line of pascal triangle stored in memory place separate from other line i want to make one but i have no idea how to do it in assembly using macro . macro take an number and allocate that number of dword in memory i did a try but i don't know if it is the correct way to do it %macro Malloc 2 %2 : resd %1 %endmacro i want to know 2 thing : first i want the second arg ( %2 ) to have a string name automatically

Why didn't I get segmentation fault when storing past the end of the BSS?

爷,独闯天下 提交于 2019-12-24 01:54:30
问题 I'm experimenting with assembly language and wrote a program which prints 2 hardcoded bytes into stdout. Here it is: section .text global _start _start: mov eax, 0x0A31 mov [val], eax mov eax, 4 mov ebx, 1 mov ecx, val mov edx, 2 int 0x80 mov eax, 1 int 0x80 segment .bss val resb 1; <------ Here Note that I reserved only 1 byte inside the bss segment, but actually put 2 bytes (charcode for 1 and newline symbol) into the memory location. And the program worked fine. It printed 1 character and

Write to address without segment register

ぃ、小莉子 提交于 2019-12-24 00:32:36
问题 I know this code will actually write data to ds:[100h] mov [100h], ax But how can I write to linear address 100H directly without using any segment register for a segment base? 回答1: There is no way to get around segment register; every memory access is relative to some segment register. If you want to write to an absolute address, first load a segment register with an appropriate segment: xor cx, cx mov es, cx ; es = 0000 mov [es:100h], ax ; [0000:0100] = ax To load a linear address larger

What does the lower left pane in OllyDbg displays?

梦想的初衷 提交于 2019-12-24 00:06:35
问题 I have assembled the following code using NASM: global _start section .data var1 DD 0xA1A2A3A4 ; 4 bytes var2 DD 0xB1B2B3B4 ; 4 bytes section .bss var3: RESD 1 ; 4 bytes section .text _start: mov DWORD [var3], 0xC1C2C3C4 I opened the file in OllyDbg and made it execute the instruction: mov DWORD [var3], 0xC1C2C3C4 . This is the state of the lower left pane in OllyDbg after executing this instruction: What I want to know is what does the lower left pane displays? does it display the data

NASM: Disk read timeout

拈花ヽ惹草 提交于 2019-12-24 00:02:50
问题 Trying to read data from disk (from the same file), loading 2 additional 512-byte sectors into memory. Disk read function as is: ; read DH sectors to ES:BX from drive DL disk_read: push dx push bx ; Tried to check if disk is ready first, this code runs without errors mov ah, 0x10 int 0x13 jc disk_not_ready mov bx , DISK_CURRENT_STATUS_MSG call print_string mov bx, 0 mov bl , ah call print_hex pop bx mov ah , 0x42 ; BIOS read sector function mov al , dh ; Read DH sectors mov ch , 0x00 ; Select

How to set the alignment for the .data section?

末鹿安然 提交于 2019-12-23 16:42:35
问题 I defined the following variables in the .data section in NASM: section .data var1 DD 12345 ; int (4 bytes) var2 DB 'A' ; char (1 byte) padding1 DB 123 ; 1 byte padding padding2 DB 123 ; 1 byte padding padding3 DB 123 ; 1 byte padding var3 DQ 174.13 ; double (8 bytes) In order for these variables to be correctly aligned, the .data section must be aligned to 8 bytes. I believe that the alignment for the .data section is specified by the linker. I am using the Visual C++ 2010 linker, how can I

Is it possible to make writeable variables in .text segment using DB directive in NASM?

老子叫甜甜 提交于 2019-12-23 15:38:08
问题 I've tried declaring variables in .text segment using e.g. file_handle: dd 0 . However, trying to store something in this variable like mov [file_handle], eax results in a write error. I know, I could declare writeable variables in the .data segment, but to make the code more compact I'd like to try it as above. Is the only possibility to use the stack for storing these value (e.g. the file handle), or could I somehow write to my variable above? 回答1: Executable code segments are not writable

How to call fgets in x86 assembly?

萝らか妹 提交于 2019-12-23 12:06:03
问题 According to the documentation for fgets(), the function takes three parameters: char * - a string that will hold the input int - an integer that represents the maximum number of characters to read FILE * - a FILE * to the stream to read from I have no trouble calling the function. I just push the three parameters onto the stack, call the function, and increase ESP by 12. My problem is with parameter #3. What should be passed in as the FILE * for standard input? In C, I can just use stdin ,