高分悬赏!关于汇编语言的一些问题!

1) Add the contents of six memory bytes andd store the sum in memory:

a) Define variable VAR in the data segment to be 6 bytes long with random numbers in each byte.
b) Define a one-byte variable ANSWER that is initialized to zero.
c) Add VAR[0] through VAR[5] (6 bytes in total)
d) Put the sum in ANSWER.
e) Use a looping and any addressing mode that you find acceptable.

2)Change question one to keep track each time the carry bit is set.

a) Use a new variable called ANSWER1.
b) Each time carry is set add one to ANSWER1

Note: The word-size sum of all the bytes is: ANSWER1 for the high byte, ANSWER for the low byte.

3. This program is to count the number of lower and upper case characters and store the result in memory.
a) Store a string that includes upper case, lower case and other ASCII characters at location STRING1.
b) Write a program that reads 20 bytes of the character data that are stored at location STRING1 and counts the number of upper case characters. And the number of lower case charactors.
c) Store this total in location UPPER and location LOWER.

4. Change question three to keep reading any number of data bytes until the sentinal value 0FF16 is encountered. Make sure that the last byte stored at location STRING1 has the value 0FF16.

5. Write a program that gets a byte of data from location DATA1.
a) If DATA1 has bit 0 set, subtract 2016 from the value.
b) If bit 7 is set, clear bits 4 through 7.
c) If both bit 0 and bit 7 are set, then toggle bits 0 through 3.

Hint: You may find the test instruction useful for this problem.

6. Write a program which returns to DOS if x is pressed. Any other key is to be echoed to the screen.
This interrupt waits for a key press and returns the keycode:
mov ah,00h
int 16h ;interrupt 16h, function 0h
Exit condition:
• AH returns the keyboard scan code
• AL returns the ASCII character code

Key Scan code ASCII code
A 1Eh 41h (61h)
X 2Dh 58h (78h)
X 01h 1Bh
应楼下要求,悬赏我提高了50分.
但是我要的是完整详细的答案,不是要翻译....所以不能给你分~但是还是谢谢你.
继续等待.

第5题有点迷糊...

感谢锟鹏展翅为我找出错误,谢谢!
现在可能没问题了呵呵...
有什么问题的话还请指出

1

assume cs:code, ds:datas

datas segment
var db 100, 77, 69, 201, 32, 148
answer db 0
datas ends

code segment
start:
mov bx, datas
mov ds, bx

mov cx, 6
mov bx, offset var
xor ax, ax
mov si, 0

next:
add al, [bx+si]
inc si
loop next

mov [answer], al

mov ax, 4c00h
int 21h
code ends
end start

2

assume cs:code, ds:datas

datas segment
var db 100, 77, 69, 201, 32, 148
answer db 0
answer1 db 0
datas ends

code segment
start:
mov bx, datas
mov ds, bx

mov cx, 6
mov bx, offset var
xor ax, ax
mov si, 0

next:
add al, [bx+si]
adc ah, 0
inc si
loop next

;mov word ptr [answer], ax
mov answer, al
mov answer1, ah

mov ax, 4c00h
int 21h
code ends
end start

3

assume cs:code, ds:datas

datas segment
string1 db 'Should Auld Acquaint|ance Be Forgot, And Never Brought To Mind?'
upper db 0
lower db 0
datas ends

code segment
start:
mov bx, datas
mov ds, bx
mov bx, offset string1
mov si, 0

nxt0:
cmp si, 20
jz done
mov al, byte ptr [bx+si]
cmp al, 65
jl nxt2
cmp al, 122
jg nxt2
cmp al, 90
jg nxt1
add [upper], 1
jmp nxt2
nxt1:
add [lower], 1
nxt2:
inc si
jmp nxt0
done:

mov ax, 4c00h
int 21h
code ends
end start

4

assume cs:code, ds:datas

datas segment
string1 db 'Should Auld Acquaintance Be Forgot, And Never Brought To Mind?',16h,0ffh
upper db 0
lower db 0
datas ends

code segment
start:
mov bx, datas
mov ds, bx
mov bx, offset string1
mov si, 0

nxt0:
mov cx, word ptr [bx+si]
cmp cx, 0ff16h
jz done
mov al, byte ptr [bx+si]
cmp al, 65
jl nxt2
cmp al, 122
jg nxt2
cmp al, 90
jg nxt1
add [upper], 1
jmp nxt2
nxt1:
add [lower], 1
nxt2:
inc si
jmp nxt0
done:

mov ax, 4c00h
int 21h
code ends
end start

5

这题题目可能有错吧,为了第2小问能减去2016,我把ax拿来操作了,其他几问的操作都是在ah里完成的:
assume cs:code, ds:datas

datas segment
data1 dw 1234h
datas ends

code segment
start:
mov bx, datas
mov ds, bx

mov ax, [data1]

test ah, 1
jz nxt0
sub ax, 2016
nxt0:
test ah, 80h
jz nxt1
and ah, 0fh
nxt1:
test ah, 81h
jz nxt2
mov bh, ah
not bh
and bh, 0fh
and ah, 0f0h
or ah, bh
nxt2:
mov data1, ax

mov ax, 4c00h
int 21h
code ends
end start

6

assume cs:code

code segment
start:

lp0:
mov ah, 0
int 16h
cmp al, 78h
jz done
cmp al, 58h
jz done
mov dl, al
mov ah, 2h
int 21h
jmp lp0
done:

mov ax, 4c00h
int 21h
code ends
end start
温馨提示:答案为网友推荐,仅供参考
第1个回答  2007-11-01
1.
DATA SEGMENT
VAR DB 1,2,3,6,5,4
ANSWER DB 0
DATA ENDS
CODE SEGMENT
ASSUME DS:DATA,CS:CODE
START:
MOV AX,DATA
MOV DS,AX
LEA SI,VAR
MOV CX,6
MOV AL,0
STEP:
ADD AL,[SI]
INC SI
LOOP STEP
MOV ANSWER,AL
MOV AH,1
INT 21H
MOV AX,4C00H
INT 21H
CODE ENDS
END START
2.
DATA SEGMENT
VAR DB 1,2,3,6,5,4
ANSWER DB 0
ANSWER1 DB ?
DATA ENDS
CODE SEGMENT
ASSUME DS:DATA,CS:CODE
START:
MOV AX,DATA
MOV DS,AX
LEA SI,VAR
MOV CX,6
MOV AX,0
STEP:
ADD AL,[SI]
ADC AH,0
INC SI
LOOP STEP
MOV ANSWER,AL
MOV ANSWER1,AH
MOV AH,1
INT 21H
MOV AX,4C00H
INT 21H
CODE ENDS
END START
3.
DATA SEGMENT
STRING1 DB 'THE second answer of 飘渺世间天 committed a mistake that the order about ANSWER and ANSWER1 is reversal.'
UPPER DB ?
LOWER DB ?
DATA ENDS
CODE SEGMENT
ASSUME DS:DATA,CS:CODE
START:
MOV AX,DATA
MOV DS,AX
LEA SI,STRING1
MOV CX,20
STEP:
ADD AL,[SI]
CMP AL,41H
JB NEXT
CMP AL,5AH
JA LOW
INC UPPER
JMP NEXT
LOW:
CMP AL,61H
JB NEXT
CMP AL,7AH
JA NEXT
INC LOWER
NEXT:
INC SI
LOOP STEP
MOV AH,1
INT 21H
MOV AX,4C00H
INT 21H
CODE ENDS
END START
4.
DATA SEGMENT
STRING1 DB 'THE fourth answer of 飘渺世间天 supposed that the number of STRING1 is even so that there are not generic.',16h,0FFH
UPPER DB ?
LOWER DB ?
DATA ENDS
CODE SEGMENT
ASSUME DS:DATA,CS:CODE
START:
MOV AX,DATA
MOV DS,AX
LEA SI,STRING1
STEP:
ADD AL,[SI]
CMP AL,16H
JNZ STEP1
CMP BYTE PTR [SI+1],0FFH
JZ TJ
STEP1:
CMP AL,41H
JB NEXT
CMP AL,5AH
JA LOW
INC UPPER
JMP NEXT
LOW:
CMP AL,61H
JB NEXT
CMP AL,7AH
JA NEXT
INC LOWER
NEXT:
INC SI
JMP STEP
TJ:
MOV AH,1
INT 21H
MOV AX,4C00H
INT 21H
CODE ENDS
END START
5.本题有处错误,从DATA1为字节变量,不应该减2016,所以令减去201,程序如下:
DATA SEGMENT
DATA1 DB 21H
DATA ENDS
CODE SEGMENT
ASSUME DS:DATA,CS:CODE
START:
MOV AX,DATA
MOV DS,AX
LEA AL,DATA1
TEST AL,1
JZ NEXT
SUB DATA1,201
MOV AH,1
NEXT:
TEST AL,80H
JZ TJ
CMP AH,1
JNZ NEXT1
XOR DATA1,0FH
JMP TJ
NEXT1:
AND DATA,0FH
TJ:
MOV AH,1
INT 21H
MOV AX,4C00H
INT 21H
CODE ENDS
END START
6.
CODE SEGMENT
ASSUME DS:DATA,CS:CODE
START:
MOV AH,0
INT 16H
CMP AL,78H
JZ TJ
MOV DL,AL
MOV AH,2
INT 21H
JMP START
TJ:
MOV AH,1
INT 21H
MOV AX,4C00H
INT 21H
CODE ENDS
END START
第2个回答  2007-11-01
嘿嘿。我才16岁、能力有限。
况且汇编也不太懂,忽忽。
楼猪是程序员吧?
汇编确实很难噢、
楼猪好小气、看了我好一段时间、才给100分而已。
记得给我最佳答案哈。

第一句、我也不太清楚貌似是 增加六个记忆字节内容和存放
a) 长期定义易变的VAR 在数据段是6 个字节以随机号在各个字节。
b) 定义初始化到零的一个一字节易变的答复。
c) 增加VAR[0 ] 通过VAR[5 ] (6 个字节总共)
d) 投入总和在答复。
e) 使用一个使成环的和任一个寻址模式, 您发现可接受。

第二 这句我看不明白、忽忽。
我把A 和B 翻译出来吧
a) 使用新易变的告诉的ANSWER1 。
b) 每次运载是集合加一来ANSWER1

第三句

3. 这个节目将计数更低和大写体字符的数量和存放结果在记忆。
a) 存放包括大写的串, 小写和其它ASCII 字符在地点STRING1 。
b) 写读字符数据20 个字节被存放在地点STRING1 并且计数大写体字符的数量的一个节目。并且小写charactors 的数量。
c) 英语不怎么好、这句不认识。

第四句的意思是
改变问题三到保留读任一个数据字节的数字直到sentinal 价值0FF16 遇到。确信, 最后字节被存放在地点STRING1 有价值0FF16 。

第五句
5. 写得到数据字节从地点DATA1 的一个节目。
a) 如果DATA1 咬住了0 个集合, 减去2016 年从价值。
b) 如果位7 被设置, 清楚的位4 至7 。
c) 如果位0 和被咬住的7 被设置, 然后乒乓键位0 至3 。

提示: 您可以找到测试指示有用为这个问题。

最后一句"终于弄完了.楼猪满意不?"
6. 写回到DOS 的一个节目如果x 被按。其他钥匙将echoed 对屏幕。
这个中断等一则关键新闻和退回keycode:
运动啊, 00h
内部16h;interrupt 16h, 作用0h
出口情况:
• 退回键盘扫瞄码
• AL 退回ASCII 字符代码

关键扫瞄码ASCII 代码
1Eh 41h (61h)
x 2Dh 58h (78h)
x 01h 1Bh
第3个回答  2007-11-01
我给你两个汇编群,你去那里问吧,很多高手的. 汇编群5466089

7429467
相似回答
大家正在搜