assembly

Chosing suffix (l-b-w) for mov instruction

痞子三分冷 提交于 2021-02-18 23:03:23
问题 I am new to assembly.I am reading computers system programmer's perspective. I don't understand how I choose suffix for mov instruction. I know each register and bit count. Suffix usage is determined by bit count (32 bit l , 16 bit w , 8 bit b ). Few example is not valid for prior sentence. For example %esp is 32-bit register but for 4. step suffix b is used instead of l . Please give an explanation for using suffix. questions : answer : l-w-b-b-l-w-l Source: Computer Systems: A Programmer's

Chosing suffix (l-b-w) for mov instruction

帅比萌擦擦* 提交于 2021-02-18 23:01:08
问题 I am new to assembly.I am reading computers system programmer's perspective. I don't understand how I choose suffix for mov instruction. I know each register and bit count. Suffix usage is determined by bit count (32 bit l , 16 bit w , 8 bit b ). Few example is not valid for prior sentence. For example %esp is 32-bit register but for 4. step suffix b is used instead of l . Please give an explanation for using suffix. questions : answer : l-w-b-b-l-w-l Source: Computer Systems: A Programmer's

Avoiding page faults in IDT hooking

故事扮演 提交于 2021-02-18 22:12:37
问题 Note: I'm running on FreeBSD, but I've also included Linux as a tag since the problem is somewhat general and Linux-specific solutions are of interest to me. Edit : just to confirm that the issue was not FreeBSD specific, I ported the module to Linux, and indeed got the exact same behavior. The code for the Linux version of the module is given below; it is essentially exactly the same, the only major difference being that the IDT is evidently given read-only protection in Linux, and so I had

When do we create base pointer in a function - before or after local variables?

给你一囗甜甜゛ 提交于 2021-02-18 19:03:16
问题 I am reading the Programming From Ground Up book. I see two different examples of how the base pointer %ebp is created from the current stack position %esp . In one case, it is done before the local variables. _start: # INITIALIZE PROGRAM subl $ST_SIZE_RESERVE, %esp # Allocate space for pointers on the # stack (file descriptors in this # case) movl %esp, %ebp The _start however is not like other functions, it is the entry point of the program. In another case it is done after. power: pushl

When do we create base pointer in a function - before or after local variables?

扶醉桌前 提交于 2021-02-18 19:00:53
问题 I am reading the Programming From Ground Up book. I see two different examples of how the base pointer %ebp is created from the current stack position %esp . In one case, it is done before the local variables. _start: # INITIALIZE PROGRAM subl $ST_SIZE_RESERVE, %esp # Allocate space for pointers on the # stack (file descriptors in this # case) movl %esp, %ebp The _start however is not like other functions, it is the entry point of the program. In another case it is done after. power: pushl

When do we create base pointer in a function - before or after local variables?

守給你的承諾、 提交于 2021-02-18 19:00:17
问题 I am reading the Programming From Ground Up book. I see two different examples of how the base pointer %ebp is created from the current stack position %esp . In one case, it is done before the local variables. _start: # INITIALIZE PROGRAM subl $ST_SIZE_RESERVE, %esp # Allocate space for pointers on the # stack (file descriptors in this # case) movl %esp, %ebp The _start however is not like other functions, it is the entry point of the program. In another case it is done after. power: pushl

Error when trying to run .asm file on NASM on Ubuntu

喜你入骨 提交于 2021-02-17 08:26:10
问题 I'm using ubuntu 64-bit and trying to run a .asm file on NASM. But it returns this error when I try to run the following code. What Iḿ trying to do is build an executable by compiling (or assembling) object file from the source $ nasm -f elf hello.asm , and then after created the file hello.o is producing executable file itself from the object file by invoking linker $ ld -s -o hello hello.o This will finally build hello executable. I'm following this tutorial http://www.faqs.org/docs/Linux

Assembly 8086. Read from the standard input several numbers, in base 2. Print on the screen these numbers in base 10

风流意气都作罢 提交于 2021-02-17 07:19:08
问题 So, i have to convert the numbers from base two in base 10, and i have no idea how to do it.This is how my program looks for now, but I am not sure if what I got until now works properly. The conversion part is really giving me a hard time, but for sure I have lots of mistakes in my code, so any help would be greatly appreciated. assume cs:code, ds:data data segment msg db 'Give numbers:$' numbers LABEL BYTE max_size DB 100 numbers_len DB ? number DB 100 dup (?) ten db 10 errm db 'Numbers not

C array indexing in MIPS assembly?

為{幸葍}努か 提交于 2021-02-17 07:19:06
问题 Question: void swap (int v[], int k) { int temp; temp = v[k]; v[k] = v[k+1]; v[k+1] = temp; } My question is why does int v[] get added $t1 ? (whoever did this didn't even comment it so I'm assuming $a0 is v[] and $a1 is k ). Answer in mips: swap: sll $t1, $a1, 2 add $t1, $a0, $t1 lw $t0, 0($t1) lw $t2, 4($t1) sw $t2, 0($t1) sw $t0, 4($t1) jr $ra I know this is used to swap variables but what is it doing here, why is it adding v[] with k ? Isn't v[] a array of declared variables, how can you

Inline assembly multiplication “undefined reference” on inputs

风流意气都作罢 提交于 2021-02-17 07:15:08
问题 Trying to multiply 400 by 2 with inline assembly, using the fact imul implicity multiplies by eax . However, i'm getting "undefined reference" compile errors to $1 and $2 int c; int a = 400; int b = 2; __asm__( ".intel_syntax;" "mov eax, $1;" "mov ebx, $2;" "imul %0, ebx;" ".att_syntax;" : "=r"(c) : "r" (a), "r" (b) : "eax"); std::cout << c << std::endl; 回答1: Do not use fixed registers in inline asm, especially if you have not listed them as clobbers and have not made sure inputs or outputs