[Source]Printing strings using interrupts in 16-bit.

Posts 12 of 2 · Page 1 of 1
[Source]Printing strings using interrupts in 16-bit.
Yeah, I was working on this last night, first in MASM, then in NASM because MASM was sort of being a douchebag. ):


[highlight=asm]
[bits 16]
[org 0x100]

main:
jmp start

message db 'Test..',0

PrintChar:

push bp
mov bp,sp

mov ax,word [bp+4]

mov al,byte [bp+4]
mov ah,0Eh
int 10h

mov sp,bp
pop bp
ret

PrintString:

push bp
mov bp,sp

mov bx,0

printLoop:
push bp
mov bp,[bp+4]
add bp,bx
mov cl,byte [bp]
pop bp
cmp cl,0
je print_done

push cx
call PrintChar
inc bx
jmp printLoop
print_done:

mov sp,bp
pop bp
ret

start:

xor ax,ax
mov ds,ax
mov es,ax

mov bp,100h
mov sp,100h

push message
call PrintString

l:
jmp l ;infinite loop to keep the window open

[/highlight]
MASM isn't a douchebag
It rocks
Posts 12 of 2 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Need help?