Okay, I am currently in an Assembly Languages class at school. We are delving into some source code this week for the first time. My teacher has given us an example as follows:
;plan for getting a, b, c, and displaying ab + bc
call getVal a
mov M1, AX
call getVal
mov M2, AX
call getVal
mov BX, AX
mul M2
mov CX, AX
mov AX, M2
mul...
I wanted to know how you need to handle assembly programs that are larger than 64k when you're doing 16-bit (assembly)programming in real segmented mode for DOS. In the book that I'm following("Assembly Language Step by Step" by Jeff Duntemann) the author mentions something about using more than one code segment(but unfortunately doesn't...
Hi guys,
I'm trying to call MessageBoxA() directly in assembly, using gcc inline. However I need to do this in 2 ways: first is using dynamic addressing, with LoadLibrary() and GetProcAddress() - I found a tutorial about this, trying to follow it. But I'm also interested in calling directly the address of MessageBoxA, wich is 0x7e4507ea...
Hello,
I am facing a problem related Inline assembler in c++ in order calling C++ functions at runtime.
Suppose the function to which I need to call is just taking UDT(User defined data type) as object. But my problem is I am not aware of of that user defined type in code. That UDT is not defined there in the caller's code.
Suppose I...
I'm in the process of writing an assembly program that takes two strings as input and concatenates them. Here's what I have: (using NASM syntax)
SECTION .data
hello: db "Hello ",0
world: db "world!",0
SECTION .text
; do the concatenation
Since I've never done any work with strings in x86 assembly before, I need to know how...
This description is valid for Linux 32 bit:
When a Linux program begins, all pointers to command-line arguments are stored on the stack. The number of arguments is stored at 0(%ebp), the name of the program is stored at 4(%ebp), and the arguments are stored from 8(%ebp).
I need the same information for 64 bit.
Edit:
I have working code...
Hi all,
I am generating x86-64 code at runtime in a C program on a linux system (centos 5.4 to be exact).
I generate my bytecodes into a global array as shown below
char program[1024 * 1024] __attribute__((aligned (16)));
and then call into it via a function pointer.
My issue is, when I compile the program like this
gcc -std=gnu99...
I'm implementing a program which loads pure code from a file and calls the first instruction. No matter what I do, I get a Segmentation fault when my call instruction is executed. What do I do wrong?
char code[65536];
...
__asm__("movl code, %eax");
__asm__("call *%eax");
...
According to the documentation for fgets(), the function takes three parameters:
char * - a string that will hold the input
int - an integer that represents the maximum number of characters to read
FILE * - a FILE * to the stream to read from
I have no trouble calling the function. I just push the three parameters onto the stack, cal...
I have the next code:
mov ax,@data
mov ds,ax
Why I can not write just like this?
mov ds,@data
All source:
.MODEL small
.STACK 100h
.DATA
HelloMessage DB 'Hello, world',13,10,'$'
.CODE
.startup
mov ax,@data
mov ds,ax
mov ah,9
mov dx,OFFSET HelloMessage
int 21h
mov ah,4ch
int 21h
E...
I'm somewhat familiar with the x87 instructions for manipulating floating point numbers in x86 assembly. However, I read somewhere that these were seldom used anymore. (And weren't allowed in 64-bit Windows drivers)[1]
If that's the case, what instructions should I be using? I saw something about SSE, but unless I'm mistaken, those inst...
I was reading the paper "Garbage Collector in an Uncooperative Environment" and wondering how hard it would be to implement it. The paper describes a need to collect all addresses from the processor (in addition to the stack). The stack part seems intuitive. Is there any way to collect addresses from the registers other than enumeratin...
Here is my short assembly program:
; This code has been generated by the 7Basic
; compiler <http://launchpad.net/7basic>
extern printf
; Initialized data
SECTION .data
f_0 dd 5.5
printf_f: db "%f",10,0
SECTION .text
; Code
global main
main:
push ebp
mov ebp,esp
push dword [f_0]
push printf_f
call printf
add esp,8...
I'm looking for the fastest way to popcount on large buffer of 512 or more bytes. I can guarantee any required alignment, and the buffer size is always a power of 2. The buffer corresponds to block allocations, so typically the bits are either all set, none set, or mostly set favoring the "left" of the buffer, with occasional holes.
Som...
hi,
i'm kinda having some issues with linking my assembly. I use NASM for assembly and then I link it with ld. One minor problem is that the GLOBAL directive only works if I define .data section which.. I believe has something reasonable behind it, but still how is that importnant for exporting symbols? (I decided to use coff since that ...
I have the following assembly code (written for NASM on Linux):
; This code has been generated by the 7Basic
; compiler <http://launchpad.net/7basic>
extern printf
extern scanf
SECTION .data
printf_f: db "%f",10,0
scanf_f: db "%f",0
SECTION .bss
v_0 resb 8
SECTION .text
global main
main:
push ebp
mov ebp,esp
...
Kind of an extension of http://stackoverflow.com/questions/3694100/converting-to-ascii-in-c , I was wondering exactly how divisions are handled on a PIC18X.
If I perform a DIV operation, how many instructions does the compiler interpret that as?
How many clock cycles will it take for the operation to complete? Is the number of clock cyc...
What is the structure of a stack frame and how is it used while calling functions in assembly?
...
Hello. I'm writing in 32-bit x86 assembler, and I'm not quite sure how to address data that is always in the same relation to the code. Do I have to use EIP to calculate the absolute address, or is there a better way?
...
I am making an emulator for Z80 binaries but I cannot find out whether all the integer data types are signed or unsigned from the manual or from google. So are the numbers from registers A,B...HL,BC etc signed or not?
Also, in machine code are the bytes/words/addresses which come after the instructions as arguments signed or unsigned?
...