G
G
Grigory Dikiy2016-04-21 12:07:36
Pascal
Grigory Dikiy, 2016-04-21 12:07:36

Call writeln and readln Pascal?

Good day, the question is how can I call the writeln and readln functions in assembler. Intuitively, I understand that I need to include some header files, but which ones? I plan to use NASM
. I work in Linux, before that I used gcc, there I called the scanf () and print () functions. In general, I even think about using calls to these functions instead of _writeln_ and _readln_

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vladimir Kuts, 2016-04-21
@frilix

If you work under DOS, output the text after 21h interrupt,
if in windows - through WindowsApi calls
Using the C library, something like this:

; ----------------------------------------------------------------------------
; helloworld.asm
;
; This is a Win32 console program that writes "Hello, World" on one line and
; then exits.  It needs to be linked with a C library.
; ----------------------------------------------------------------------------

    global  _main
    extern  _printf

    section .text
_main:
    push    message
    call    _printf
    add     esp, 4
    ret
message:
    db  'Hello, World', 10, 0

R
Roman Mirilaczvili, 2016-04-21
@2ord

In theory, you need to use the system API to work with input / output. This can be implemented differently on different operating systems. In DOS - through interrupts, and in modern ones - through calling the appropriate functions.
For Linux - the libc library with the functions puts, printf and others.
Only I absolutely do not see the point of writing it in assembler. Pascal is good for this, that you can write portable code using the usual write / read.
You can also try GNU Pascal instead of Free Pascal. The latter has a backend implemented on the same GCC, which by itself implies good code optimization.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question