nasm

unable to open include file 'io.mac' assembly

梦想的初衷 提交于 2019-12-13 06:25:42
问题 I am using nasm assembler and 32 bit Ubuntu.When I try to execute a program,"unable to open include file 'io.mac' " error occurs.My compile commands : nasm -f elf32 fact.asm After I have searched this problem in some sites,I try : nasm -f elf32 fact.asm -l fact.lst However,error has not changed.Pls help. 回答1: If you haven't got the file, this may be it: http://www.scs.carleton.ca/sivarama/org_book/org_book_web/source_code.html If you have the file, but it isn't in the current directory, the

How to use nasm to generate a dynamic linked exe on windows?

孤街醉人 提交于 2019-12-13 06:21:02
问题 Basically I know we can use this to create a static linked exe on windows 32 bit: nasm -fwin32 test.s cl.exe test.obj /link libcmt.lib But how to create a dynamic-linked exe from the obj file nasm generated? 来源: https://stackoverflow.com/questions/21010335/how-to-use-nasm-to-generate-a-dynamic-linked-exe-on-windows

Manipulating arrays in assembly

时光总嘲笑我的痴心妄想 提交于 2019-12-13 05:23:43
问题 I have a problem, that i cant figure out: In assembly language, write a function that receives a pointer to an array of integers and the size of this array, and changes the array by reversing its elements without copying the array to stack. Use the dedicated instructions and registers to work with arrays ( esi , edi ; lodsb , stosb , cld , std ). Example: 1 2 3 4 5 -> 5 4 3 2 1 Anyone have any suggestions? 回答1: Reversing an array with lodsb and stosb requires cld and std for every element

How to check if a number represents an uppercase character in NASM Assembly?

冷暖自知 提交于 2019-12-13 04:47:07
问题 Suppose that you have a number stored in EAX . How can I check whether this number represents an uppercase character or not? Frankly, I haven't tried anything. The closest idea I had was to create an array of upper case characters ('A','B','C,'D',...) and then check if EAX was equal to any of these. Is there a simpler way to do this in NASM Assembly? I'm using 64-bit CentOS, for a 32-bit program. 回答1: For ASCII characters, something like this would work: cmp eax,'A' setnc bl ; bl = (eax >= 'A

Binary representation in processor's registers in Nasm

旧城冷巷雨未停 提交于 2019-12-13 04:46:46
问题 I would like to ask about process of put instructions into registers. For example: we want to overwrite count '50' into EBX (in ASCII '50' is count '2'). EBX consists of 32 bits. When we put '50' into it, it will be arranged as binary represent, yes? (0000000 | 00000000 | 00000000 | 00110010). Have a right? What happens with bits, when we place a string into register? 回答1: EAX holds 32 bits which Intel calls "integer". The programmer - and sometimes the assembler - decides how to interpret

Print out string with spaces

戏子无情 提交于 2019-12-13 04:38:23
问题 I am trying to loop through a string in nasm and printing it back out with a space in between each character and incrementing any digit less than 9 by 1. So for example; if I type in command line; str1 Hello8 str1 1234 str1 9 The output should be; H e l l o 9 1 2 3 4 9 I've managed to print out the first two arguments; %include "asm_io.inc" global asm_main section .data section .bss section .text asm_main: enter 0, 0 pusha mov eax, dword [ebp+8] ; argc call print_int ; display argc call print

Executable isn't compatible with 64 bits processor

倖福魔咒の 提交于 2019-12-13 04:36:10
问题 My problem is that this: When I try to execute an .exe assembled in NASM and Windows 8 64 bits tells me that this .exe isn't compatible with 64 bits. So, how should I assemble this code (I obtained it from the Web)? Used code STD_OUTPUT_HANDLE equ -11 STD_INPUT_HANDLE equ -10 NULL equ 0 global start extern ExitProcess, GetStdHandle, WriteConsoleA, ReadConsoleInputA section .data ;message we want to display on console msg db "Press a key to continue...", 13, 10, 0 msg.len equ $ - msg

Declaring a pointer in nasm

我是研究僧i 提交于 2019-12-13 04:26:56
问题 I am writing a simple os in nasm and I am new to assembly. From c I am used to be able to declare pointers without reserving memory for them and moving them around as I please. How can I do this in nasm? If I declare a variable e.g. by var: resb 1 I understand that I declare a pointer and can access the value of the variable e.g. by mov eax, [var] Though, I cannot move the pointer to another address by mov var, 0x1234 then I get "invalid combination of opcode and operands". So how can I

What syntax does a disassembled .s file is not acceptable in nasm?

浪子不回头ぞ 提交于 2019-12-13 04:17:55
问题 This code is a C program (bubble sort) disassembled into assembly. How can I make the following code run if I put it in a .asm file and use nasm to assemble? If you know what needs changing, please say what to change it to. For instance I understand that nasm won't accept DWORD PTR , but I haven't found out what to do instead. Thanks .file "sort.c" .intel_syntax noprefix .text .globl sort .type sort, @function sort: .LFB0: .cfi_startproc push rbp .cfi_def_cfa_offset 16 .cfi_offset 6, -16 mov

Windows multicore threads enter their function but return results randomly

孤街浪徒 提交于 2019-12-13 03:57:22
问题 For several days I have had trouble with creating four threads (for four cores) on a Windows 7 Ivy Bridge system. I have created a simple test function in NASM, as minimal as it can be, to demonstrate. The program increments a counter from 0 to 1 billion and returns the result. For multicore processing, I divided it so core 1 counts from 0 to 2.5 million, core 2 counts from 2.5 million to 5 million, etc. For testing purposes. the program returns a 12-element array with three values from each