MASM

Assembly Language (x86): How to create a loop to calculate Fibonacci sequence

十年热恋 提交于 2019-11-26 16:47:53
I am programming assembly language (x86) in MASM using Visual Studio 2013 Ultimate. I am trying to use an array to calculate a Fibonacci sequence for n elements using an array. In other words, I am trying to go to an array element, obtain the two elements before it, add those up, and store the result in another array. I am having trouble setting up the index registers to make this work. I have my program setup like this: TITLE fibonacci.asm INCLUDE Irvine32.inc .data fibInitial BYTE 0, 1, 2, 3, 4, 5, 6 fibComputed BYTE 5 DUP(0) .code main PROC MOVZX si, fibInitial MOVZX di, fibComputed MOV cl,

Call C standard library function from asm in Visual Studio

寵の児 提交于 2019-11-26 15:30:19
I have a problem with calling C function from asm project created in visual studio (Win10 x64, Visual Studio 2015). Project consist of one asm file: .586 .model flat, stdcall option casemap:none includelib msvcrt.lib ExitProcess PROTO return:DWORD extern printf:near .data text BYTE "Text", 0 .code main PROC push offset text call printf add esp,4 invoke ExitProcess,0 main ENDP end main When I build project, linker outputs the error: Error LNK2019 unresolved external symbol _printf referenced in function _main@0 Linker output parameters: /OUT:"C:\Users\apple\Documents\SP_Lab7\Debug\SP_Lab7_Demo

How to print colored string in assembly language?

随声附和 提交于 2019-11-26 14:48:20
问题 Jan db " January$ " string db "Sun Mon Tue Wed Thu Fri Sat$" string1 db " 1 2 3$" string2 db " 4 5 6 7 8 9 10$" string3 db "11 12 13 14 15 16 17$" string4 db "18 19 20 21 22 23 24$" string5 db "25 26 27 28 29 30 31$" 回答1: There are several ways to achieve your goal IN TEXT MODE : Display char by char : this way you can choose one color for every character. Access screen memory : at segment 0B800:0. Display the whole string with the same color. Next code does the job with the third option (the

Printing Hexadecimal Digits with Assembly

我的梦境 提交于 2019-11-26 08:34:35
问题 I\'m trying to learn NASM assembly, but I seem to be struggling with what seems to simply in high level languages. All of the textbooks which I am using discuss using strings -- in fact, that seems to be one of their favorite things. Printing hello world, changing from uppercase to lowercase, etc. However, I\'m trying to understand how to increment and print hexadecimal digits in NASM assembly and don\'t know how to proceed. For instance, if I want to print #1 - n in Hex, how would I do so

Assembly Language (x86): How to create a loop to calculate Fibonacci sequence

让人想犯罪 __ 提交于 2019-11-26 06:03:45
问题 I am programming assembly language (x86) in MASM using Visual Studio 2013 Ultimate. I am trying to use an array to calculate a Fibonacci sequence for n elements using an array. In other words, I am trying to go to an array element, obtain the two elements before it, add those up, and store the result in another array. I am having trouble setting up the index registers to make this work. I have my program setup like this: TITLE fibonacci.asm INCLUDE Irvine32.inc .data fibInitial BYTE 0, 1, 2,

Confusing brackets in MASM32

微笑、不失礼 提交于 2019-11-26 03:59:28
问题 I am trying to get to grips with MASM32 and am confused by the following: I thought that brackets were used for indirection so if I have the a pre-defined variable .data item dd 42 then mov ebx, item would put the contents of \'item\', i.e. the number 42, into ebx and mov ebx, [item] would put the address of \'item\', i.e. where the 42 is stored, into ebx. But the following code in a console app: mov ebx, item invoke dwtoa, ebx, ADDR valuestr invoke StdOut, ADDR valuestr mov ebx, [item]

Referencing the contents of a memory location. (x86 addressing modes)

谁说胖子不能爱 提交于 2019-11-25 23:57:35
问题 I have a memory location that contains a character that I want to compare with another character (and it\'s not at the top of the stack so I can\'t just pop it). How do I reference the contents of a memory location so I can compare it? Basically how do I do it syntactically. 回答1: For a more extended discussion of addressing modes (16/32/64bit), see Agner Fog's "Optimizing Assembly" guide, section 3.3. That guide has much more detail than this answer for relocation for symbols and or 32bit