nasm

How to push a 64bit int in NASM?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-17 06:14:53
问题 I'm trying to push a 64bit integer but when assembling NASM seems to want to see it as a DWORD not a QWORD. I'm using ASM to create the shellcode I need to inject a 64bit DLL into a 64bit process. The first QWORD is the old instruction pointer, the second is the address containing the address of the DLL, the third is the address of LoadLibrary. The placeholders are filled in at runtime. section .text global _start _start: BITS 64 PUSH QWORD 0xACEACEACACEACEAC PUSHFQ push rax PUSH QWORD

Assembly segmentation fault after making a system call, at the end of my code

試著忘記壹切 提交于 2019-12-17 03:44:13
问题 I was experimenting and have the following assembly code, which works very well, except that I get a "Segmentation fault (core dumped)" message right before my program ends: GLOBAL _start %define ___STDIN 0 %define ___STDOUT 1 %define ___SYSCALL_WRITE 0x04 segment .data segment .rodata L1 db "hello World", 10, 0 segment .bss segment .text _start: mov eax, ___SYSCALL_WRITE mov ebx, ___STDOUT mov ecx, L1 mov edx, 13 int 0x80 It doesn't matter whether or not I have ret at the end; I still get

Obtaining peak bandwidth on Haswell in the L1 cache: only getting 62%

好久不见. 提交于 2019-12-17 02:58:57
问题 I'm attempting to obtain full bandwidth in the L1 cache for the following function on Intel processors float triad(float *x, float *y, float *z, const int n) { float k = 3.14159f; for(int i=0; i<n; i++) { z[i] = x[i] + k*y[i]; } } This is the triad function from STREAM. I get about 95% of the peak with SandyBridge/IvyBridge processors with this function (using assembly with NASM). However, using Haswell I only achieve 62% of the peak unless I unroll the loop. If I unroll 16 times I get 92%. I

ASM subroutine to print coloured text at specific location on the screen

ぐ巨炮叔叔 提交于 2019-12-14 02:40:17
问题 I'm trying to write some ASM code that will write some text to the display using BIOS interrupts. This code will run from the boot sector. I have msgText DB "Hello" ;Text msgCol DB 0x07,0x08,0x09,0x0A,0x0B ;Colours msgXY DW 0x0E26 ;Col/Row msgLen DB 0x05 ;Length The message is just "Hello", each letter having a different colour. The position of the message on the screen is roughly in the middle, and it has a length of 5. I want to write a function that will write any message/colour/xy/length

x86 assembly 16 bit vs 8 bit immediate operand encoding

穿精又带淫゛_ 提交于 2019-12-14 01:17:35
问题 I'm writing my own assembler and trying to encode the ADC instruction, I have a question about immediate values, especially when adding 8-bit value into the AX register. When adding 16-bit value: adc ax, 0xff33 gets encoded as 15 33 ff which is correct. But would it matter if adc ax, 0x33 gets encoded as 15 33 00 ? Nasm encodes this into 83 d0 33 which is obviously correct, but is my approach correct as well? 回答1: It's common for x86 to have more than 1 valid way of encoding an instruction. e

make bootloader and kernel into iso?

痴心易碎 提交于 2019-12-14 01:04:23
问题 how to create simple bootloader that load kernel into iso? it has been 5 days , I searching in google and do trial and error many times but got nothing.....I have tried many tutorial like mikeos,osdev,supernova,cosmos os but still get no solution..... my computer doesn't have floopy disk so I can't make bootloader using floopy disk... I see in mikeos tutorial first sector 512 byte is for bootloader and second for kernel can be made using imdisk but using floopy disk also he can made

Multicore in NASM Windows: threads execute randomly

瘦欲@ 提交于 2019-12-13 22:14:59
问题 I have code in NASM (64 bit) in Windows to run four simultaneous threads (each assigned to a separate core) on a four-core Windows x86-64 machine. The threads are created in a loop. After thread creation, it calls WaitForMultipleObjects to coordinate the threads. The function to call is Test_Function (see code below). Each thread (core) executes Test_Function across a large array. The first core starts at data element zero, the second core starts at 1, the third core starts at 2, the fourth

Finding substring in assembly

蓝咒 提交于 2019-12-13 18:18:56
问题 I'm wondering if there is a more efficient method to finding a substring in assembly then what I am currently planning to do. I know the string instruction "scansb/scasw/scads" can compare a value in EAX to a value addressed by EDI. However, as far as I understand, I can only search for one character at a time using this methodology. So, if I want to find the location of "help" in string "pleasehelpme", I could use scansb to find the offset of the h, then jump to another function where I

Switch to and from 16-bit Real Mode and 32-bit Protected Mode

那年仲夏 提交于 2019-12-13 17:51:45
问题 I'm interested in writing my own microkernel with graphics support. However, as far as I know there is no way to change the graphics mode without interrupt 0x10 , which requires Real Mode. How can I switch between Real and Protected Mode during the application's runtime? I have seen an article on osdev.org, but since I am new to assembly I cannot work out how to implement this. Technical details: Ubuntu 16.04.4 LTS GCC 7.3.0 cross-compiler (i686-elf) NASM 2.11.08 assembler, but inline GAS

Assembly 32-bit print to display code runs on qemu, fails to work on real hardware

岁酱吖の 提交于 2019-12-13 16:13:01
问题 I've written a small piece of code in x86 assembly language that runs on bare hardware which, at this point, goes as far as enabling protected 32-bit mode I've run into a problem, however, pertaining printing to the screen. I've read that to do so without interrupts one may load characters into a special memory region, namely RAM address 0xb8000. Knowing this, I wrote a function that does exactly that, and it proved a success when tested in qemu. However, and here comes the problem, when I