OSDev.org https://forum.osdev.org/ |
|
Which assembler? https://forum.osdev.org/viewtopic.php?f=1&t=16795 |
Page 1 of 2 |
Author: | steward [ Sun Apr 13, 2008 8:40 am ] |
Post subject: | Which assembler? |
Which assembler can assemble this code? Nasm or Masm or ....what? ; stopwatch DOSSEG .MODEL SMALL .STACK 4096 .DATA Instructions db 'STOPWATCH',13,10 db '---------',13,10 db ' (S)tart S(t)op (Q)uit',13,10 db 13,10,' $' Blank db ' $' StartRow db ? ; position on screen of timer StartCol db ? ; position on screen of timer Running db 0 ; is timer running ? TimerStart dd ? ; start value of timer TempStr db 1,2 ; temporary storage for STDIN input t2 db 80 dup (0) t3 db 13,10,'$' .CODE ProgramStart: mov ax,SEG _DATA ; set up data segment mov ds,ax lea dx,Instructions ; output instructions mov ah,9 int 21h mov ah,3 ; get current position on screen xor bh,bh int 10h mov StartRow,dh mov StartCol,dl startkeys: ; loop to get/process keystrokes mov ah,1 ; check keyboard status int 16h jz updateloop ; update if no keys available mov ah,0 ; get keystroke int 16h cmp al,'q' ; check for QUIT key je theend cmp al,'s' ; check for START key jne checkstop ; jump to next check call start jmp updateloop ; update display checkstop: cmp al,'t' ; check for STOP key jne startkeys ; continue loop call stop updateloop: cmp Running,0 je startkeys ; continue loop if timer not running call update ; update screen jmp startkeys ; continue loop theend: lea dx,t3 ; move cursor to next line mov ah,9 int 21h mov ah,4ch ; terminate program int 21h update PROC ; procedure to update timer display mov ax,0040h ; set ES to point to BIOS data area mov es,ax mov ax,es:[006Ch] ; get system clock value mov dx,es:[006Eh] sub ax,word ptr TimerStart ; get time difference sbb dx,word ptr TimerStart+2 mov bx,65535 div bx ; get hours in AX mov cx,ax ; save hours value in CX xor ax,ax xchg ax,dx ; swap remainder into AX mov bx,1092 div bx ; get minutes in dx mov si,ax ; save minutes value in SI xor ax,ax xchg ax,dx ; swap remainder into AX mov bx,18 div bx ; get seconds in ax push ax ; save seconds push si ; save minutes push cx ; save hours xor bh,bh ; put cursor at old position mov dh,StartRow mov dl,StartCol mov ah,2 int 10h pop ax ; restore hours call writesint ; output hours mov dl,':' ; output colon mov ah,2 int 21h pop ax ; restore minutes call writesint ; output minutes mov dl,':' ; output colon mov ah,2 int 21h pop ax ; restore seconds call writesint ; output seconds lea dx,Blank ; erase any digits left from old time mov ah,9 int 21h ret update ENDP start PROC ; procedure to start timer mov ax,0040h ; set ES to point to BIOS data area mov es,ax mov ax,es:[006Ch] ; get system clock value mov dx,es:[006Eh] mov word ptr TimerStart,ax ; store clock value in TimerStart mov word ptr TimerStart+2,dx mov Running,1 ; set timer flag ret start ENDP stop PROC ; procedure to stop timer mov Running,0 ; clear timer flag ret stop ENDP writesint PROC ; outputs the integer in the AX register push ax ; save all registers used push bx push cx push dx push si mov bx,10 ; radix = decimal = 10 xor si,si ; initialize digit counter startdiv: xor dx,dx div bx ; divide no by 10 push dx ; save remainder inc si ; increment digit counter cmp ax,0 ; check for end of divisions jne startdiv mov cx,si ; set digit counter mov bx,0 ; initialize position counter makeletters: pop ax ; get digit add al,48 ; make integer --> ascii value mov [t2+bx],al ; insert digit into string inc bx ; increment position counter loop makeletters mov [t2+bx],'$' ; put end-of-string marker mov ah,09h ; output integer as string lea dx,t2 int 21h pop si ; restore registers pop dx pop cx pop bx pop ax ret ; return to point of call writesint ENDP END ProgramStart |
Author: | White-spirit [ Sun Apr 13, 2008 8:52 am ] |
Post subject: | |
MASM or any other assembler with a macro for MASM syntax support |
Author: | steward [ Sun Apr 13, 2008 8:57 am ] |
Post subject: | |
I have test it in Masm and nasm.but they say that the code has error.but you know i have gotten this code from Wiki and i think it has no error. if it is possible first you assemble it first and if would work correctly please upload for me. Thnx in advance |
Author: | JamesM [ Sun Apr 13, 2008 9:15 am ] |
Post subject: | |
steward wrote: I have test it in Masm and nasm.but they say that the code has error.but you know i have gotten this code from Wiki and i think it has no error.
if it is possible first you assemble it first and if would work correctly please upload for me. Thnx in advance There are about a thousand and one posting errors in this thread, and instead of my usual painstaking ritual of working through them all, I'll just let the moderators tell you what's wrong. |
Author: | t6q4 [ Sun Apr 13, 2008 9:36 am ] |
Post subject: | |
I'm going for a wild guess.... TASM? Its 16-bit DOS code, and the only 16-bit assembler on DOS I've ever used was Turbo Assember, so I'm going with TASM. Could be MASM, so please tell me if I'm wrong (I've never used MASM). |
Author: | neon [ Sun Apr 13, 2008 10:52 am ] |
Post subject: | |
steward wrote: I have test it in Masm and nasm.but they say that the code has error.but you know i have gotten this code from Wiki and i think it has no error.
I recommend to learn assembly language first before trying to use random code from the internet. Please take no offense, but it sounds like you do not have much experience with it. In any case, please post the errors that you have gotten. iirc, MASM and TASM share alot of syntax, so it might work with both of them.. |
Author: | Combuster [ Sun Apr 13, 2008 11:16 am ] |
Post subject: | |
Quote: DOSSEG
Any reason for using that obsolete OS? |
Author: | steward [ Sun Apr 13, 2008 12:48 pm ] |
Post subject: | |
Tasm was True |
Author: | 01000101 [ Mon Apr 14, 2008 12:42 am ] |
Post subject: | |
Quote: you know i have gotten this code from Wiki and i think it has no error.
well, if it's from a wiki then it must be good code then. why did you post this? just curious about the assembler that assembled this code? or is it something that you needed to understand? |
Author: | inflater [ Mon Apr 14, 2008 8:15 am ] |
Post subject: | |
Combuster wrote: Quote: DOSSEG Any reason for using that obsolete OS? DOS is not obsolete and it still is used, http://www.freedos.org/ |
Author: | steward [ Mon Apr 14, 2008 8:45 am ] |
Post subject: | |
i want to know what is the function of this code?what does it do? |
Author: | AJ [ Mon Apr 14, 2008 8:51 am ] |
Post subject: | |
Some Clues: Quote: Code: ; stopwatch ... Code: Instructions db 'STOPWATCH',13,10 db '---------',13,10 db ' (S)tart S(t)op (Q)uit',13,10 ... This is very well (over)commented code. Cheers, Adam |
Author: | JamesM [ Mon Apr 14, 2008 12:58 pm ] |
Post subject: | |
steward wrote: i want to know what is the function of this code?what does it do?
If you don't know what it does, why on earth would you want to run it? It sounds to me like you don't know what you're doing... |
Author: | 01000101 [ Mon Apr 14, 2008 2:34 pm ] |
Post subject: | |
if you didnt know what it was, why even grab the code? how did you even get the code if you were searching for nothing imparticular? just random archive somewhere? that seems like a rather inefficient way to learn code. It would probably help if you knew what you were looking at before you went rummaging through it, or rather, posting it so others can babystep it for you. |
Author: | steward [ Mon Apr 14, 2008 2:51 pm ] |
Post subject: | |
I want to know ,does it show me the Hardware Spec? |
Page 1 of 2 | All times are UTC - 6 hours |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |