x86

Assembly code do not recognise ? and @data

别来无恙 提交于 2021-01-28 08:04:28
问题 It is my first assembly program. Can anyone please help to make it run successfully. I am seeing below compilation error. Why it do not recognize the ? and @data ? I am trying to swap two variables in assembly. I am executing the following command nasm -f elf swap.asm But I get this error: swap.asm:6: error: symbol `?' undefined swap.asm:12: error: symbol `@data' undefined swap.asm:15: error: invalid combination of opcode and operands swap.asm:21: error: invalid combination of opcode and

x86 Assembly - printf doesn't print without “\n”

好久不见. 提交于 2021-01-28 07:31:08
问题 So I'm confused. I'm going through the book "Programming from the Ground Up" and am working with using libraries. printf is working just fine so long as I include a "\n" in the string, but without it it will print absolutely nothing. Any idea why this happens? Code: .section .data my_str: .ascii "Jimmy Joe is %d years old!\n\0" my_num: .long 76 .section .text .globl _start _start: pushl my_num pushl $my_str call printf movl $1, %eax movl $0, %ebx int $0x80 Also, when I use -m elf_i386 for 32

The difference between signed and unsigned, what means a negative byte?

二次信任 提交于 2021-01-28 07:02:41
问题 I need to solve the problem below, but I don't understand the concepts needed for solution. Let's consider the following string of doublewords: B234* A68C *h, * 52B4 *78C8h, * 1AB3 *C470h, F9DC* 98B6 *h. It is required to: 1) print on the screen the words ' ranks that have the minimum value from each doubleword (considering them unsigned ) The answer is '2112' (the bold words have the minimum value) 2) print on the screen the sum of the bytes that have the maximum value from these words

x86 Assembly Input a set of Integers

非 Y 不嫁゛ 提交于 2021-01-28 06:31:27
问题 The code below asks a user to input integers and the code will spit the same set of integers back to the user. include irvine32.inc .data input dword ? prompt1 byte "Input your numbers: ",0 .code mWriteNum Macro input push ecx push eax mov eax, offset input call writedec pop eax push ecx endM mReadInput MACRO input push ecx push eax mov eax, offset input mov ecx, sizeof input call Readint mov input, eax pop eax pop ecx endM main proc call clrscr mov edx, offset prompt1 call writeString

x86 Assembly two jump instructions with the same target

拜拜、爱过 提交于 2021-01-28 04:00:29
问题 I try to understand an example form the book "Practical Malware Analysis" by Michael Sikorski. There is an example on anti disassembly techniques that i don't comprehend. It says that a common technique is to create two conditional instructions namely jump if zero (JZ) and jump if not zero (JNZ) which considered together are actually just one unconditional instruction (this is clear to me). Here are the graphics of the two possible results created by the disassembler. The following quote

What is the value of segment registers in 8086?

时光毁灭记忆、已成空白 提交于 2021-01-28 03:09:14
问题 I have just started to read about intel 8086 and have a question concerning its memory. I read that the address bus is 20-bit wide, which means the address space is 1MB, and this space is divided into segments. the question is: the four segment registers, CS , DS , SS and ES , are they read only or I can set their values, and which are their default values? I saw the following assembly tutorial: ORG 100h MOV AX, 0B800h ; set AX = B800h (VGA memory). MOV DS, AX ; copy value of AX to DS. MOV CL

Can't size instruction

这一生的挚爱 提交于 2021-01-28 02:20:50
问题 I was wondering why some assembly instructions can be inferred, but others cannot. For example, in the following program I have: .globl main main: push %rbp mov %rsp, %rbp mov $8, -8(%rbp) mov -8(%rbp), %rax pop %rbp ret I get the following error: stack.s:5: Error: no instruction mnemonic suffix given and no register operands; can't size instruction However, if I change: the 5th line to: movq $8, -8(%rbp) It runs without error. How can all the other operations infer the size, but that

Is there a pattern to x86 op codes? (other than direction and size bits)

我是研究僧i 提交于 2021-01-27 22:14:20
问题 The op code portion of many important x86 instructions like MOV and ADD has the last two bits standardized as a direction bit and a data size bit: Is there any pattern to the part of the op code shown in gray here? For example, for ADD some of the instructions use the code 000000 and others have code 100000. 来源: https://stackoverflow.com/questions/41720529/is-there-a-pattern-to-x86-op-codes-other-than-direction-and-size-bits

What does the “fh” suffix mean on a number like “38fh” in Intel assembly

最后都变了- 提交于 2021-01-27 21:24:59
问题 I've searched all over the web, but I couldn't find what the "fh" means in the following instruction and eax, 38fh . I know that "h" stands for hexadecimal and "d" for decimal, but I've never seen fh before. 回答1: If an Intel assembler (ie. MASM ) token starts with a number (0 to 9) then it is assumed to be that the entire token is a value. If the value ends with an h the assembler assumes it is H exadecimal. In your case 38fh starts with a number so it is assumed to be a value. The end of the

add 1 byte immediate value to a 2 bytes memory location

好久不见. 提交于 2021-01-27 21:00:36
问题 The add instruction documentation from this page says the following: Notice the two instructions that I highlighted. I tried the following code in NASM (which conforms with the first highlighted instruction): add WORD [myvar], BYTE 0xA5 But I got the following error: warning: signed byte value exceeds bounds What am I doing wrong? 回答1: The 8-bit immediate operand (denoted here by imm8 ) is sign-extended into 16 (or 32) bits to match the size of the other operand ( r/m16 or r/m32 ,