fasm

FASM HelloWorld .exe program

我的梦境 提交于 2019-12-24 08:29:25
问题 I tried to write my first .exe program on FASM. It works ok when I use org 100h, but I want to compile .exe file. When I replaced first line with "format PE GUI 4.0" and tried to compile it the error occured: "value out of range" (line: mov dx,msg). ORG 100h ;format PE GUI 4.0 mov dx,msg mov ah,9h int 21h mov ah,10h int 16h int 21h msg db "Hello World!$" How should I change the source code? ---------------------------------------------- The answer is: format mz org 100h mov edx,msg mov ah,9h

Function Parameters in ASM x86 FASM

不羁的心 提交于 2019-12-22 12:37:21
问题 How do I pass parameters to a function in Assembly? I did push Last Param, push Second Param, push First Param.. But I cannot access the parameters within Meh Function.. What I'm doing crashes the program.. format PE console ;Format PE OUT GUI 4.0 entry main include 'macro/import32.inc' section '.idata' import data readable ;Import Section. library msvcrt,'msvcrt.dll' import msvcrt, printf, 'printf',\ exit,'exit', getchar, 'getchar' section '.data' data readable writeable ;Constants/Static

Switch from protected mode to real mode in a DOS EXE program

≯℡__Kan透↙ 提交于 2019-12-19 18:54:02
问题 I learned to switch to protected mode with a simple DOS based bootloader. This loader loads kernel.bin into a buffer and copies the buffer to 100000h (kernel is 8KiB). Control is then transferred to the kernel. When I return from the kernel and attempt to switch to real mode I encounter a problem. My FASM assembly code (Similar to my previous Stackoverflow question) is as follows: format MZ push cs pop ds mov eax,cs shl eax,4 mov [AdresSegmentuProgramu_32],eax ;Calculating real mode segment

How to write to the console in fasm?

三世轮回 提交于 2019-12-18 02:42:51
问题 I'm exceptionally new to assembly. I only picked it up yesterday and I've looked through many examples and still can't figure out for myself how to write to the console. I always get an error when I seem to replicate it in my own way. 回答1: The easiest way is to use the C functions. In its simplest use, printf() takes a string as a parameter and writes it on the standard output. This code should work: format PE console entry start include 'win32a.inc' section '.text' code executable start:

Why does this code crash with address randomization on?

岁酱吖の 提交于 2019-12-17 16:57:19
问题 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

Printing out registers/ints to console | FASM | WINAPI

£可爱£侵袭症+ 提交于 2019-12-12 08:56:09
问题 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 回答1: 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

FASM- passing parameters to an external procedure

自古美人都是妖i 提交于 2019-12-12 01:59:02
问题 I am having trouble with passing parameters to procedures outside the main ASM file. Here is my code. It shows a main procedure, _main (in main.asm) which calls a sub-procedure _sub in another source file (sub.asm). The sub-procedure prints a string specified by the main procedure. main.asm: ;subprocedure test- main.asm org 100h include 'sub.asm' ;file of sub-procedure _main: ;main method mov dx, string ;move string to dx register push dx ;push dx onto the stack call _sub;calls sub-procedure

Best way to simulate a call with jmp(dos assembly)

不羁岁月 提交于 2019-12-11 10:17:39
问题 I'm using a flat assembler on windows and have already simulated a call instruction with jmp but was wondering if there's a better way to do it with less code?(not using a call) here's the code. org 100h mov al, 'x' push come_back ; - simulated "call" - jmp test_label ; - continued - come_back: ; - end of simulated "call" - mov al, 'y' push come_back2 ; - simulated "call" - jmp test_label ; - continued - come_back2: ; - end of simulated "call" - Looop: jmp Looop test_label: mov ah, 0x0e int

A wrong size of “len” calculated by $ - symbol with FASM EQU [closed]

时光毁灭记忆、已成空白 提交于 2019-12-08 14:00:14
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 2 years ago . I have this FASM code: msg1: db "hello", 0 msg1_len equ $ - msg1 ; should be 6 Then later in code, mov edx, msg1_len puts its value in a register. Although msg1_len is supposed to be 6, when I'm debugging it, it returns a strange big number such as 4570. that is, "msg1_len" is equal to 4570 In other applications

Function Parameters in ASM x86 FASM

左心房为你撑大大i 提交于 2019-12-06 11:51:58
How do I pass parameters to a function in Assembly? I did push Last Param, push Second Param, push First Param.. But I cannot access the parameters within Meh Function.. What I'm doing crashes the program.. format PE console ;Format PE OUT GUI 4.0 entry main include 'macro/import32.inc' section '.idata' import data readable ;Import Section. library msvcrt,'msvcrt.dll' import msvcrt, printf, 'printf',\ exit,'exit', getchar, 'getchar' section '.data' data readable writeable ;Constants/Static Section. InitialValue dd 0 section '.code' code readable executable main: push 67 push 66 push 65 call