assembly

BIOS int 0x13 modifies CS:IP?

陌路散爱 提交于 2021-02-10 15:46:55
问题 I'm writing an x86 bootloader which occupies two sections (1024 bytes) on disk and the first thing I want it to do is to load both sections to segment 0x60 before continuing execution Here is the relocation part of my code: _start: // relocate and load remaining bootloader code mov $0x60, %ax mov %ax, %es mov $0x02, %ah mov $2, %al xor %bx, %bx mov $0, %ch mov $2, %cl xor %dh, %dh int $0x13 jmp $0x60, $reloc_done reloc_done: // set up segment registers mov $0x60, %ax mov %ax, %ds mov %ax, %es

Where is the Linear Address Space located?

拈花ヽ惹草 提交于 2021-02-10 15:10:58
问题 I'm reading the intel manual, and I see mentions of "Linear Address Space of the processor". I'm confused as to where or what the linear address space actually is. Where in the processor is the linear address space? The Physical Address Space is the actual RAM as I understand. A logical address is a "segment selector" + "offset", and it must be translated to a physical address. If I understand, if paging is not used, the linear address space is effectively the same as a physical address in

Where is the Linear Address Space located?

孤人 提交于 2021-02-10 15:05:59
问题 I'm reading the intel manual, and I see mentions of "Linear Address Space of the processor". I'm confused as to where or what the linear address space actually is. Where in the processor is the linear address space? The Physical Address Space is the actual RAM as I understand. A logical address is a "segment selector" + "offset", and it must be translated to a physical address. If I understand, if paging is not used, the linear address space is effectively the same as a physical address in

Assembly MIPS %call16(printf)

巧了我就是萌 提交于 2021-02-10 14:57:56
问题 I have this code in Assembly. .data tabela: .word 4, 2, 10, 1, 6 print: .asciiz "The value is: %d\n" .text .globl programa programa: ######################## Do some stuff here. Value on $10 is -99 ######################## la $4,print move $5,$10 lw $25,%call16(printf)($28) jalr $25 This code will print: The value is: -99 I understand that: la $4,print Loads the address of the string to print on the first parameter of function call ($a0) move $5,$10 moves the value on register 10 (in this

Assembly MIPS %call16(printf)

て烟熏妆下的殇ゞ 提交于 2021-02-10 14:55:14
问题 I have this code in Assembly. .data tabela: .word 4, 2, 10, 1, 6 print: .asciiz "The value is: %d\n" .text .globl programa programa: ######################## Do some stuff here. Value on $10 is -99 ######################## la $4,print move $5,$10 lw $25,%call16(printf)($28) jalr $25 This code will print: The value is: -99 I understand that: la $4,print Loads the address of the string to print on the first parameter of function call ($a0) move $5,$10 moves the value on register 10 (in this

Assembly clone syscall thread function not called

醉酒当歌 提交于 2021-02-10 14:47:00
问题 Im trying to create a thread using 'clone' syscall ... i searched toooooooo much ! for example, link1 link2 and now this is my source code in assembly for linux x64: FORMAT ELF64 EXECUTABLE ENTRY thread_linux_x64 THREAD_MEM_SIZE = 1024 define PROT_READ 0x1 define PROT_WRITE 0x2 define PROT_EXEC 0x4 define MAP_PRIVATE 0x02 define MAP_ANONYMOUS 0x20 define CLONE_VM 0x00000100 define CLONE_FS 0x00000200 define CLONE_FILES 0x00000400 define CLONE_SIGHAND 0x00000800 define CLONE_PARENT 0x00008000

Add two 32-bit numbers using 8-bit registers

匆匆过客 提交于 2021-02-10 14:39:48
问题 The goal here is two add two 32-bit numbers stored in little-endian notation. The numbers are stored in the following memory cells: first number: 0x3000-0x3003 seconds number: 0x4000-0x4003 the result should go into: 0x5000-0x5003 The following is my implementation, that is not very efficient in terms of DRY principle: ARG1 EQU 3000H ARG2 EQU 4000H RESULT EQU 5000H ORG 0000H MOV DPTR, #ARG1 + 0 MOV A, #12H MOVX @DPTR, A MOV DPTR, #ARG1 + 1 MOV A, #34H MOVX @DPTR, A MOV DPTR, #ARG1 + 2 MOV A,

Squared Brackets in x86 asm from IDA

孤者浪人 提交于 2021-02-10 13:39:47
问题 I used IDA Starter to dissassemble a Windows program, and there is something I don't understand in the resulting assembler code: mov eax, dword_4033CC[eax*4] My question is, what the purpose of the squared brackets is. I found this other question, that is also about squared brackets, but I believe that this is a different context. 来源: https://stackoverflow.com/questions/49176047/squared-brackets-in-x86-asm-from-ida

Printf arguments not pushed on the stack

蹲街弑〆低调 提交于 2021-02-10 13:15:26
问题 I'm in the process of trying to understand the stack mechanisms. From the theory I have seen, before a function is called, its arguments are pushed onto the stack. However when calling printf in the code below, none of them are pushed: #include<stdio.h> int main(){ char *s = " test string"; printf("Print this: %s and this %s \n", s, s); return 1; } I've put a break in gdb to the printf instruction, and when displaying the stack, none of the 3 arguments are pushed onto the stack. The only

Printf arguments not pushed on the stack

筅森魡賤 提交于 2021-02-10 13:11:26
问题 I'm in the process of trying to understand the stack mechanisms. From the theory I have seen, before a function is called, its arguments are pushed onto the stack. However when calling printf in the code below, none of them are pushed: #include<stdio.h> int main(){ char *s = " test string"; printf("Print this: %s and this %s \n", s, s); return 1; } I've put a break in gdb to the printf instruction, and when displaying the stack, none of the 3 arguments are pushed onto the stack. The only