Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jan 29th, 2006, 12:54 AM   #1
GothicSheep
Newbie
 
Join Date: Jan 2006
Posts: 1
Rep Power: 0 GothicSheep is on a distinguished road
Making a temperature converter in assembly

Hello everyone,

I'm new to assembly, but I've got most of the basics so I'm trying to make a temperature converter. However, TLINK tells me there's no program entry point when I try to link it. No problems with TASM, it's just TLINK that gives the error.

Any help would be appreciated. Thanks!

Here's my code:

----------------------------

.model small
.stack

.data
lf equ 0ah
cr equ 0dh

prompt1 db cr,lf,"Enter task: ","$"
prompt1a db cr,lf,"[1] Convert centigrade to farenheit","$"
prompt1b db cr,lf,"[2] Convert farenheit to centigrade","$"
prompt2 db cr,lf,"Enter temp: ","$"

.code
main proc far
mov ax,@data
mov ds,ax

call firstprompt

cmp al,'1'
je centigrade
cmp al,'2'
je farenheit
jmp firstprompt

main endp

firstprompt:
mov ax,offset prompt1
call write
mov ax,offset prompt1a
call write
mov ax,offset prompt1b
call read
ret

write:
mov ah,09h
int 21h
ret

read:
mov ah,01h
int 21h
ret

centigrade:
jmp entertemp
sub ax,32d
mov bx,5d
mul bx
mov bx,9d
div bx
call write

farenheit:
jmp entertemp
mov bx,9d
mul bx
mov bx,5d
div bx
mov bx,32d
add ax,bx
call write

entertemp:
mov ax,offset prompt2
call write
call read
ret

endprog:
mov ax,4c00h
int 21h

end

Last edited by GothicSheep; Jan 29th, 2006 at 1:02 AM. Reason: Syntax error
GothicSheep is offline   Reply With Quote
Old Jan 29th, 2006, 4:13 AM   #2
Klarre
Game engine designer
 
Klarre's Avatar
 
Join Date: May 2005
Location: Sweden
Posts: 288
Rep Power: 4 Klarre is on a distinguished road
I tried to link your program and got the error that there were no entry point in the program. I added two rows, and then it worked. Try this code.
.model small
.stack

.data
lf equ 0ah
cr equ 0dh

prompt1 db cr,lf,"Enter task: ","$"
prompt1a db cr,lf,"[1] Convert centigrade to farenheit","$"
prompt1b db cr,lf,"[2] Convert farenheit to centigrade","$"
prompt2 db cr,lf,"Enter temp: ","$"

.code
start: ; ADDED
main proc far
mov ax,@data
mov ds,ax

call firstprompt

cmp al,'1'
je centigrade
cmp al,'2'
je farenheit
jmp firstprompt

main endp

firstprompt:
mov ax,offset prompt1
call write
mov ax,offset prompt1a
call write
mov ax,offset prompt1b
call read
ret

write:
mov ah,09h
int 21h
ret

read:
mov ah,01h
int 21h
ret

centigrade:
jmp entertemp
sub ax,32d
mov bx,5d
mul bx
mov bx,9d
div bx
call write

farenheit:
jmp entertemp
mov bx,9d
mul bx
mov bx,5d
div bx
mov bx,32d
add ax,bx
call write

entertemp:
mov ax,offset prompt2
call write
call read
ret

endprog:
mov ax,4c00h
int 21h

end start ; MODIFIED

It outputs some crap though, so you got some time with debugging now.
Klarre is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 12:08 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC