Dollar Completed Lines

In my assembler class, our first task was to write a program to print a simple line with a trailing dollar in DOS. It looked something like this:

BITS 32
    global _main

section .data
    msg db "Hello, world!", 13, 10, โ€™$โ€™

section .text
_main:
mov ah, 9
mov edx, msg
int 21h
ret

As I understand it, the $ sign is used to stop the sting, like null in C. But what if I want to put a dollar sign in a string (for example, I want to print), does it cost $ 30? )? This seems like a simple question, but my professor did not know the answer, and I did not seem to find it using google search.

+3
source share
6 answers

DOS 0x09 $, 0x02. . .

+8

print_string NULL, INT 29h ( AL).

; ds:si = address of string to print
print_string:
    lodsb                   ; load next character from ds:si
    or al, al               ; test for NULL-character
    jz .end_of_string       ; end of string encountered, return.
    int 29h                 ; print character in AL on screen
    jmp print_string        ; print next character
.end_of_string:
    ret                     ; return to callers cs:ip

(, NASM)

+3

Um. , $, . \$? \ , \\ \

0

- , . . " ", "$" , , "30". , .

0

02 INT 21H 09 .

.

mov dl, '$'

mov ah,02

int 21h
0

'$$', '\ 044' () '\ x24' (hex)

-3

Source: https://habr.com/ru/post/1702266/


All Articles