0, 59, 60, 3599, 3600, 7272, 32000, 32072, 65535
Mov Ax, Seg Data Mov Ds, Ax Mov Es, Ax
Ax 16-bit/ Dx:Ax Dx
| Var
Prompt : String[42] = 'ENTER TEMPERATURE IN DEGREES FAHRENHEIT'; Annotation : String[42] = ' TEMPERATURE IN DEGREES CENTIGRADE'; Ax : Integer; Begin Write( Prompt ); Readln( Ax ); { Read Fahrenheit } Ax := Round( (Ax - 32) * 5/9 ); { Convert Fahr. to Cent. } Write( Annotation ); Writeln( Ax ); { Write Centigrade } End. |
| #include <iostream.h>
void main() { char Prompt[42] = "ENTER TEMPERATURE IN DEGREES FAHRENHEIT"; char Annotation[42] = " TEMPERATURE IN DEGREES CENTIGRADE"; int Ax; cout << Prompt
;
|
Extrn Getdec:Far ; #include <iostream.h>
Extrn Putdec:Far
Extrn PutStrng:Far
Data Segment
Prompt db "ENTER TEMPERATURE IN DEGREES FAHRENHEIT ";
Annotation db " TEMPERATURE IN DEGREES CENTIGRADE ";
Data Ends
Code Segment
Assume Cs:Code, Ds:Data, Ss: SSeg
main Proc Far ; void main() {
Mov Ax, Seg Data
Mov Ds, Ax
Mov Es, Ax
Mov Cx, 40
Lea Di, Prompt
Call Putstrng ; cout << Prompt ;
Call Getdec ; cin >> Ax ;
Sub Ax, 32 ; Ax = (int)((Ax - 32)* 5/9 );
Mov Bx, 5
Imul Bx
Mov Bx, 9
Idiv Bx ; Dx=Remainder Ax=Quotient
Xchg Ax, Dx
Mov Bl, 5 ; Round up
Idiv Bl
Cbw
Add Ax, Dx
Mov Cx, 40 ; cout << Annotation ;
Lea Di, Annotation
Call Putstrng
Mov Bh, 0
Call Putdec ; cout << Ax ;
Mov Ah, 4ch
Int 21h
main Endp ; }
Code Ends
SSeg Segment STACK ;;Stack segment of 254 bytes
DB 254 dup(?)
SSeg Ends
End main
|
The object code of a program using these input/output routines must be combined with the io.lib object code by the linker. The commands to assemble and link the following program source named Hw3.asm are:io.lib
ml /Fl Hw3.asm /link io.lib