How to define a string using assembly 8086 in Turbo Pascal? -
i can write assembly code.
i want use interruption 10h/13h write string screen. can't figure out how define or save in memory string using assembly in turbo pascal.
this didn't work:
msg1 'hello, world!$'
my code:
program string; begin asm mov ah,$0 mov al,03h int 10h; mov ax,1300h mov bh,$0 mov bl,07h mov cx,$9 mov dl,$0 mov dh,$0 int 10h mov ah,00h int 16h end; end.
anyone knows it?
the suffix '$' termination character available dos functions. int 10h / ah=13h
(video-bios function) deals length of string in cx
. "pascal-string" has length in first byte. has no termination character dos-/c-/asciiz-string. can tp manuals - programmer's guide - here.
look @ example:
program string_out; var s1 : string; procedure write_local_string; var s3 : string; begin s3 := 'hello world stack segment.'; asm push bp { `bp` in need of procedure return } mov ax, ss mov es, ax lea bp, s3 { determine offset of string @ runtime } mov ax, 1300h mov bx, 0007h xor cx, cx { clear @ least `cx` } mov cl, [es:bp] { length of string in 1st byte of string } inc bp { string begins byte later } mov dx, 0200h { write @ third row , first column} int 10h pop bp end; end; begin s1 := 'hello world data segment.'; asm mov ah, 0 mov al, 03h int 10h; mov ax, ds mov es, ax mov bp, offset s1 mov ax, 1300h mov bx, 0007h xor cx, cx { clear @ least `ch` } mov cl, [es:bp] { length of string in 1st byte of string } inc bp { string begins byte later } mov dx, 0000h { write @ first row , first column} int 10h mov ax, cs mov es, ax mov bp, offset @s2 mov ax, 1300h mov bx, 0007h mov cx, 30 { length of string } mov dx, 0100h { write @ second row , first column} int 10h jmp @skip_data @s2: db 'hello world code segment.' @skip_data: end; write_local_string; writeln; writeln; { adjust cursor } end.
Comments
Post a Comment