nasm

About USB boot from usb

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-11 17:45:52
问题 I want to make ipl and boot os from my usb. I just want to read 360 sectors(512 bytes per sector).I checked code for several times and cannot find some mistakes.I have already debug it on qemu but it always returns "load error"(as in this code, it jumps to error section).It seems lba search did not work and always get carry flag 1 when I do it. my qemu program is like this qemu-system-i386 -usb ipl.bin and ipl.bin is compiled binary file made from assembler code below. ; haribote-ipl ; TAB=4

NASM - Macro local label as parameter to another macro

♀尐吖头ヾ 提交于 2019-12-11 17:19:13
问题 I am trying to use a macro (as shown in this tutorial) to print a string. The macro PRINT creates local labels to define the string content ( str ) and length ( strlen ), and then passes these as parameters to a second macro _syscall_write which makes the syscall. However running the code fails and I get a Segmentation fault (core dumped) message. I suspect the problem to be this particular lines, but I don't understand why. mov rsi, %1 ; str mov rdx, %2 ; strln Here is the full code: %macro

NASM Linux x64 | Encode binary to base64

♀尐吖头ヾ 提交于 2019-12-11 17:13:29
问题 I'm trying to encode a binary file into base64. Althrough, I'm stuck at the few steps and I'm also not sure if this is the way to think, see commentaries in code below : SECTION .bss ; Section containing uninitialized data BUFFLEN equ 6 ; We read the file 6 bytes at a time Buff: resb BUFFLEN ; Text buffer itself SECTION .data ; Section containing initialised data B64Str: db "000000" B64LEN equ $-B64Str Base64: db "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" SECTION .text

extended multiplication with nasm

爱⌒轻易说出口 提交于 2019-12-11 16:27:11
问题 as part of an assignment i have been trying to multiply two 32 bit numbers and store the result in a 64bit place. However, my result is incorrect. please help me figure why [org 0x0100] jmp start multiplicand: dd 100122,0 multiplier: dd 66015 result: dd 0,0 start: initialize: mov cl,16 mov bl,1 checkbit: test bl,[multiplier] jz decrement multiply: mov ax, [multiplicand] add [result],ax mov ax, [multiplicand+2] adc [result+2], ax mov ax, [multiplicand+4] adc [result+4], ax decrement: shl bl,1

Basics of Assembly programming in 64-bit NASM programming

杀马特。学长 韩版系。学妹 提交于 2019-12-11 16:04:06
问题 I am new to assembly programming and trying to interpret the following code where I've to print an array present in the .data section : Here is the code: %macro print 2 mov rax,1 mov rdi,1 mov rsi,%1 mov rdx,%2 syscall %endmacro %macro exit 0 mov rax,60 mov rdi,0 syscall %endmacro section .data msg db 10,"Array is : ",10 len equ $-msg array dq 11234H, 0AB32H, -3326H, 056BH newline db 10 section .bss buff resb 16; section .code global _start _start: print msg,len mov rsi,array mov rcx,4 back:

How can i make the os wait a second before shutdown ( nasm )

让人想犯罪 __ 提交于 2019-12-11 15:54:32
问题 powerCommand: mov si, powerOFF call printString ;sleep command here mov ax, 0x1000 mov ax, ss mov sp, 0xf000 mov ax, 0x5307 mov bx, 0x0001 mov cx, 0x0003 int 0x15 ret I want the program wait for 1 second then continue with shutdown. At the moment it shuts down instantly after the shutdown message. I am running it on my custom os made in nasm. 回答1: Assuming your program is loaded by the ROM-BIOS (not EFI), and you're running in (Real/Virtual) 86 Mode, and you have interrupts enabled ( sti ),

how do you multiply word-size inputs and get its word-size product in stack?

感情迁移 提交于 2019-12-11 15:48:04
问题 section .data msg db "Menu: " msgLen equ $ -msg msg2 db "[1]Factorial" msgLen2 equ $ -msg2mov dx, 0 msg3 db "[2]Power" msgLen3 equ $ -msg3 msg4 db "[3]Exit" msgLen4 equ $ -msg4 msg5 db "Enter number: " msgLen5 equ $ -msg5 msg6 db "Enter two numbers: " msgLen6 equ $ -msg6 line db "", 10 section .bss choice resb 1 num1 resw 1 quo1 resw 1 quo2 resw 1 quo3 resw 1 quo4 resw 1 quo5 resw 1 rem1 resw 1 rem2 resw 1 rem3 resw 1 rem4 resw 1 rem5 resw 1 section .text global _start _start: do_while: mov

Wait for keypress Assembly NASM, Linux

社会主义新天地 提交于 2019-12-11 13:58:09
问题 I'm working on a Hello World in Assembly for x86-64. I have managed to create one that finishes when Enter key is pressed, but I have to finish it when ANY key is pressed. This is the code for waiting the ENTER Key: mov rax, 0 mov rdi, 0 mov rdx, 1 syscall I can't use any int xh or something like that. Only syscalls. Thanks! 回答1: I've answered a similar question before, and gave C code that would work directly with system calls to do what you wanted. Here's a translation of that code to nasm,

Are rdi and rsi caller saved or callee saved registers?

不打扰是莪最后的温柔 提交于 2019-12-11 12:53:00
问题 From the wikipedia x86 calling convention, it says that for the Microsoft x64 calling convention: The registers RBX, RBP, RDI, RSI , RSP, R12, R13, R14, and R15 are considered nonvolatile (callee-saved). But for System V AMD64 ABI: If the callee wishes to use registers RBX, RBP, and R12–R15, it must restore their original values before returning control to the caller. It did not mention anything about rdi and rsi. I also read that %rax, %rcx, %rdx, %rdi, %rsi , %rsp, and %r8-r11 are

Convert hexadecimal number to hexadecimal string in assembly language (NASM) (debug)

北战南征 提交于 2019-12-11 11:53:10
问题 OK, before someone else marks this question as a duplicate. Let me make this very clear that this is more of a debugging problem than a logical problem. The logic is correct as far as I know because if I individually print the value in bx register after each operation, then I get correct output. The problem is that storing the results in bx register should make changes in the memory location it holds which is not happening. So, I was learning assembly language these days, in NASM. I am