assembly

DosBox is buggy with int 15h ah = 86h

无人久伴 提交于 2021-02-11 08:46:11
问题 I am currently working on an assembly program, but I need to make the program wait every once in a while. So, I have been using int 15h/ah = 86h, but for some reason DosBox is giving me a hard time, and the program either gets confused with pixels (wierd colors) or in the worse case; crash. Can someone please help me? 回答1: I had this issue as well. Based on the answer at Problems with BIOS delay function (INT 15h / AH = 86h), I was able to get it working by making sure to set AL to zero

Assembly safes and keys- why it won't work?

谁说我不能喝 提交于 2021-02-11 08:41:44
问题 So we have like this safes challenge in assembly, you need to create safes and keys that will break them and end the infinite loop. Here's an example for a safe: loopy: mov ax, [1900] cmp ax,1234 jne loopy and a key: loopy2: mov ax, 1234 mov [1900],ax jmp loopy2 So I have a safe and a key, and I don't understand why it doesn't work: here's my safe: org 100h mySafe: mov dx,5 mov ax, [5768h] mov bx,7 mov word [180h],2 mul word [180h] mov [180h],bx push ax dec bx mov cx,dx mov ax,dx loopy1: add

In assembly, how do I add a 5 byte instruction into a 3 byte space in the debugger

萝らか妹 提交于 2021-02-11 07:49:40
问题 I'm trying to change this line 0041DE91 | 8B 46 64 | mov eax,dword ptr ds:[esi+64] 0041DE94 | 83 C4 0C | add esp,C 0041DE97 | 83 F8 01 | cmp eax,1 to 0041DE91 | mov eax, 10 But the instruction which was 3 bytes occupies 5 bytes and spills into the two addresses below it: 0041DE91 | B8 0A 00 00 00 | mov eax,10 0041DE96 | 0C 83 | or al,83 0041DE98 | F8 | clc Is it possible to do this in a debugger to a pre-compiled program? 回答1: In 32-bit code (where there's no red-zone to clobber) you can move

Passing parameters from C to GNU Assembly function in 64bit

坚强是说给别人听的谎言 提交于 2021-02-11 07:09:02
问题 I have main function in C that runs code in assembly. I just want to make simple sum: main.c #include <stdio.h> extern int addByAssembly(int first_number, int second_number); int main (int argc, char **argv) { int sum=0; sum = addByAssembly(5,4); printf ("%d\n",sum); return 0; } addByAssembly.s .data SYSREAD = 0 SYSWRITE = 1 SYSEXIT = 60 STDOUT = 1 STDIN = 0 EXIT_SUCCESS = 0 .text #.global main #main: #call write #movq $SYSEXIT, %rax #movq $EXIT_SUCCESS, %rdi #syscall #******** .globl

Undefined reference to in os kernel linking

不羁岁月 提交于 2021-02-11 05:00:58
问题 i have a problem. I making simple OS kernel with this tutorial: http://wiki.osdev.org/Bare_Bones#Linking_the_Kernel but,if i want to link files boot.o and kernel.o, gcc compiler returns this error: boot.o: In function `start': boot.asm:(.text+0x6): undefined reference to `kernel_main' collect2.exe: error: ld returned 1 exit status. sources of files: boot.asm ; Declare constants used for creating a multiboot header. MBALIGN equ 1<<0 ; align loaded modules on page boundaries MEMINFO equ 1<<1 ;

Undefined reference to in os kernel linking

拈花ヽ惹草 提交于 2021-02-11 04:57:23
问题 i have a problem. I making simple OS kernel with this tutorial: http://wiki.osdev.org/Bare_Bones#Linking_the_Kernel but,if i want to link files boot.o and kernel.o, gcc compiler returns this error: boot.o: In function `start': boot.asm:(.text+0x6): undefined reference to `kernel_main' collect2.exe: error: ld returned 1 exit status. sources of files: boot.asm ; Declare constants used for creating a multiboot header. MBALIGN equ 1<<0 ; align loaded modules on page boundaries MEMINFO equ 1<<1 ;

What does the D flag in the code segment descriptor do for x86-64 instructions?

谁说我不能喝 提交于 2021-02-10 18:14:50
问题 I'm trying to understand the workings of the D flag in the code segment descriptor when used in the x86-64 code. It's set in the D/B bit 22 of the code segment descriptor as shown on this diagram: The Intel documentation (from section 3.4.5 Segment Descriptors) states the following: D/B (default operation size/default stack pointer size and/or upper bound) flag Performs different functions depending on whether the segment descriptor is an executable code segment, an expand-down data segment,

label inconsitently redefined NASM

我的梦境 提交于 2021-02-10 17:47:32
问题 i have been following a YouTube tutorial on how to make an operating system, as well as experimenting with writing assembly code my self. I use NASM to turn my assembly files into executable binaries, and use qemu to run them. -=-=-=-=-= boot.asm [org 0x7c00] mov [BOOT_DISK], dl mov bp, 0x7c00 mov sp, bp mov bx, tst call pst call readisk %include 'print.asm' %include 'diskread.asm' jmp $ times 510-($-$$) db 0 db 0x55, 0xaa -=-=-=-=-= diskread.asm PROGRAM_SPAVE equ 0x7e00 readisk: mov bx,

label inconsitently redefined NASM

别来无恙 提交于 2021-02-10 17:46:35
问题 i have been following a YouTube tutorial on how to make an operating system, as well as experimenting with writing assembly code my self. I use NASM to turn my assembly files into executable binaries, and use qemu to run them. -=-=-=-=-= boot.asm [org 0x7c00] mov [BOOT_DISK], dl mov bp, 0x7c00 mov sp, bp mov bx, tst call pst call readisk %include 'print.asm' %include 'diskread.asm' jmp $ times 510-($-$$) db 0 db 0x55, 0xaa -=-=-=-=-= diskread.asm PROGRAM_SPAVE equ 0x7e00 readisk: mov bx,

Assembler code, need help understand what 'movzwl 0x40272e(,%rax,4),%esi' is doing

▼魔方 西西 提交于 2021-02-10 17:29:22
问题 i understand what the other calls are doing but when i get line 36, i don't get what's happening? my 3 parameters are rsi = 5, rdx = 6, rcx = 7 On line 26 my %rax = 25 then on line 30 my rsi changes from 5 to 37 can you explain why this happens? and what is 0x40272e 0x0000000000401212 <+0>: sub $0x8,%rsp # subtract 8 from rsp 0x0000000000401216 <+4>: lea -0x1(%rdx),%rax # rax = -1 + rdx 0x000000000040121a <+8>: cmp $0xf,%rax # rax ?? 0xf '-1' 'SI' 0x000000000040121e <+12>: ja 0x40124f <phase