assembly

FAT 12 Implementation

♀尐吖头ヾ 提交于 2020-02-23 04:08:29
问题 I have been following the Operating System development tutorial on http://www.brokenthorn.com. Right now I'm trying to setup the BIOS parameter block with this code: jmp loader bpbName db "NubOS",0,0,0 bpbBytesPerSector: DW 512 bpbSectorsPerCluster: DB 1 bpbReservedSectors: DW 1 bpbNumberOfFATs: DB 2 bpbRootEntries: DW 224 bpbTotalSectors: DW 2880 bpbMedia: DB 0xF0 bpbSectorsPerFAT: DW 9 bpbSectorsPerTrack: DW 18 bpbHeadsPerCylinder: DW 2 bpbHiddenSectors: DD 0 bpbTotalSectorsBig: DD 0

Return a float from a 64-bit assembly function that uses x87 FPU

隐身守侯 提交于 2020-02-20 11:43:50
问题 I am trying to make a program that calculates equations (what equation doesn't matter currently) that use 64-bit registers, floats, and coprocessor instructions. Unfortunately I don't know how to access the final outcome of the equation as a float. I can do: fist qword ptr [bla] mov rax,bla and change the function type to INT and get my value, but I cannot access it as a FLOAT. Even when I leave the result in ST(0) (the top of the coprocessor stack) it doesn't work as expected and my C++

How do I write letter-initiated hexadecimal numbers in masm code?

点点圈 提交于 2020-02-16 10:30:08
问题 I am currently editing several macros consisting of MASM code. They all look similar to this: Primary MACRO Key 0Bh,'0' Key 29h,15h Key 03h,'2' Key 06h,'5' Key 0Ch,'+' Key 0Dh,'´' Key 1Bh,'¨' Key 2Bh,27h Key 35h,'-' Key 34h,'.' Key 33h,',' Key 56h,'<' ENDM I have noticed that I can write hexadecimal numbers which are initiated by (begin with) character 0-9 in the following format: 02h , 12h , 5Ah , etc. However, if I try to write letter-initiated hexadecimal numbers in the same way (that is,

Why do i have this problem with breakpoints on GDB? GDB Stops

吃可爱长大的小学妹 提交于 2020-02-16 10:27:20
问题 I tried to set a break-point on GDB when a function strcpy() is called, but GDB stops, and i don't know how to find the error, im new to GDB and i want to study binary exploitation, so the forum i'm reading does not explain nothing about this, here is the output; (gdb) disassemble main Dump of assembler code for function main: 0x00000000000011c9 <+0>: endbr64 0x00000000000011cd <+4>: push rbp 0x00000000000011ce <+5>: mov rbp,rsp 0x00000000000011d1 <+8>: sub rsp,0x50 0x00000000000011d5 <+12>:

Compiler changes printf to puts

对着背影说爱祢 提交于 2020-02-15 10:00:30
问题 Consider the following code: #include <stdio.h> void foo() { printf("Hello world\n"); } void bar() { printf("Hello world"); } The assembly produced by both these two functions is: .LC0: .string "Hello world" foo(): mov edi, OFFSET FLAT:.LC0 jmp puts bar(): mov edi, OFFSET FLAT:.LC0 xor eax, eax jmp printf Now I know the difference between puts and printf, but I find this quite interesting that gcc is able to introspect the const char* and figure out whether to call printf or puts. Another

gdb behaves differently for symbols in the .bss, vs. symbols in .data

流过昼夜 提交于 2020-02-15 08:34:27
问题 I recently started learning assembly language for the Intel x86-64 architecture using YASM. While solving one of the tasks suggested in a book (by Ray Seyfarth) I came to following problem: When I place some characters into a buffer in the .bss section, I still see an empty string while debugging it in gdb. Placing characters into a buffer in the .data section shows up as expected in gdb. segment .bss result resb 75 buf resw 100 usage resq 1 segment .data str_test db 0, 0, 0, 0 segment .text

gdb behaves differently for symbols in the .bss, vs. symbols in .data

杀马特。学长 韩版系。学妹 提交于 2020-02-15 08:33:31
问题 I recently started learning assembly language for the Intel x86-64 architecture using YASM. While solving one of the tasks suggested in a book (by Ray Seyfarth) I came to following problem: When I place some characters into a buffer in the .bss section, I still see an empty string while debugging it in gdb. Placing characters into a buffer in the .data section shows up as expected in gdb. segment .bss result resb 75 buf resw 100 usage resq 1 segment .data str_test db 0, 0, 0, 0 segment .text

manipulating c variable via inline assembly [duplicate]

自作多情 提交于 2020-02-14 06:51:32
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: How to access c variable for inline assembly manipulation Given this code: #include <stdio.h> int main(int argc, char **argv) { int x = 1; printf("Hello x = %d\n", x); } I'd like to access and manipulate the variable x in inline assembly. Ideally, I want to change its value using inline assembly. GNU assembler, and using the AT&T syntax. Suppose I want to change the value of x to 11, right after the printf

Why does an assembly program only work when linked with crt1.o crti.o and crtn.o?

隐身守侯 提交于 2020-02-13 04:57:56
问题 I like to know how programs work so to make it as bare bones as possible I fool around with assembly. I just found out how to assemble code for x86_64 using wprintf function (found out wide chars are 32 bit). all I had to do was link to libc (-lc). I'm trying to assemble code for 32-bit doing about the same thing but I stumbled quite a bit. Eventually I used gcc to do the linking ( and changed the _start: to main:). So then I did the linking myself using ld and included crt1.o crti.o and crtn

x86 Assembly: Before Making a System Call on Linux Should You Save All Registers?

不问归期 提交于 2020-02-10 09:00:42
问题 I have the below code that opens up a file, reads it into a buffer and then closes the file. The close file system call requires that the file descriptor number be in the ebx register. The ebx register gets the file descriptor number before the read system call is made. My question is should I save the ebx register on the stack or somewhere before I make the read system call, (could int 80h trash the ebx register?). And then restore the ebx register for the close system call? Or is the code I