x86

Interrupting instruction in the middle of execution

六眼飞鱼酱① 提交于 2020-12-23 09:52:27
问题 Suppose that CPU is running an assembly instruction, say, FOO that will be executed in several clocks (e.g. 10) An interrupt request has come just in the middle of executing FOO and processor needs to interrupt. Does it wait until command is properly executed, or is FOO aborted and will be restarted? Does it behave differently considering different types of interrupts' prioritization? 回答1: The CPU has the option of deciding to do either one, i.e. deciding when the interrupt was handled

Interrupting instruction in the middle of execution

て烟熏妆下的殇ゞ 提交于 2020-12-23 09:52:17
问题 Suppose that CPU is running an assembly instruction, say, FOO that will be executed in several clocks (e.g. 10) An interrupt request has come just in the middle of executing FOO and processor needs to interrupt. Does it wait until command is properly executed, or is FOO aborted and will be restarted? Does it behave differently considering different types of interrupts' prioritization? 回答1: The CPU has the option of deciding to do either one, i.e. deciding when the interrupt was handled

How should I approach to find number of pipeline stages in my Laptop's CPU

浪尽此生 提交于 2020-12-23 08:20:25
问题 I want to look into how latest processors differs from standard RISC V implementation (RISC V having 5 stage pipeline - fetch, decode, memory , ALU , Write back) but not able to find how should I start approaching the problem so as to find the current implementation of pipelining at processor I tried referring Intel documentation for i7-4510U documentation but it was not much help 回答1: Haswell's pipeline length is reportedly 14 stages (on a uop-cache hit), 19 stages when fetching from L1i for

Fastest way to horizontally sum SSE unsigned byte vector

牧云@^-^@ 提交于 2020-12-23 02:33:19
问题 I need to horizontally add a __m128i that is 16 x epi8 values. The XOP instructions would make this trivial, but I don't have those available. Current method is: hd = _mm_hadd_epi16(_mm_cvtepi8_epi16(sum), _mm_cvtepi8_epi16(_mm_shuffle_epi8(sum, swap))); hd = _mm_hadd_epi16(hd, hd); hd = _mm_hadd_epi16(hd, hd); Is there a better way with up to SSE4.1? 回答1: You can do it with SSE2's _mm_sad_epu8 (psadbw), e.g.: inline uint32_t _mm_sum_epu8(const __m128i v) { __m128i vsum = _mm_sad_epu8(v, _mm

how to show the index of element found in tasm program

£可爱£侵袭症+ 提交于 2020-12-13 20:59:27
问题 how can i display index number of the element which i have found? i have found out the maximum element from the array and now I want to print the index of the element which I have found how to proceed? i want to find the element of the largest number which i found in the array according to the below logic ? Data Segment msg db 0dh,0ah,"Please enter the length of the array: $" msg1 db 0dh,0ah,"Enter a number: $" newl db 0dh,0ah," $" res db 0dh,0ah,"The maximum is: $" len db ? max db ? Data

how to show the index of element found in tasm program

空扰寡人 提交于 2020-12-13 20:58:28
问题 how can i display index number of the element which i have found? i have found out the maximum element from the array and now I want to print the index of the element which I have found how to proceed? i want to find the element of the largest number which i found in the array according to the below logic ? Data Segment msg db 0dh,0ah,"Please enter the length of the array: $" msg1 db 0dh,0ah,"Enter a number: $" newl db 0dh,0ah," $" res db 0dh,0ah,"The maximum is: $" len db ? max db ? Data

How to get the size of a function in bytes in GNU assembler with Intel syntax?

狂风中的少年 提交于 2020-12-13 04:10:16
问题 I need to compute the size of a function in bytes at assembly time. I've tried various ways, including: .set chk0_sz, offset chk0_e - offset chk0_s and then using mov rcx, offset chk0_sz to get the value. However, it gives the error: error: cannot use more than one symbol in memory operand . Here chk0_e and chk0_s are two labels denoting the end and start of the function, respectively. Any ideas? 回答1: You only need the offset keyword when using an address as an immediate. In other contexts,

How to get the size of a function in bytes in GNU assembler with Intel syntax?

╄→尐↘猪︶ㄣ 提交于 2020-12-13 04:05:11
问题 I need to compute the size of a function in bytes at assembly time. I've tried various ways, including: .set chk0_sz, offset chk0_e - offset chk0_s and then using mov rcx, offset chk0_sz to get the value. However, it gives the error: error: cannot use more than one symbol in memory operand . Here chk0_e and chk0_s are two labels denoting the end and start of the function, respectively. Any ideas? 回答1: You only need the offset keyword when using an address as an immediate. In other contexts,

Calculating LCM in assembly x86

。_饼干妹妹 提交于 2020-12-12 05:35:11
问题 I have the following assembly code .global _start .section .text _start: movq a, %rax movq b, %rbx imul %rbx, %rax cmp %rbx, %rax je gcd_calculated ja l1 sub %rax, %rbx jmp _start l1: sub %rbx, %rax jmp _start gcd_calculated: div %rax movq %rax, (c) a,b are quads that I need to calculate their lcm and I need to assign the result to c I get wrong results with the above code and I can't spot why. generally, i'm relaying on the the lcm = (a*b)/gcd so I store a*b in %rax and then calculate the

Reading more sectors than there are on a track with int 13h

偶尔善良 提交于 2020-12-11 08:55:16
问题 What is the order int 13h with ah=02h will read 19 sectors starting at (C, H, S) = (0, 0, 1) provided a (floppy) disk geometry of 2 heads, 18 sectors per track and 80 tracks per side. Or, more generally, what happens when it reaches the end of track 0, head 0? Does it go to track 1 or head 1? Does it even work properly in this case? EDIT: Wait.. is this actually like hours, minutes, seconds? If we reach the end of the track (S is greater than 18), then H is increased? 回答1: Modern BIOSes