nasm

How to copy 9th sector to 1st sector?

北城余情 提交于 2019-12-13 16:05:39
问题 I'm creating custom mbr, something like mbr-lovenote and i can't create code that will copy 9th sector - (there is located original mbr) to 1st sector, i already tried take some code from mbr-lovenote and modify it, but i find out that code only load sector in memory and jump to it, but i have to copy it. I write my code, the code will be loaded from fist sector on PhysicalDrive0 , but i don't know why it doesn't works. ;---create buffer buffer db 512 ;---read sector - 9th mov ax, buffer ;ES:

How link obj file from NASM with link.exe in Win10

霸气de小男生 提交于 2019-12-13 15:55:24
问题 I have the following code in NASM: ;sleep.asm [SECTION .text] global _start _start: xor eax,eax mov ebx, 0x00016630 ;address of Sleep mov ax, 5000 ;pause for 5000ms push eax call ebx ;Sleep(ms); Where 0x00016630 is the address of Sleep function (taken from dumpbin from kernel32.dll). I would like to make executable file to run in Win 10. What I did was: nasm -f win32 sleep.asm and have sleep.obj as result. So now I have to link it. I choose link.exe Unfortunately with the following command

How do I get user input with NASM?

痴心易碎 提交于 2019-12-13 12:17:22
问题 The program needs to take in a simple string from the user and display it back. I have gotten the program to take input from the user but I can't seem to store it. Here is what I have so far: BITS 32 global _main section .data prompt db "Enter a string: ", 13, 10, '$' input resd 1 ; something I can using to store the users input. name db "Name: ******", 13, 10,'$' StudentID db "********", 13, 10, '$' InBoxID db "*************", 13, 10, '$' Assignment db "************", 13, 10, '$' version db

idiv overflow exception asm

泪湿孤枕 提交于 2019-12-13 10:22:31
问题 I'm very new to assembly, before only C C++ I was trying to create a simple application that print all the prime number from 2 to given input When I run, it crashes, and that's normal. Looking at OllyDbg, the guilty piece is this: move eax, ebx idiv ecx ; !!! here It is strange because ecx is not 0 Values are EAX = 0000 0004, ECX = 0000 0002, and it says me that's an Integer_Overflow (exception C000 0095) How it's possible to have an overflow during a division? Both operands are 32bit

Adding value in register to memory operand produces 'error operation size not specified'

北城余情 提交于 2019-12-13 09:37:59
问题 section .data var dd 10 section .text add [var] , eax for above code nasm gives error operation size not specified, but if we reverse it add eax, [var] it doesn't gives error. why error for only first and not for second type ? 回答1: You need specify size like this: add dword [var],eax 回答2: Because the first operand is the destination operand and needs to be a register so instead just move it back : add eax, [var] mov [var], eax 来源: https://stackoverflow.com/questions/39426316/adding-value-in

NASM - Variable Basics

独自空忆成欢 提交于 2019-12-13 09:25:10
问题 I know that you can create a string in nasm by writing this: mystring db 'Hello World' But if I want to move a single character, let's say e, the second character in the string to the al register. How can I do that? Should I write mov al, mystring+1 or something? And how do I make an int variable? Can I write: myint db 4 回答1: 'mystring + 1' is the address of the second byte of the string. mov al, mystring + 1 stores (the least significant byte of) that address in al. To indicate that you don

nasm is not executing file in Windows 8

こ雲淡風輕ζ 提交于 2019-12-13 07:45:14
问题 Recently started learning Assembly so I'm relatively new to this. We use Linux back at school but I wanted to try coding on my PC. I'm using nasm on a Win8.1 64-bit system. Here's the code: section .text global _WinMain@16 _WinMain@16: mov edx, len mov ecx, msg mov ebx, 1 mov eax, 4 ret 16 mov eax, 1 ret 16 section .data msg db 'Hello, world!', 0xA len equ $ - msg nasm seems to be running since it responds to the commands, but it doesn't execute the program: How can I run the program? Is

Print ascii character on screen

为君一笑 提交于 2019-12-13 07:41:32
问题 I am writing a bootloader in assembly (NASM instruction set), but for some reason it doesn't show any letter. [BITS 16] [ORG 0x7C00] JMP $ MOV AL, 0x65 MOV AH, 0x0E MOV BL, 0x07 MOV BH, 0x00 INT 0x10 TIMES 510 - ($ - $$) db 0 DW 0xAA55 All I see is the _ cursor. 回答1: JMP $ Jumps to itself. Removing it will let the other code run 来源: https://stackoverflow.com/questions/38085205/print-ascii-character-on-screen

Determine number of negative and positive numbers in an array

Deadly 提交于 2019-12-13 07:38:19
问题 I need to determine the number of negative and positive numbers in an array in assembler. It seems that the assembler doesn't recognizes them as negative numbers. How can I solve this problem? I define the array this way: word_array db 3, -2, 11, -1, -2, -7, -5, -20 I have this function that counts the positive ones: count_positives: mov dx, word [word_array + 2*ecx - 2] cmp edx, 0 JL skip inc ebx skip: loopnz count_positives 回答1: Count either negative or non-negative, and subtract that from

Using GDB to debug assembly programs produced by NASM/MinGW doesn't stop at breakpoints?

别等时光非礼了梦想. 提交于 2019-12-13 07:16:46
问题 Using GDB to debug assembly programs produced by NASM/MinGW doesn't stop at breakpoints? Assembling and linking the program below produce unexpected results when debugging using GDB. nasm -g -f win32 insertion_sort_static.asm ld insertion_sort_static.obj -o test Now, when I run GDB and set a breakpoint at _exit , the program doesn't break at the specified point. Instead the program terminate. gdb test (gdb) break exit Breakpoint 1 at 0x401034 (gdb) run Starting program: C:\Users\nze\Desktop