Pregunta

I am talking about 16 bit 8086 (Nasm). I can understand full code but I can't understand why we have to do this

push cs 
pop es

in the code below

; print string using bios service
[org 0x0100]
jmp start
message: db 'Hello World'
start: mov ah, 0x13 ; service 13 - print string
mov al, 1 ; subservice 01 – update cursor
mov bh, 0 ; output on page 0
mov bl, 7 ; normal attrib
mov dx, 0x0A03 ; row 10 column 3
mov cx, 11 ; length of string

;******************
push cs
pop es ; segment of string
;******************

mov bp, message ; offset of string
int 0x10 ; call BIOS video service
mov ax, 0x4c00 ; terminate program
int 0x21
¿Fue útil?

Solución 2

The cs is a segment register, it points the segment in which the code that you are running resides.

Since the string is in your code segment, you need to pass that segment to the int 0x10 that you call.

Otros consejos

Because

mov ES,CS

is not a valid instruction and it's required that ES=CS for the code.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top