MASM

Location and Highest value in array

自古美人都是妖i 提交于 2021-02-10 12:18:07
问题 So i am trying learn assembly and my practice sheet has an example where i have to create a program to input 10 numbers one at a time into an array. I have to print the highest value and when it was entered. I have barely any exp in comparing but I want to somehow store the high value and compare it the locations? code: include irvine32.inc .data num dw 10 dup(0) count db 1 prompt db "Enter a number: ",0 yesMsg db "hi val is in location ",0 hiMsg db "The high value is ",0 .code main proc mov

How safe is this swap w/o pushing registers?

这一生的挚爱 提交于 2021-02-08 15:18:30
问题 I'm very new to Assembly and the code below is supposed to swap two integers via two different functions: first using swap_c and then using swap_asm . However, I doubt, whether I need to push (I mean save) each value of registers before assembly code and pop them later (just before returning to main ). In other words, will the CPU get mad at me if I return different register content (not the crucial ones like ebp or esp ; but, just eax , ebx , ecx & edx ) after running swap_asm function? Is

How safe is this swap w/o pushing registers?

走远了吗. 提交于 2021-02-08 15:18:21
问题 I'm very new to Assembly and the code below is supposed to swap two integers via two different functions: first using swap_c and then using swap_asm . However, I doubt, whether I need to push (I mean save) each value of registers before assembly code and pop them later (just before returning to main ). In other words, will the CPU get mad at me if I return different register content (not the crucial ones like ebp or esp ; but, just eax , ebx , ecx & edx ) after running swap_asm function? Is

How safe is this swap w/o pushing registers?

守給你的承諾、 提交于 2021-02-08 15:17:18
问题 I'm very new to Assembly and the code below is supposed to swap two integers via two different functions: first using swap_c and then using swap_asm . However, I doubt, whether I need to push (I mean save) each value of registers before assembly code and pop them later (just before returning to main ). In other words, will the CPU get mad at me if I return different register content (not the crucial ones like ebp or esp ; but, just eax , ebx , ecx & edx ) after running swap_asm function? Is

X86 Fibonacci program

情到浓时终转凉″ 提交于 2021-02-08 12:04:29
问题 My assignment is to write a program that calculates first seven values of fibonacci number sequence. the formula given is: Fib(1) = 1, Fib(2) = 1, Fib(n) = Fib(n-1) + Fib(n-2) I believe that is a function but I do not understand how to incorporate it into code. I need to place the values in EAX register. I am using MASM not that makes any difference. Any hints? 回答1: I suspect that this is an academic assignment so I'm only going to partially answer the question. The fibonacci sequence is

OFFSET Operator in Assembly language for x86 Processors

ⅰ亾dé卋堺 提交于 2021-02-08 09:18:24
问题 I am rather confused by the concept OFFSET Operator. According to Kip R. Irvine's book Assembly Language for x86 Processors, he defines the Offset Operator as the operator that returns the distance of a variable from the beginning of its enclosing segment. He also says the Offset Operator returns the offset of a data label and that represents the distance (in bytes) of the label from the beginning of the data segment. What is the offset? What does he mean by the distance of the label from the

Accessing the Program Segment Prefix

回眸只為那壹抹淺笑 提交于 2021-02-08 07:34:47
问题 I'm trying to access the Program Segment Prefix (PSP) in x86 MASM Assembler. As a test, I'd like to print the given command line arguments after running my program. I tried putting the address of the PSP in the dx register, with an offset of 81h : the position of the command line arguments. However, after running the program, I get this in return. I can see the given command line argument, but it is preceded by a lot of gibberish. Any idea why this is happening? I guess I'm not correctly

multiply two consecutive times in assembly language program

允我心安 提交于 2021-02-05 12:32:50
问题 I am using 8086 emulator and DOSBOX and MASM. I know that when we multiply 8-bit with 8-bit, answer will be of 16-bit. al*(8-bit)=ax And when we multiply 16-bit with 16-bit,answer will of 32-bit. ax*(16-bit)=dx & ax But if the answer is in (dx & ax) and I want to multiply 8-bit or 16-bit number then it will simply perform with ax But I needed to multiply a number with answer in (dx & ax) . So how to overcome this problem? I need solve this situation for the factorial program. Where I am

How to display floating-point rounded to .001 with Irvine32 WriteFloat, not printf

非 Y 不嫁゛ 提交于 2021-02-04 08:30:47
问题 I am very new to assembly language so bear with me... I have a floating-point that I have rounded to the nearest .001, but still displays as something like +1.6670000E+000. I would like it to display simply as 1.667. Here is my code for dividing and rounding the numbers: fild num_a fidiv num_b fimul thousand frndint fidiv thousand fst a_div_b And here is my code for displaying the float: mov eax, num_a call WriteDec mov edx, OFFSET divide call WriteString mov eax, num_b call WriteDec mov edx,

How to display floating-point rounded to .001 with Irvine32 WriteFloat, not printf

不打扰是莪最后的温柔 提交于 2021-02-04 08:30:06
问题 I am very new to assembly language so bear with me... I have a floating-point that I have rounded to the nearest .001, but still displays as something like +1.6670000E+000. I would like it to display simply as 1.667. Here is my code for dividing and rounding the numbers: fild num_a fidiv num_b fimul thousand frndint fidiv thousand fst a_div_b And here is my code for displaying the float: mov eax, num_a call WriteDec mov edx, OFFSET divide call WriteString mov eax, num_b call WriteDec mov edx,