nasm

How important are section/segment directives?

How important are section/segment directives? I've noticed that they are usually optional. Also, I've noticed that the output size changes when you do or do not include them. I'm using NASM, if that helps. ...

NASM and INT13h - what am I doing wrong?

Hey, I'm pretty interested in OS writing, I was for a long time, but still just could not swallow it (I mostly go with "What can't you understand on first read you should not do at all" - and it applies well for everything else I do, like PHP, HTML, AS3.0, C++... a lot more) just now I KIND of got it. The problem is - really, ASM was not...

Intel IAPX 88 Processor,TSR (terminate and stay resident), question about resident portion of the program in Assembly, NASM assembler

suppose i have a following program [org 0x100] jmp start kbisr:........ .............. ............ ............ iret start: .......... ............... ;now to reside the portion of program that is above the start lable what i do is mov dx,start add dx,15 mov cl,4 shr dx,cl mov ax,0x3100 int 0x21 Now Suppose the offset of start is 01...

Some questions about string length counting

Hi, I have a problem about counting the length of a string. I always get some number like 2432, thou I pass a string like "abc". I think the problem is in this line mov bl, byte [esi] but I would not know why. Maybe it is something with character length in bits? Could the problem be a 64bit operating system or dual core processor? ...

OS's Boot-loader doesn't work

I am making a custom Operating System. I have two nasm files: boot.asm: [BITS 16] ;tell the assembler that its a 16 bit code [ORG 0x7C00] ;Origin, tell the assembler that where the code will ;be in memory after it is been loaded INT 0x13 JMP $ ;infinite loop TIMES 510 - ($ - $$) db 0 ;fill the rest of sector with 0 DW 0...

Intel IAPX88 Processor, Trap ISR

I am posting the following piece of code, the basic aim of this code is, when i set the trap flag to 1 then after that i am printing a character z on the screen, now as trap flag is set, the program should execute one instruction and trap, I have written a simple trap ISR in which i have an infinite loop, this infinite loop will be broke...

How do i read single character input from keyboard using nasm (assembly) under ubuntu?

Hi, I'm using nasm under ubuntu. By the way i need to get single input character from user's keyboard (like when a program ask you for y/n ?) so as key pressed and without pressing enter i need to read the entered character. I googled it a lot but all what i found was somehow related to this line (int 21h) which result in "Segmentation F...

Building a COM object vtable in x86 assembly

I am building a COM object in x86 assembly using NASM. I understand COM quite well and I understand x86 assembly pretty well, but getting the two to mesh is getting me hung up... (by the way, if you're thinking of attempting to dissuade me from using x86 assembly, please refrain, I have very particular reasons why I'm building this in x8...

SegFaults in my Assembler? But that's impossible! :O

Okay, so I understand all of us C/C++ programmers have at one time met our untimely nemesis, the diabolical signal SIGSEGV, the Segmentation Fault. Now, I understood (emphasis on the past tense) this to be some form of fail safe / checking system within some portion of the machine code spat out by the magical GCC (or g++) compiler, or wh...

What does ORG Assembly Instruction do?

Hi, can anyone give me a comprehensive description about ORG directive? When and why is it used in assembly written applications? Using Nasm on x86 or AMD64. ...

Shutting down computer with nasm.

Is it possible to shut down or kill the power (is there a difference?) to a computer from nasm. I know you can use this to reboot: mov al, 0xFE out 0x64, al Is there an equivalent for shutting down? ...

When assembling .asm, can it be disassembled to the same syntax?

Say I have a simple nasm program to print hello!, of course in intel syntax, when I assemble it (with -f elf) and diassemble with with ndisasm it's completely different! why can it not disassemble back into the same simple format of my hello world program? is it not possible ? ...

64 bits binary form in assembler....

I'm kind a of making a "JIT" for a numeric routine that I need to compute fast, for x86-64. I'm only using sse instructions for arithmetics and of course some moves. My application generates all of those by simply writing the binary form of machine instructions to some part of memory and then executing. For getting the binary form of ins...

Why is this an invalid operand?

I have the following ASM file generated by a compiler I'm writing: ; This code has been generated by the 7Basic ; compiler <http://launchpad.net/7basic&gt; ; Uninitialized data SECTION .bss v_0 resb 4 v_4 resb 4 v_8 resb 4 ; Code SECTION .text push 1 pop eax mov v_0, eax push 2 pop eax mov v_4, eax mov eax, v_0 push eax ...

How to print string in OS-neutral way?

I am trying to print a string in a way that's OS-neutral. For example, the program should run the same on Windows as it does on *nix. Is this even possible? I'm assuming that since the underlying architecture is the same (x86) that the method would be the same. Is it as simple as calling an interrupt? The reason for this is I'm trying ...

Can't modify memory using 32bit assembler

Hello. I am using NASM to assemble my assembler code. The code I assembled looks like this: [BITS 32] [ORG 0] jmp 07c0h:start testvar db 0, 0, 0, 0, 0, 0, 4, 8, 15, 16, 23, 42 start: mov byte [testvar], 47 hang: jmp hang times 510-($-$$) db 0 dw 0AA55h I had problems with another piece of code, I noticed that I cou...

How to debug an assembled program?

I have a program written in assembly that crashes with a segmentation fault. (The code is irrelevant, but is here.) My question is how to debug an assembly language program with GDB? When I try running it in GDB and perform a backtrace, I get no meaningful information. (Just hex offsets.) How can I debug the program? (I'm using NASM ...

How to call fgets in x86 assembly?

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...

Why is scanf returning 0.000000 when it is supplied with a double?

I have the following assembly code (written for NASM on Linux): ; This code has been generated by the 7Basic ; compiler <http://launchpad.net/7basic&gt; 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 ...

Printing Hexadecimal Digits with Assembly

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 t...