x86-16

Incorrect value of the variable ans that stores the LCM of two numbers (8086 Program)

社会主义新天地 提交于 2021-01-05 12:47:21
问题 Following is the code I wrote to find LCM of two numbers in EMU8086. When I ran it, I am getting value 0 in the Ans variable. .MODEL SMALL .DATA Num1 DW 250 Num2 DW 100 Ans DW ? .CODE MOV AX,@DATA MOV DS, AX MOV AX, Num1 MOV BX, Num2 MOV DX, 0000h NEXT: PUSH AX PUSH DX DIV BX CMP DX, 0000h JZ LAST POP DX POP AX ADD AX, Num1 JNC NEXT INC DX JMP NEXT LAST: POP Ans+2 POP Ans MOV AH, 4Ch INT 21h END 回答1: LCM(a, b) = a * b / GCD(a, b) Due to this equation, you can find GCD using Euclid's algorithm

Incorrect value of the variable ans that stores the LCM of two numbers (8086 Program)

柔情痞子 提交于 2021-01-05 12:45:03
问题 Following is the code I wrote to find LCM of two numbers in EMU8086. When I ran it, I am getting value 0 in the Ans variable. .MODEL SMALL .DATA Num1 DW 250 Num2 DW 100 Ans DW ? .CODE MOV AX,@DATA MOV DS, AX MOV AX, Num1 MOV BX, Num2 MOV DX, 0000h NEXT: PUSH AX PUSH DX DIV BX CMP DX, 0000h JZ LAST POP DX POP AX ADD AX, Num1 JNC NEXT INC DX JMP NEXT LAST: POP Ans+2 POP Ans MOV AH, 4Ch INT 21h END 回答1: LCM(a, b) = a * b / GCD(a, b) Due to this equation, you can find GCD using Euclid's algorithm

EMU8086 dividing 32 bit number by a 16 bit number gives unexpected 0 remainder

天大地大妈咪最大 提交于 2021-01-03 07:07:52
问题 I was trying to divide (Unsigned) 8A32F4D5 by C9A5 using emu8086 tool. I expected the quotient to be AF73H and the remainder be 94B6H . After writing the following code, I was getting correct quotient but the remainder became 0000h . Am I missing something? .MODEL SMALL .STACK 100H .DATA .CODE MAIN PROC ; initialize DS MOV AX,@DATA MOV DS,AX ; enter your code here MOV DX, 8A32H MOV AX, 0F4D5H MOV BX, 0C9A5H DIV BX ;exit to DOS MOV AX,4C00H INT 21H MAIN ENDP END MAIN The output in EMU8086: 回答1

EMU8086 dividing 32 bit number by a 16 bit number gives unexpected 0 remainder

蓝咒 提交于 2021-01-03 07:04:46
问题 I was trying to divide (Unsigned) 8A32F4D5 by C9A5 using emu8086 tool. I expected the quotient to be AF73H and the remainder be 94B6H . After writing the following code, I was getting correct quotient but the remainder became 0000h . Am I missing something? .MODEL SMALL .STACK 100H .DATA .CODE MAIN PROC ; initialize DS MOV AX,@DATA MOV DS,AX ; enter your code here MOV DX, 8A32H MOV AX, 0F4D5H MOV BX, 0C9A5H DIV BX ;exit to DOS MOV AX,4C00H INT 21H MAIN ENDP END MAIN The output in EMU8086: 回答1

EMU8086 dividing 32 bit number by a 16 bit number gives unexpected 0 remainder

不羁岁月 提交于 2021-01-03 07:04:33
问题 I was trying to divide (Unsigned) 8A32F4D5 by C9A5 using emu8086 tool. I expected the quotient to be AF73H and the remainder be 94B6H . After writing the following code, I was getting correct quotient but the remainder became 0000h . Am I missing something? .MODEL SMALL .STACK 100H .DATA .CODE MAIN PROC ; initialize DS MOV AX,@DATA MOV DS,AX ; enter your code here MOV DX, 8A32H MOV AX, 0F4D5H MOV BX, 0C9A5H DIV BX ;exit to DOS MOV AX,4C00H INT 21H MAIN ENDP END MAIN The output in EMU8086: 回答1

Program solving expression in assembly

丶灬走出姿态 提交于 2020-12-31 04:43:51
问题 I have a problem with my simple program in assembly. I'm using DOSBox and TASM. The problem is that the operand types don't match in lines 76, 78, and 80. This is after multiplication. I tried to make some changes by using a different variable size. ; -------------------------------------------- ; Equation=(a+c*b)/d-2*c, ; -------------------------------------------- .model small .stack 100h .data a db 0 b db 0 c db 0 d db 0 result1 db ? result2 db ? message1 db "Equation: (a+c*b)/d-2*c a=$"

Program solving expression in assembly

别说谁变了你拦得住时间么 提交于 2020-12-31 04:43:29
问题 I have a problem with my simple program in assembly. I'm using DOSBox and TASM. The problem is that the operand types don't match in lines 76, 78, and 80. This is after multiplication. I tried to make some changes by using a different variable size. ; -------------------------------------------- ; Equation=(a+c*b)/d-2*c, ; -------------------------------------------- .model small .stack 100h .data a db 0 b db 0 c db 0 d db 0 result1 db ? result2 db ? message1 db "Equation: (a+c*b)/d-2*c a=$"

manipulating 32 bit numbers with 16 bit registers in 8086

五迷三道 提交于 2020-12-25 04:00:57
问题 Im trying to write a program which get two 6-digit decimal numbers and show the addition of them, but in 16 bit 8086 i defined numbers as double word and put LO in WORD 1 and HO in word 2. similar to below code but i dont have any idea to do next, can any body suggest me algorithm for next operations? Thnx x dd(?) next_no: mov cl,2 mov ch,4 two_bit: getch sub al,30h mov bl,10 mul bl mov di,ax add word ptr x+2,di dec cl jnz two_bit fourbit: getch sub al,30h mov bl,10 mul bl mov di,ax add word

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

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

China☆狼群 提交于 2020-12-11 08:54:03
问题 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