nasm

print string with bios interrupt 0x10

拈花ヽ惹草 提交于 2021-02-08 07:10:33
问题 I want to print a string using bios interrupt 0x10. But I get only a blue fiel, without letters in it. Maybe I habe a problem by adressing my string. Edit: I have two code files. The first is written on the first sector of a floppy. It copys the second sector from the floppy to the memory (starting at 0x5000) and jump to 0x5000. Here is my second file, where I should print my string. [BITS 16] org 0x5000 sect2: mov ah, 0x03 ;get curser position mov bh, 0x00 ;page number int 0x10 mov ax,

NASM tutorial uses int 80h, but this isn't working on Windows

孤街醉人 提交于 2021-02-07 14:16:18
问题 I'm starting NASM Assembler after finishing FASM. I'm coding this in a Windows Operating System. My code reads: section.data ;Constant msg: db "Hello World!" msg_L: equ $-msg ; Current - msg1 section.bss ;Varialble section.text ; Code global _WinMain@16 _WinMain@16: mov eax,4 mov ebx,1; Where to wrte it out. Terminal mov ecx, msg mov edx, msg_L int 80h mov eax, 1 ; EXIT COMMAND mov ebx,0 ; No Eror int 80h To compile it and execute I use: nasm -f win32 test.asm -o test.o ld test.o -o test.exe

Linux NASM detect EOF

蹲街弑〆低调 提交于 2021-02-07 13:17:27
问题 I'm trying to learn the basics asm on linux and I can't find a very good reference. The NASM docs seem to assume you already know masm... I found no examples in the documentation of the cmp (outside the Intel instruction reference). I'd written a program that reads a single byte from stdin and writes it to stdout. Below is my modification to try to detect EOF on stdin and exit when EOF is reached. The issue is it never exits. I just keeps printing the last char read from stdin. The issue is

Linux NASM detect EOF

老子叫甜甜 提交于 2021-02-07 13:12:55
问题 I'm trying to learn the basics asm on linux and I can't find a very good reference. The NASM docs seem to assume you already know masm... I found no examples in the documentation of the cmp (outside the Intel instruction reference). I'd written a program that reads a single byte from stdin and writes it to stdout. Below is my modification to try to detect EOF on stdin and exit when EOF is reached. The issue is it never exits. I just keeps printing the last char read from stdin. The issue is

MinGW's ld cannot perform PE operations on non PE output file

喜你入骨 提交于 2021-02-07 08:08:44
问题 I know there are some other similar questions about this out there, be it StackOverflow or not. I've researched a lot for this, and still didn't find a single solution. I'm doing an operative system as a side project. I've been doing all in Assembly, but now I wanna join C code. To test, I made this assembly code file (called test.asm): [BITS 32] GLOBAL _a SECTION .text _a: jmp $ Then I made this C file (called main.c): extern void a(void); int main(void) { a(); } To link, I used this file

MinGW's ld cannot perform PE operations on non PE output file

喜你入骨 提交于 2021-02-07 08:06:17
问题 I know there are some other similar questions about this out there, be it StackOverflow or not. I've researched a lot for this, and still didn't find a single solution. I'm doing an operative system as a side project. I've been doing all in Assembly, but now I wanna join C code. To test, I made this assembly code file (called test.asm): [BITS 32] GLOBAL _a SECTION .text _a: jmp $ Then I made this C file (called main.c): extern void a(void); int main(void) { a(); } To link, I used this file

How to write to screen with video memory address 0xb8000 from real mode?

巧了我就是萌 提交于 2021-02-06 20:02:53
问题 I created simple code to load second sector from hard drive, and then write to whole screen, with spaces with red background. The problem is that always instead of spaces I got @ signs. This is the code: org 0x7C00 bits 16 xor ax,ax mov ds,ax mov es,ax mov bx,0x8000 cli mov ss,bx mov sp,ax sti cld clc xor ah,ah int 0x13 mov bx,0x07E0 mov es,bx xor bx,bx mov ah,0x2 ;function mov al,0x5 ;sectors to read mov ch,0x0 ;track mov cl,0x2 ;sector mov dh,0x0 ;head int 0x13 ;jc error ;mov ah, [0x7E00]

Why use RIP-relative addressing in NASM?

生来就可爱ヽ(ⅴ<●) 提交于 2021-02-06 09:25:50
问题 I have an assembly hello world program for Mac OS X that looks like this: global _main section .text _main: mov rax, 0x2000004 mov rdi, 1 lea rsi, [rel msg] mov rdx, msg.len syscall mov rax, 0x2000001 mov rdi, 0 syscall section .data msg: db "Hello, World!", 10 .len: equ $ - msg I was wondering about the line lea rsi, [rel msg] . Why does NASM force me to do that? As I understand it, msg is just a pointer to some data in the executable and doing mov rsi, msg would put that address into rsi .

Function works with buffers on the stack but not in .data or .bss sections? [duplicate]

折月煮酒 提交于 2021-02-05 12:21:04
问题 This question already has an answer here : Why can't I make a char array longer than 61 characters in C? [duplicate] (1 answer) Closed 10 months ago . I have the following code: global _start extern GetStdHandle, WriteConsoleA ;kernel32.dll section .data: buf times 12 db 0 section .text: _uint32_to_string: ;void uint32_to_string(uint32_t n, char* buffer) ;buffer: 11 bytes (minimum) push ebp push ebx push esi push edi mov ebp, esp mov ebx, [ebp + 24] xor edi, edi mov eax, [ebp + 20] mov ecx,

NASM says “Invalid combination of opcode and operands”

北战南征 提交于 2021-02-05 11:36:26
问题 I just started learning assembly programming. I am using NASM on linux. I wrote this code that's basically meant to calculate the somethingth power of something and I know it's probably not exactly good, but I really don't care at this point, all I want is just SOME idea why I keep getting that error, because I have tried to modify and switch operands and operations and everything in the section where the problem is, but if anything that only gave me more error messages. As I said, I'm really