nasm

NASM: operation size not specified

只谈情不闲聊 提交于 2019-12-17 17:18:01
问题 I wrote this code in emu8086 and it goes well in the emulator but when I'm trying to compile it with NASM it's throwing me up the error: "operation size not specified", help someone? add bx,[3565] sub bx,0xcc mov [bx],0CCh 回答1: NASM can't figure out what you meant by a line like mov [bx],0CCh . Clearly, this sets something to 0CCh. But do you want to have bx pointing to a single byte , short, long, ...? This will manifest itself as the fairly self-explanatory error: operation size not

Assembly: printf not printing new line

喜你入骨 提交于 2019-12-17 17:15:55
问题 I have the following code that prints the number of parameters passed to ./main . Notice the fmt in the rodata section. I've included the new line \n , just like in C , but instead of printing the new line, it prints: Number of parameters: 1 \n My code is: ;main.asm GLOBAL main EXTERN printf section .rodata: fmt db "Number of parameters: %d \n", 0 section .text: main: push ebp mov ebp, esp ;stackframe push dword[ebp+8] ;prepara los parametros para printf push fmt call printf add esp, 2*4 mov

Convert string to int. x86 32 bit Assembler using Nasm

左心房为你撑大大i 提交于 2019-12-17 16:52:41
问题 So I'm trying to convert a string to a number so I can add another number to it later. here is what I have to far in my .text for the conversion. num2Entered is what the user entered. Num1plusNum2 is the label that I will eventually add to. They are both declared in the .bss section. Any help would be appreciated! mov ax, [num2Entered + 0] sub ax, '0' mov bx, WORD 1000 mul bx mov [Num1plusNum2], ax mov ax, [num2Entered + 1] sub ax, '0' mov bx, WORD 100 mul bx add [Num1plusNum2], ax mov ax,

MASM/NASM Differences

那年仲夏 提交于 2019-12-17 15:46:37
问题 What are the syntax differences between the NASM and MASM assemblers? 回答1: Section 2.2 of the NASM documentation is titled Quick Start for MASM Users which lists the important differences between NASM and MASM. 来源: https://stackoverflow.com/questions/2035747/masm-nasm-differences

16 bit animation - getting started

倖福魔咒の 提交于 2019-12-17 14:56:34
问题 Took a while but finally got to square 1 in 16 bit graphics. Here I clear the screen and draw a single pixel: mov ax, 0a000h mov es, ax ; es - Extra Segment now points to the VGA location mov ax, 0013h int 10h xor al, al mov dx, 3c8h out dx, al inc dx mov al, 63 out dx, al out dx, al out dx, al mov ax, 0100h int 21h mov ax, 4c00h int 21h ; draw single pixel :) mov ah, 0ch; mov al, 03h ; color mov cx, 70 ; x co-ordinate mov dx, 70 ; y co-ordinate ; mov bh,1 ; page # int 10h times 510-($-$$) db

Creating a C function without compiler generated prologue/epilogue & RET instruction?

不问归期 提交于 2019-12-17 14:12:23
问题 Consider this function: void foo(){ //do something } In assembly it would look something like this (not accurate): push something ;do stuff pop something ret But I don't want this generated code ( RET , PUSH , POP ...). I just want a label to a block of code, so I have to return myself: void bar(){ //do something asm("iret") //i want to use this function as a ISR } and in assembly it would look something like this: ; do something iret without PUSH , POP or RET . Are there any pre-processor

execute binary machine code from C

痞子三分冷 提交于 2019-12-17 08:59:49
问题 following this instructions I have managed to produce only 528 bytes in size a.out (when gcc main.c gave me 8539 bytes big file initially). main.c was: int main(int argc, char** argv) { return 42; } but I have built a.out from this assembly file instead: main.s: ; tiny.asm BITS 64 GLOBAL _start SECTION .text _start: mov eax, 1 mov ebx, 42 int 0x80 with: me@comp# nasm -f elf64 tiny.s me@comp# gcc -Wall -s -nostartfiles -nostdlib tiny.o me@comp# ./a.out ; echo $? 42 me@comp# wc -c a.out 528 a

Segmentation fault on printf - NASM 64bit Linux

不问归期 提交于 2019-12-17 07:51:15
问题 I trying to input four floats using scanf , store them onto the stack, and then use vmovupd to copy them over to a register for use. My problem is when I try to output those 4 numbers, the program seg faults at printf . I presume it is something with the stack but I've tried popping numerous times (multiple instructions at once) to no avail. I'm still new to Assembly coding so using gdb is a bit too advanced for me. You will notice that I have included a file called debug . It allows me to

Segmentation fault on printf - NASM 64bit Linux

怎甘沉沦 提交于 2019-12-17 07:51:04
问题 I trying to input four floats using scanf , store them onto the stack, and then use vmovupd to copy them over to a register for use. My problem is when I try to output those 4 numbers, the program seg faults at printf . I presume it is something with the stack but I've tried popping numerous times (multiple instructions at once) to no avail. I'm still new to Assembly coding so using gdb is a bit too advanced for me. You will notice that I have included a file called debug . It allows me to

Addressing Modes in Assembly Language (IA-32 NASM)

旧街凉风 提交于 2019-12-17 06:45:49
问题 As the web-resources on this is sparse, I will, for the benefit of future searches, begin by listing the address modes for IA-32 Assembly Language (NASM) and then follow up with a quick question. Register addressing mov eax, ebx: Copies what is in ebx into eax mov esi, var: Copies address of var (say 0x0040120e) into esi Immediate addressing (second operand is an immediate constant) mov bx, 20: 16-bit register bx gets the actual value 20 Direct memory addressing (directly loads from memory