![]() |
China DOS Union-- Unite DOS · Advance DOS · Grow DOS --Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum |
| Guest | Log in | Register | Members | Search | China DOS Union |
|
中国DOS联盟论坛 The time now is 2026-09-15 00:18 |
47,812 topics / 349,917 posts / today 0 new / 48,268 members |
| DOS开发编程 & 发展交流 (开发室) » Assembler compilers use 6 |
| Printable Version 2,608 / 6 |
| Floor1 chrise | Posted 2010-04-12 23:30 |
| 初级用户 Posts 32 Credits 88 | |
|
### Translation:
### Write a main program that inputs two non-compressed BCD numbers from the keyboard and stores them in AX. In the future, it will be converted into a binary number. An far-type subroutine should be written. If the character is to be displayed, a near-type subroutine can be implemented, or a source-type subroutine can be implemented. When the main program is executed, the data can be input cyclically and ends when '00' is encountered. NAME EX_05_19 STACKS SEGMENT DB 100 DUP(0) STACKS ENDS EXTRN CON:FAR,DISP:FAR CODES SEGMENT ASSUME CS:CODES,SS:STACKS MAIN PROC FAR START:PUSH DS MOV AX,0 PUSH AX REV:MOV AX,1 INT 21H MOV BL,AL INT 21H MOV AH,AL MOV AL,BL CMP AX,3030H JE ENDTRAN CALL NEAR PTR TRAN CALL FAR PTR CON MOV AL,0DH CALL FAR PTR DISP MOV AL,0AH CALL FAR PTR DISP JMP REV ENDTRAN:RET MAIN ENDP TRAN PROC NEAR AND AX,0F0FH MOV BL,AL MOV CL,3 SHL BL,CL MOV CL,1 SHL AL,CL ADD AL,BL ADD AL,AH RET TRAN ENDP CODES ENDS END START NAME EX_05_09_2 PUBLIC CON,DISP CSBG SEGMENT PARA 'CODE' ASSUME CS:CSBG CON PROC FAR PUSH AX MOV CL,4 SHR AL,CL ADD AL,30H ADD AL,30H CMP AL,39H JBE CON2 ADD AL,7 CON2:PUSH AX MOV AL,0DH CALL FAR PTR DISP; I don't understand MOV AL,0AH CALL FAR PTR DISP POP AX CALL FAR PTR DISP POP AX AND AL,0FH ADD AL,30H CMP AL,39H JBE CON1 ADD AL,07H CON1:CALL DISP RET CON ENDP DISP PROC FAR MOV DL,AL MOV AH,2 INT 21H RET DISP ENDP CSBG ENDS END There is a problem with the program when running. There are the following doubts: 1) Can you tell me about the code problem. The numbers input from the keyboard are represented by hexadecimal codes. I asked before, what code does it become after conversion through the subroutine TRAN? Is it necessary to use MOV DL,02H, int21H to display in hexadecimal code. To be honest, I don't understand this question at all. Can you tell me in detail how they convert? 2) I marked a sentence and think that FAR should be changed to NEAR, which is within the segment Thanks ### Note: The part with ... is the original content that remains as is as per the requirements. |
|
| Floor2 chrise | Posted 2010-04-14 19:30 |
| 初级用户 Posts 32 Credits 88 | |
|
Brother 070, you are originally an elder brother. Please be so kind as to answer.
|
|
| Floor3 070 | Posted 2010-04-14 21:15 |
| 高级用户 Posts 218 Credits 663 From 福建 | |
Originally posted by chrise at 2010-4-14 19:30: I'm not a brother, I'm also a novice, and my assembly knowledge is also half-baked, heh. I have to read books to answer your questions. Ben Shi is definitely a brother, he has written many assembly programs. First of all, you asked what the following code does earlier, and I didn't answer clearly. STACKS SEGMENT DB 100 DUP(0) ;This should be applying for stack space, 100 bytes, initial value all 0. DB and DUP are pseudo-code, you can find them in the book. STACKS ENDS
Did you input all the posted code into one file? That won't work. This program should be to demonstrate how two source files are assembled into an executable program together, so far pointers are needed. I changed it into two files, but it still didn't succeed, I can only wait for Brother Ben Shi, heh. Here is the function of BCD code, http://baike.baidu.com/view/45179.htm. Computers don't know that the data they process is BCD code, they only recognize binary. Hexadecimal is adopted because it is convenient to represent binary. You can also use decimal instead of hexadecimal in assembly code. |
|
| Floor4 chrise | Posted 2010-04-14 23:06 |
| 初级用户 Posts 32 Credits 88 | |
|
But I still don't quite understand that code problem.
|
|
| Floor5 本是 | Posted 2010-04-15 20:20 |
| 银牌会员 Posts 790 Credits 2,227 | |
|
Rev:mov aH,1
shl Al,cl MOV CL,1 MOV CL,1 shl Bl,cl 改 ADD AL,30H 为 一行add al,30h ADD AL,30H CALL FAR PTR DISP;不明白 MOV AL,0AH 改为两行,如 CALL FAR PTR DISP;不明白 MOV AL,0AH Then it can be assembled and linked, and then executed. Input two - digit BCD numbers to get hexadecimal numbers. |
|
| Floor6 070 | Posted 2010-04-15 21:29 |
| 高级用户 Posts 218 Credits 663 From 福建 | |
|
Originally, the purpose of his assembly example seems to be to demonstrate compiling two files together, not in one file
|
|
| Floor7 本是 | Posted 2010-04-15 23:00 |
| 银牌会员 Posts 790 Credits 2,227 | |
|
Of course! The file name prompt EX_05_19 is in front of his source program. After I made changes, I assembled (masm EX_05_19; and masm EX_05_09_2;), linked (link EX_05_19+EX_05_09_2) and ran for verification: as modified in floor 5, it was successful.
[ Last edited by 本是 on 2010-4-15 at 23:02 ] |
|
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |