fasm

Printing out registers/ints to console | FASM | WINAPI

喜夏-厌秋 提交于 2019-12-04 13:08:16
Just wondering if there was a way i could print out a number to the console by invoking. it can be either base 10, or hex I don't mind. I would like to see the format in which some functions return. I would prefer not to do it the long way using WriteConsole and a lot of asm P.S also this is my first question , how do i accept an answer use printf from msvcrt.dll: format PE console include "win32ax.inc" start: cinvoke printf,formatstring,eax invoke Sleep,-1 formatstring db "%d",13,10,0 section '.idata' import data readable library msvcrt,'msvcrt.dll',\ kernel32,'kernel32.dll' import msvcrt

Converting 16-bit DOS .com assembly for use on 64-bit

家住魔仙堡 提交于 2019-12-04 05:41:20
问题 I wrote few programs in assembly in flat assembler for 32bit windows xp. But now that I have 64bit windows 8 I can't run the .com files, as they appear to be incompatible with 64bit version (the programs are 32bit). How do I convert it so I can run it in win8 as well? Maybe use a different assembler? I'd like to avoid the need for emulators and virtual machines. 回答1: A .com file is 16-bit. You can use 32-bit instructions and registers, but it's 16-bit code. A 64-bit CPU, once it's put in

Reading from memory in 8086 real mode while using 'ORG 0x0000'

限于喜欢 提交于 2019-12-03 20:33:27
问题 I've been messing around with x86-16 assembly and running it with VirtualBox. For some reason when I read from memory and try to print it as a character, I get completely different results from what I was expecting. However when I hard-code the character as part of the instruction, it works fine. Here's the code: ORG 0 BITS 16 push word 0xB800 ; Address of text screen video memory in real mode for colored monitors push cs pop ds ; ds = cs pop es ; es = 0xB800 jmp start ; input = di (position

ASM: MASM, NASM, FASM?

余生颓废 提交于 2019-12-03 03:12:02
问题 I have done ARM assembly programming and I would like to learn the Intel Assembler. I keep hearing all these different F/M/N/ASMs mentioned- but I am unsure how they related to what I wish to achieve? Could somebody please help me identify what I would need to learn how to program low level on the Intel architecture? I dont quite understand how the "different Assemblers" correlate, even more so with x86, IA64, AMD64/x86-64 etc? If it is of any help, I am most comfortable with Eclipse and

How to use large numbers?

为君一笑 提交于 2019-12-02 21:15:46
问题 How to use large numbers in? like 3441881739,30000000 etc mov eax,3441881739 In this case eax value is a negative number. How to fix it? split it? how? I need to do also add/sub/mul/div etc the cmp operation. Can someone explain and give an example how to do it? I marked fasm and nasm tags but anothers assembly are welcome too. I'm on 32-bit machine. 回答1: If you want to deal with numbers larger than 2 32 -1, you'll need to do multiple-precision arithmetic. For example, to add a pair of 64-bit

ASM: MASM, NASM, FASM?

守給你的承諾、 提交于 2019-12-02 16:41:10
I have done ARM assembly programming and I would like to learn the Intel Assembler. I keep hearing all these different F/M/N/ASMs mentioned- but I am unsure how they related to what I wish to achieve? Could somebody please help me identify what I would need to learn how to program low level on the Intel architecture? I dont quite understand how the "different Assemblers" correlate, even more so with x86, IA64, AMD64/x86-64 etc? If it is of any help, I am most comfortable with Eclipse and Visual Studio 08/10 IDEs. MASM (Microsoft Assembler) is the popular assembler for Windows. MASM is for 16

Assembly pass pointer to function

五迷三道 提交于 2019-12-02 02:18:55
问题 I'm trying to sent DWORD variable into function as pointer paramater variable1 dd 1 ... push [variable1] ; push variable adress call _InitPoiner ... _InitPoiner: ; push ebp mov ebp, esp ; lea eax, [ebp+8] ; load address mov dword [eax], 10 ; move value 10 into that address pop ebp ret ... push [variable1] push sdigit ; where sdigit db '%d', 0x0D, 0x0A, 0 call [printf] but variable1 is 1, not 11 , why? 回答1: You are making sure that you pop your vars when done? Looking at your example, I see no

Reading from memory in 8086 real mode while using 'ORG 0x0000'

[亡魂溺海] 提交于 2019-11-30 16:35:25
I've been messing around with x86-16 assembly and running it with VirtualBox. For some reason when I read from memory and try to print it as a character, I get completely different results from what I was expecting. However when I hard-code the character as part of the instruction, it works fine. Here's the code: ORG 0 BITS 16 push word 0xB800 ; Address of text screen video memory in real mode for colored monitors push cs pop ds ; ds = cs pop es ; es = 0xB800 jmp start ; input = di (position*2), ax (character and attributes) putchar: stosw ret ; input = si (NUL-terminated string) print: cli

A good NASM/FASM tutorial? [closed]

假装没事ソ 提交于 2019-11-28 15:23:27
Does anyone know any good NASM or FASM tutorials? I am trying to learn assembler but I can't seem to find any good resources on it. There is e.g. Writing A Useful Program With NASM and of course the obvious http://www.nasm.us/doc/nasmdoc3.html . There are a couple of sample programs at http://www.csee.umbc.edu/help/nasm/sample.shtml If you are looking for a more general introduction to assembly programming there is The Art of Assembly Programming and the wikipedia page on NASM references Assembly Language Step by Step by Jeff Duntemann. There is a free book on assembly language by Dr. Paul

Why does this code crash with address randomization on?

感情迁移 提交于 2019-11-28 01:56:46
I am learning amd64 assembler, and trying to implement a simple Unix filter. For an unknown reason, even simplified to the bare minimum version (code below), it crashes at random. I tried to debug this program in GNU Debugger (gdb). In the default configuration of gdb, the program runs fine, but if I enable address randomization ( set disable-randomization off ), the program starts crashing (SIGSEGV). The problematic instruction is marked in the listing: format ELF64 executable sys_read = 0 sys_write = 1 sys_exit = 60 entry $ foo: label .inbuf at rbp - 65536 label .outbuf at .inbuf - 65536