assembly

Is the i386 instruction “div ah” pointless?

偶尔善良 提交于 2021-01-18 11:02:44
问题 From https://www.felixcloutier.com/x86/div: ... temp ← AX / SRC; IF temp > FFH THEN #DE; (* Divide error *) ELSE AL ← temp; AH ← AX MOD SRC; FI; ... For div ah the SRC would be ah . IMHO temp will always be larger than FFH and therefore the exception will be raised since: AX = 256*AH+AL temp = AX / AH = (256*AH+AL)/AH = 256 + AL/AH temp is over FFH Do I miss something here? 回答1: That's correct, just like div edx it's never usable without faulting. The criterion for 2N/N => N-bit div not

MIPS assembly: how to declare integer values in the .data section?

旧街凉风 提交于 2021-01-17 08:20:05
问题 I'm trying to get my feet wet with MIPS assembly language using the MARS simulator. My main problem now is how do I initialize a set of memory locations so that I can access them later via assembly language instructions? For example, I want to initialize addresses 0x1001000 - 0x10001003 with the values 0x99, 0x87, 0x23, 0x45. I think this can be done in the data declaration (.data) section of my assembly program but I'm not sure of the syntax. Is this possible? Alternatively, in the .data

MIPS assembly: how to declare integer values in the .data section?

折月煮酒 提交于 2021-01-17 08:09:23
问题 I'm trying to get my feet wet with MIPS assembly language using the MARS simulator. My main problem now is how do I initialize a set of memory locations so that I can access them later via assembly language instructions? For example, I want to initialize addresses 0x1001000 - 0x10001003 with the values 0x99, 0x87, 0x23, 0x45. I think this can be done in the data declaration (.data) section of my assembly program but I'm not sure of the syntax. Is this possible? Alternatively, in the .data

MIPS assembly: how to declare integer values in the .data section?

倾然丶 夕夏残阳落幕 提交于 2021-01-17 08:06:09
问题 I'm trying to get my feet wet with MIPS assembly language using the MARS simulator. My main problem now is how do I initialize a set of memory locations so that I can access them later via assembly language instructions? For example, I want to initialize addresses 0x1001000 - 0x10001003 with the values 0x99, 0x87, 0x23, 0x45. I think this can be done in the data declaration (.data) section of my assembly program but I'm not sure of the syntax. Is this possible? Alternatively, in the .data

MIPS assembly: how to declare integer values in the .data section?

岁酱吖の 提交于 2021-01-17 08:05:49
问题 I'm trying to get my feet wet with MIPS assembly language using the MARS simulator. My main problem now is how do I initialize a set of memory locations so that I can access them later via assembly language instructions? For example, I want to initialize addresses 0x1001000 - 0x10001003 with the values 0x99, 0x87, 0x23, 0x45. I think this can be done in the data declaration (.data) section of my assembly program but I'm not sure of the syntax. Is this possible? Alternatively, in the .data

How to determine the appropriate MOV instruction suffix based on the operands?

社会主义新天地 提交于 2021-01-16 03:52:01
问题 The answer is 1. movl 2. movw 3. movb 4. movb 5. movq 6. movw But how do we determine that? 回答1: Simply look at the destination operand and specify its size. Case 1 : You are moving the value at address specified by register rsp to the register eax. Therefore, you should use movl which means move a long value. This is done because the eax register is 4 bytes wide which make up a long. The same applies to the other cases. movb - move byte. movw - move word (2 bytes). 来源: https://stackoverflow

How to determine the appropriate MOV instruction suffix based on the operands?

一世执手 提交于 2021-01-16 03:51:07
问题 The answer is 1. movl 2. movw 3. movb 4. movb 5. movq 6. movw But how do we determine that? 回答1: Simply look at the destination operand and specify its size. Case 1 : You are moving the value at address specified by register rsp to the register eax. Therefore, you should use movl which means move a long value. This is done because the eax register is 4 bytes wide which make up a long. The same applies to the other cases. movb - move byte. movw - move word (2 bytes). 来源: https://stackoverflow

How can I simulate a CALL instruction by using JMP?

拜拜、爱过 提交于 2021-01-13 11:01:08
问题 Like this but without the CALL instruction. I suppose that I should use JMP and probably other instructions. PUSH 5 PUSH 4 CALL Function 回答1: This is fairly easy to do. Push the return address onto the stack and then jump to the subroutine. The final code looks like this: PUSH 5 PUSH 4 PUSH offset label1 jmp Function label1: ; returns here leas esp, 8[esp] Function: ... ret While this works, you really don't want to do this. On most modern processors, an on-chip call stack return address

Assembly - safe competition

白昼怎懂夜的黑 提交于 2021-01-07 11:30:30
问题 I participate in the competition named 'Code guru - Extreme' In this competition there is safes and keys in assembly 8086. To a safe and a key there are joint data segment, and you need to make a key that break the safe. Example to safe: L: mov ax, [1234] cmp ax, 5678 jne L Example to key that break the safe L: mov ax, 5678 mov [1234], ax jne L And now I have a safe that I can not break it and al, 0FEh push ax clc mul ax xor ax, dx or al, 1 loc_10A: sub [0A2h], ax pop ax push ax jnz loc_10A

Assembly - safe competition

蓝咒 提交于 2021-01-07 11:29:58
问题 I participate in the competition named 'Code guru - Extreme' In this competition there is safes and keys in assembly 8086. To a safe and a key there are joint data segment, and you need to make a key that break the safe. Example to safe: L: mov ax, [1234] cmp ax, 5678 jne L Example to key that break the safe L: mov ax, 5678 mov [1234], ax jne L And now I have a safe that I can not break it and al, 0FEh push ax clc mul ax xor ax, dx or al, 1 loc_10A: sub [0A2h], ax pop ax push ax jnz loc_10A