nasm

GNU GAS: Label is not relatively referenced

烈酒焚心 提交于 2020-06-09 04:32:30
问题 I am writing a little bootsector for learning purpose. Here is boot.S .code16 .text movw $0xB800, %ax /* 0xB000 is the text screen video memory */ movw %ax, %es /* set it as the %es segment */ movb label, %al movb %al, %es:0x0 /* screen[0] = 'A' */ movb $0x07, %es:0x1 /* white on black */ jmp . label: .byte 'A .=510 .byte 0x55 .byte 0xAA and here is the Makefile I use to compile it to a raw binary file hdd.img: boot.S as $< -o boot.o ld --oformat binary -Ttext 0x7c00 boot.o -o hdd.img I face

How to execute a call instruction with a 64-bit absolute address?

旧城冷巷雨未停 提交于 2020-06-08 06:14:05
问题 I am trying to call a function - that should have an absolute address when compiled and linked - from machine code. I am creating a function pointer to the desired function and trying to pass that to the call instruction, but I noticed that the call instruction takes at most a 16 or 32-bit address. Is there a way to call an absolute 64-bit address? I am deploying for the x86-64 architecture and using NASM to generate the machine code. I could work with a 32-bit address if I could be

Switch to VESA/VBE?

北城以北 提交于 2020-05-28 07:53:49
问题 So, I'm currently working on an OS, and I'm stuck in a very dumb situation : switching to VESA/VBE My current code : mov ax, 0x4F02 mov bx, 0x4118 int 0x10 It changes Qemu resolution, but now I have a problem with plotting pixels. The formula of the pixel offset is : uint32 pixel_offset = y * pitch + (x * (bpp/8)) + framebuffer; The problem is that bpp, pitch and framebuffer are supposed to be given by mov ax, 0x4F01 int 0x10 and mov ax, 0x4F00 int 0x10 First, mov ax, 0x4F00 int 0x10 softlock

Switch to VESA/VBE?

百般思念 提交于 2020-05-28 07:53:24
问题 So, I'm currently working on an OS, and I'm stuck in a very dumb situation : switching to VESA/VBE My current code : mov ax, 0x4F02 mov bx, 0x4118 int 0x10 It changes Qemu resolution, but now I have a problem with plotting pixels. The formula of the pixel offset is : uint32 pixel_offset = y * pitch + (x * (bpp/8)) + framebuffer; The problem is that bpp, pitch and framebuffer are supposed to be given by mov ax, 0x4F01 int 0x10 and mov ax, 0x4F00 int 0x10 First, mov ax, 0x4F00 int 0x10 softlock

Switch to VESA/VBE?

与世无争的帅哥 提交于 2020-05-28 07:53:17
问题 So, I'm currently working on an OS, and I'm stuck in a very dumb situation : switching to VESA/VBE My current code : mov ax, 0x4F02 mov bx, 0x4118 int 0x10 It changes Qemu resolution, but now I have a problem with plotting pixels. The formula of the pixel offset is : uint32 pixel_offset = y * pitch + (x * (bpp/8)) + framebuffer; The problem is that bpp, pitch and framebuffer are supposed to be given by mov ax, 0x4F01 int 0x10 and mov ax, 0x4F00 int 0x10 First, mov ax, 0x4F00 int 0x10 softlock

How do I read a file with ReadFile onto the stack in NASM x86 assembly?

 ̄綄美尐妖づ 提交于 2020-05-24 07:42:51
问题 I have opened a file with OpenFile, and gotten its size with GetFileSize. I wish to use ReadFile and use the stack as the buffer it requires, allocating enough room on the stack with the size of the file returned from GetFileSize. When I run this I get no output. Here is my code... extern GetStdHandle extern GetModuleFileNameA extern OpenFile extern ReadFile extern WriteFile extern CloseHandle extern GetFileSize extern ExitProcess import GetStdHandle kernel32.dll import GetModuleFileNameA

How do I read a file with ReadFile onto the stack in NASM x86 assembly?

[亡魂溺海] 提交于 2020-05-24 07:42:43
问题 I have opened a file with OpenFile, and gotten its size with GetFileSize. I wish to use ReadFile and use the stack as the buffer it requires, allocating enough room on the stack with the size of the file returned from GetFileSize. When I run this I get no output. Here is my code... extern GetStdHandle extern GetModuleFileNameA extern OpenFile extern ReadFile extern WriteFile extern CloseHandle extern GetFileSize extern ExitProcess import GetStdHandle kernel32.dll import GetModuleFileNameA

NASM Assembler, how to define label twice?

﹥>﹥吖頭↗ 提交于 2020-05-23 10:53:54
问题 I have different "*.asm" files that need to be included in the "main.asm" file. The problem I'm facing is that: In many files I have declared labels like "loop", "forLoop", "whileTag" etc... in the same way ( i.e. with the same name ) And when I try to %include "file1.asm" and %include "file2.asm" it gives me a compilation error. It says that I can't declare the same label twice ( i.e. file1.asm and file2.asm, both have "loopHere" label declared ). How do I solve this ? Thanks The problem

NASM Assembler, how to define label twice?

本小妞迷上赌 提交于 2020-05-23 10:53:03
问题 I have different "*.asm" files that need to be included in the "main.asm" file. The problem I'm facing is that: In many files I have declared labels like "loop", "forLoop", "whileTag" etc... in the same way ( i.e. with the same name ) And when I try to %include "file1.asm" and %include "file2.asm" it gives me a compilation error. It says that I can't declare the same label twice ( i.e. file1.asm and file2.asm, both have "loopHere" label declared ). How do I solve this ? Thanks The problem

Confusion with how Win32 API calls work in assembly

孤人 提交于 2020-05-13 06:46:50
问题 I don't know how to ask this better but why does this: call ExitProcess do the same as this?: mov eax, ExitProcess mov eax, [eax] call eax I would think that these would be equivalent: call ExitProcess mov eax, ExitProcess call eax 回答1: When importing the code from a DLL, the symbol ExitProcess isn't actually the address of the code that exits your process (it's the address of the address ). So, in that case, you have to dereference it to get the actual code address. That means that you must