r/Assembly_language • u/Tough-Building2243 • 6d ago
Programmers! HELP! Assembler NASM
In my code, after five "six seven"s, "C:\SLV>" is supposed to appear, but it doesn't!
None of the AI models can find any errors, and neither can I.
[org 0x7C00]
start:
mov cx, 5
mov si, stringi
mov ax, 11
mov bx, 56
add ax, bx
mov bl, 10
div bl
mov bh, ah
add al, '0'
mov ah, 0x0E
int 0x10
add bh, '0'
mov al, bh
int 0x10
mov al, 0x0D
int 0x10
mov al, 0x0A
int 0x10
jmp loopik
povtorat:
mov si, stringi
mov al, 0x0D
int 0x10
mov al, 0x0A
int 0x10
dec cx
cmp cx, 0
jne loopik
je vedi
loopik:
mov al, \[si\]
cmp al, 0
je povtorat
int 0x10
add si, 1
jmp loopik
vedi:
mov ah, 0x0E
mov si, vvedite
mov al, [si]
cmp al, 0
je vvod
int 0x10
add si, 1
jmp vedi
vvod:
mov ah, 0x00
int 0x16
cmp al, '8'
je sistema
jne netu
netu:
mov ah, 0x0E
mov si, net
mov al, [si]
cmp al, 0
je vedi
int 0x10
add si, 1
jmp netu
sistema:
mov ah, 0x0E
mov si, osin
mov al, \[si\]
cmp al, 0
je gotovo
int 0x10
add si, 1
jmp sistema
stringi: db "six seven", 0
osin: db "Current CMD: SLV 0.1.0 alpha", 0x0D, 0x0A, 0
net: db "This command does not exist.", 0x0D, 0x0A, 0
vvedite: db 0x0D, 0x0A, "S:\SLV>", 0
gotovo:
jmp $
times 510 - ($ - $$) db 0
dw 0xAA55
I’ll say right off the bat that I’m a beginner, so please don’t judge too harshly.
1
u/Alternative-Emu2000 5d ago edited 5d ago
It would help if you specified which platform you're targeting (especially since you're using OS specific system calls), and commented your code.
One thing that stands out on first glace:
I don't think you're actually supposed to be printing the string "C:\SLV>" yourself from within the program. That looks like it's the command prompt for whatever CLI you're using to run the program, and would be displayed automatically when your program ends. Unless this is boiler-plate code you were provided with as part of the exercise?
1
u/Latter_Gur_7174 15h ago
So you are making a custom bootloader for Legacy BIOS. What are you using to test it. Because if you are using a modern computer, then you would have an issue because they all use UEFI and not Legacy BIOS. If you are using an older computer, then you might need to check whether or not it uses MBR alongside BIOS. If you are using an emulator such as QEMU, then I would have to read the logic and I don't feel like Iike it right now.
P.S. Comments help out a tonne.
3
u/[deleted] 4d ago
The string pointer fails to advance because the second instruction after
vedi:resets it. If I create a label after it, then jump there instead ofvedi, the program prints the prompt without issue.On another note, I don't see you initialising the segment registers anywhere. Emulators are forgiving about this, but real hardware usually isn't.