Turbo Assembler

From Wikipedia, the free encyclopedia
  (Redirected from TASM)
Jump to navigation Jump to search
Turbo Assembler
Developer(s)Borland
Initial release1989; 30 years ago (1989)
Stable release
5.4
Operating systemDOS, Windows
TypeAssembler
LicenseProprietary
WebsiteOfficial webpage at the Wayback Machine (archived October 23, 2010)

Turbo Assembler (TASM) is a computer assembler (software for program development) developed by Borland which runs on and produces code for 16- or 32-bit x86 DOS or Microsoft Windows. It can be used with Borland's high-level language compilers, such as Turbo Pascal, Turbo Basic, Turbo C and Turbo C++. The Turbo Assembler package is bundled with the Turbo Linker, and is interoperable with the Turbo Debugger. TASM can assemble Microsoft Macro Assembler (MASM) source using its MASM mode and has an ideal mode with a few enhancements. Object-Oriented programming has been supported since version 3.0. The last version of Turbo Assembler is 5.4, with files dated 1996 and patches up to 2010; it is still supplied with Delphi and C++Builder.

TASM itself is a 16-bit program; it will run on 16- and 32-bit versions of Windows, and produce code for the same versions. There are ways to run 16-bit programs such as TASM on 64-bit Windows (e.g., on a virtual machine), but it will not generate 64-bit Windows code.

The Borland Turbo Assembler 5.0 package is supplied on three 3.5-inch diskettes and with three small books.


[org 0x0100] jmp start message: db 'BC170400227' ; string to be printed tickcount: dw 0

subroutine to print a number at top left of screen
takes the number to be printed as its parameter

printnum: push bp mov bp, sp push es push ax push bx push cx push dx push di mov ax, 0xb800 mov es, ax ; point es to video base mov ax, [bp+4] ; load number in ax mov bx, 10 ; use base 10 for division mov cx, 0 ; initialize count of digits nextdigit: mov dx, 0 ; zero upper half of dividend div bx ; divide by 10 add dl, 0x30 ; convert digit into ascii value push dx ; save ascii value on stack inc cx ; increment count of values cmp ax, 0 ; is the quotient zero jnz nextdigit ; if no divide it again mov di, 140 ; point di to 70th column nextpos: pop dx ; remove a digit from the stack mov dh, 0x07 ; use normal attribute mov [es:di], dx ; print char on screen add di, 2 ; move to next screen location loop nextpos ; repeat for all digits on stack pop di pop dx pop cx pop bx pop ax pop es pop bp ret 2

timer interrupt service routine

timer: push ax inc word [cs:tickcount] ; increment tick count push word [cs:tickcount] call printnum; print tick count cmp word [cs:tickcount], 9 jne skip 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, 0x010F ; row 10 column 15 mov cx, 11 ; length of string push cs pop es ; segment of string mov bp, message ; offset of string int 0x10 skip: mov al, 0x20 out 0x20, al ; end of interrupt pop ax iret ; return from interrupt start: xor ax, ax mov es, ax ; point es to IVT base cli ; disable interrupts mov word [es:8*4], timer; store offset at n*4 mov [es:8*4+2], cs ; store segment at n*4+2 sti ; enable interrupts mov dx, start ; end of resident portion add dx, 15 ; round up to next para mov cl, 4 shr dx, cl ; number of paras mov ax, 0x3100 ; terminate and stay resident int 0x21


[org 0x0100] jmp start message: db 'BC170400227' ; string to be printed tickcount: dw 0

subroutine to print a number at top left of screen
takes the number to be printed as its parameter

printnum: push bp mov bp, sp push es push ax push bx push cx push dx push di mov ax, 0xb800 mov es, ax ; point es to video base mov ax, [bp+4] ; load number in ax mov bx, 10 ; use base 10 for division mov cx, 0 ; initialize count of digits nextdigit: mov dx, 0 ; zero upper half of dividend div bx ; divide by 10 add dl, 0x30 ; convert digit into ascii value push dx ; save ascii value on stack inc cx ; increment count of values cmp ax, 0 ; is the quotient zero jnz nextdigit ; if no divide it again mov di, 140 ; point di to 70th column nextpos: pop dx ; remove a digit from the stack mov dh, 0x07 ; use normal attribute mov [es:di], dx ; print char on screen add di, 2 ; move to next screen location loop nextpos ; repeat for all digits on stack pop di pop dx pop cx pop bx pop ax pop es pop bp ret 2

timer interrupt service routine

timer: push ax inc word [cs:tickcount] ; increment tick count push word [cs:tickcount] call printnum; print tick count cmp word [cs:tickcount], 9 jne skip 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, 0x010F ; row 10 column 15 mov cx, 11 ; length of string push cs pop es ; segment of string mov bp, message ; offset of string int 0x10 skip: mov al, 0x20 out 0x20, al ; end of interrupt pop ax iret ; return from interrupt start: xor ax, ax mov es, ax ; point es to IVT base cli ; disable interrupts mov word [es:8*4], timer; store offset at n*4 mov [es:8*4+2], cs ; store segment at n*4+2 sti ; enable interrupts mov dx, start ; end of resident portion add dx, 15 ; round up to next para mov cl, 4 shr dx, cl ; number of paras mov ax, 0x3100 ; terminate and stay resident int 0x21

References[edit]

Notes
  • Swan, Tom (1989). Mastering Turbo Assembler. Carmel, Indiana: Howard W. Sams & Company, Hayden Books division of Macmillan Computer Publishing. ISBN 0-672-48435-8. 2nd Edition, 1995 ISBN 0-672-30526-7.

External links[edit]